### [English](README.md) | [简体中文](README.zh-CN.md)
# m2w: Markdown to WordPress
<p align="left">
<a href=""><img src="https://img.shields.io/badge/python-3.7%2B-orange"></a>
<a href=""><img src="https://img.shields.io/badge/platform-Windows%7Clinux%7CMacOS-brightgreen"></a>
<a href=""><img src="https://img.shields.io/github/downloads/huangwb8/m2w/total"></a>
<a href=""><img src="https://img.shields.io/github/stars/huangwb8/m2w?style=social"></a>
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fhuangwb8%2Fm2w?ref=badge_shield" alt="FOSSA Status"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhuangwb8%2Fm2w.svg?type=shield"/></a>
</p>
Automatically upload and update local markdown to WordPress based on REST API/Password via Python
:star2::star2::star2: Welcome m2w 2.5!
Chinese tutorial: [Docker系列 WordPress系列 WordPress上传或更新Markdown的最佳实践-m2w 2.0](https://blognas.hwb0307.com/linux/docker/2813)
## Table of Contents
- [m2w: Markdown to WordPress](#m2w-markdown-to-wordpress)
- [Table of Contents](#table-of-contents)
- [Background](#background)
- [Install](#install)
- [Usage](#usage)
- [Enable REST API](#enable-rest-api)
- [Use m2w](#use-m2w)
- [Demo](#demo)
- [LOG](#log)
- [TO-DO](#to-do)
- [Related Efforts](#related-efforts)
- [Maintainers](#maintainers)
- [Contributing](#contributing)
- [License](#license)
- [More](#more)
## Background
`m2w` is a tool for automatically uploading or updating local Markdown to WordPress via Python, based on REST API (`2.5+`) or Password.
`m2w` has these features:
+ **Support REST API**, which is safer then conventional password!
+ Use `config/user.json` to maintain the user information in a little different way comparing with `m2w 1.0`.
+ You can just keep your file structures locally as you like.
+ You can manage lots of websites at the same time via multiple `legacy_*.json`.
+ All you need to deal with is a single python script `myblog.py` instead of two (`update.py` and `upload.py` in `m2w 1.0`).
+ Ignore repeated new markdown files for uploading (`v2.2.4+`)
## Install
> [Miniconda](https://docs.conda.io/en/latest/miniconda.html) is recommended to manage Python version and related dependencies.
Here is the dependency:
```python
# Python version
python_requires='>=3.7.6'
# Dependencies
install_requires=[
"python-frontmatter>=1.0.0",
"markdown>=3.3.6",
"python-wordpress-xmlrpc>=2.3",
"httpx>=0.24.0"
]
```
After 2022-12-10, `m2w` was uploaded onto [PyPi](https://pypi.org/project/m2w/). To install `m2w`, just run this code in your shell/conda environment:
```
pip install m2w
```
You can also directly download `m2w` from this repotory. The usage is exactly the same.
You can specify version or resource when installing `m2w`:
```bash
pip install -i https://pypi.org/simple m2w==2.5.12
```
Generally, the latest version of `m2w` is recommended.
## Usage
### Enable REST API
> This step is needed only **when you want to use the REST API mode**.
+ If any, please allow Application password of WordPress in Wordfence:
![WBrffVs5Ty](https://chevereto.hwb0307.com/images/2023/06/05/WBrffVs5Ty.png)
+ Go to personal settings and add a new REST API:
![sq7kG7Vsqp](https://chevereto.hwb0307.com/images/2023/06/05/sq7kG7Vsqp.png)
+ Please record the new REST API in a safe place. If you forget it or suspect its safety, please remove the old API and create a new one:
![GddR0nP8mn](https://chevereto.hwb0307.com/images/2023/06/05/GddR0nP8mn.png)
### Use m2w
1. Install m2w from PyPi or this Github repotory.
2. Build a `myblog.py` file (or other names you like) in `<path01>`. Here is the [demo](https://github.com/huangwb8/m2w/blob/main/myblog.py). Create `<path02>/config/user.json` and set `path_m2w` as `<path02>` in `myblog.py`:
```python
path_m2w = '<path02>' # Absolute path of m2w config folder
```
3. Define `<path02>/config/user.json`. You can add many websites like `web01`! Please go to the [demo](https://github.com/huangwb8/m2w/blob/main/config/user.json) for more details. Here are some interpretations:
+ **user.json** for REST API mode:
```json
"web01": {
"domain": "https://domain-01.com",
"username": "username-01",
"application_password": "password-01",
"path_markdown": [
"E:/Github/m2w/@test/main",
"E:/Github/m2w/@test/main2"
],
"post_metadata": {
"category": ["test"],
"tag": ["test"],
"status": "publish"
},
"path_legacy_json": "/config/legacy"
}
```
+ **user.json** for Password mode:
```json
"web01": {
"domain": "https://domain-01.com",
"username": "username-01",
"password": "password-01",
"path_markdown": [
"E:/Github/m2w/@test/main",
"E:/Github/m2w/@test/main2"
],
"post_metadata": {
"category": ["test"],
"tag": ["test"],
"status": "publish"
},
"path_legacy_json": "/config/legacy"
}
```
+ **domain, username, application_password/password**: The information of your WordPress site and account. `application_password` is REST API, and `password` is the conventional passord of your account. if both `application_password` and `password` exit, only `application_password` is available for m2w.
+ **path_markdown**: Add as much top folders as you want!
+ **post_metadata/path_legacy_json**: Set default if you don't know what they are.
4. Run `myblog.py` like:
```bash
python <path01>/myblog.py
```
## Demo
> This demo is conducted in Win10 with [VScode](https://code.visualstudio.com/).
As shown in the following GIF, all changed or brand-new markdowns can be automatically updated/upload via just a simple command `python myblog.py`!
![image-20230609173358533](https://chevereto.hwb0307.com/images/2023/06/09/image-20230609173358533.png)
## LOG
+ **2023-06-05**: m2w 2.0 was frozen at [v2.2.11](https://github.com/huangwb8/m2w/releases/tag/v2.2.11). Enjoy m2w 2.5+ from now on!
+ **2022-12-14**:`m2w.py` is the same name as `m2w` package, which would bring some bugs. I change the name of the demo script as `myblog.py`.
+ **2022-12-10**:Upload `m2w 2` to PyPi. You can install `m2w 2` with code (in Shell) like `pip install -i https://pypi.org/simple m2w`. The project url is [https://pypi.org/project/m2w](https://pypi.org/project/m2w).
+ **2022-12-08**:Ignore repeated uploading of new markdown based on their file names. Update ot `m2w 2.2.4` (Strongly recommended)!
+ **2022-12-06**:Optimized parameter space of m2w, which make it more flexible. Update ot `m2w 2.2`!
+ **2022-12-03**:Brand-new m2w 2.0!
+ **2022-11-13**:Add error control for the `Client` function, which is helpful to avoid legacy bugs if the connection to the WordPress website is not available.
+ **Before**: Create `m2w` project.
## TO-DO
- [ ] shuoshuo and page update & upload
- [ ] Enhanced markdown support: `python-markdown` to `markdown-it-py`
- [ ] Support Hexo-like YAML head:
```yaml
title: I Love You
tags:
- You
- I
- Love
categories:
- Note
date: 2023-11-08 16:38:31
update: 2023-11-08 16:40:31
--
```
- [ ] Develop GUI across OS
## Related Efforts
- [nefu-ljw/python-markdown-to-wordpress](https://github.com/nefu-ljw/python-markdown-to-wordpress)
## Maintainers
+ [@huangwb8](https://t.me/hwb0307)
## Contributing
> Feel free to dive in! [Open an issue](https://github.com/huangwb8/m2w/issues/new) or submit PRs. m2w follows the [Contributor Covenant](http://contributor-covenant.org/version/1/3/0/) Code of Conduct.
+ [@FoxSuzuran](https://github.com/FoxSuzuran)
## License
This software depends on other packages that may be licensed under different open source licenses.
m2w is released under the MIT license. See [LICENSE](https://github.com/huangwb8/m2w/blob/main/license.txt) for details.
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhuangwb8%2Fm2w.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhuangwb8%2Fm2w?ref=badge_large)
## More
> Applications similar to m2w
+ [nefu-ljw/python-markdown-to-wordpress](https://github.com/nefu-ljw/python-markdown-to-wordpress): The root project of m2w!
+ [WordPressXMLRPCTools](https://github.com/zhaoolee/WordPressXMLRPCTools): Manage WordPress posts in Hexo way.
+ [markpress](https://github.com/skywind3000/markpress): Write WordPress in Markdown in Your Favorite Text Editor
+ [wordpress-markdown-blog-loader](https://pypi.org/project/wordpress-markdown-blog-loader/): This utility loads markdown blogs into WordPress as a post. It allows you to work on your blog in your favorite editor and keeps all your blogs in git.
Raw data
{
"_id": null,
"home_page": "https://github.com/huangwb8/m2w",
"name": "m2w",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7.6",
"maintainer_email": null,
"keywords": "markdown, wordpress, xmlrpc",
"author": "['Bensz', 'FoxSuzuran']",
"author_email": "hwb2012@qq.com",
"download_url": "https://files.pythonhosted.org/packages/42/2c/f952fed918e4a2035082b149de4f4763bd3a523db1611121850a5a3ae834/m2w-2.5.13.tar.gz",
"platform": null,
"description": "### [English](README.md) | [\u7b80\u4f53\u4e2d\u6587](README.zh-CN.md)\r\n\r\n# m2w: Markdown to WordPress\r\n\r\n<p align=\"left\">\r\n<a href=\"\"><img src=\"https://img.shields.io/badge/python-3.7%2B-orange\"></a>\r\n<a href=\"\"><img src=\"https://img.shields.io/badge/platform-Windows%7Clinux%7CMacOS-brightgreen\"></a>\r\n<a href=\"\"><img src=\"https://img.shields.io/github/downloads/huangwb8/m2w/total\"></a>\r\n<a href=\"\"><img src=\"https://img.shields.io/github/stars/huangwb8/m2w?style=social\"></a>\r\n<a href=\"https://app.fossa.com/projects/git%2Bgithub.com%2Fhuangwb8%2Fm2w?ref=badge_shield\" alt=\"FOSSA Status\"><img src=\"https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhuangwb8%2Fm2w.svg?type=shield\"/></a>\r\n</p>\r\nAutomatically upload and update local markdown to WordPress based on REST API/Password via Python\r\n\r\n:star2::star2::star2: Welcome m2w 2.5!\r\n\r\nChinese tutorial: [Docker\u7cfb\u5217 WordPress\u7cfb\u5217 WordPress\u4e0a\u4f20\u6216\u66f4\u65b0Markdown\u7684\u6700\u4f73\u5b9e\u8df5-m2w 2.0](https://blognas.hwb0307.com/linux/docker/2813)\r\n\r\n\r\n## Table of Contents\r\n\r\n- [m2w: Markdown to WordPress](#m2w-markdown-to-wordpress)\r\n - [Table of Contents](#table-of-contents)\r\n - [Background](#background)\r\n - [Install](#install)\r\n - [Usage](#usage)\r\n - [Enable REST API](#enable-rest-api)\r\n - [Use m2w](#use-m2w)\r\n - [Demo](#demo)\r\n - [LOG](#log)\r\n - [TO-DO](#to-do)\r\n - [Related Efforts](#related-efforts)\r\n - [Maintainers](#maintainers)\r\n - [Contributing](#contributing)\r\n - [License](#license)\r\n - [More](#more)\r\n\r\n## Background\r\n\r\n`m2w` is a tool for automatically uploading or updating local Markdown to WordPress via Python, based on REST API (`2.5+`) or Password.\r\n\r\n`m2w` has these features: \r\n\r\n+ **Support REST API**, which is safer then conventional password!\r\n+ Use `config/user.json` to maintain the user information in a little different way comparing with `m2w 1.0`.\r\n+ You can just keep your file structures locally as you like.\r\n+ You can manage lots of websites at the same time via multiple `legacy_*.json`.\r\n+ All you need to deal with is a single python script `myblog.py` instead of two (`update.py` and `upload.py` in `m2w 1.0`).\r\n+ Ignore repeated new markdown files for uploading (`v2.2.4+`)\r\n\r\n## Install\r\n\r\n> [Miniconda](https://docs.conda.io/en/latest/miniconda.html) is recommended to manage Python version and related dependencies.\r\n\r\nHere is the dependency: \r\n\r\n```python\r\n# Python version\r\npython_requires='>=3.7.6'\r\n\r\n# Dependencies\r\ninstall_requires=[\r\n \"python-frontmatter>=1.0.0\",\r\n \"markdown>=3.3.6\",\r\n \"python-wordpress-xmlrpc>=2.3\",\r\n \"httpx>=0.24.0\"\r\n]\r\n```\r\n\r\nAfter 2022-12-10, `m2w` was uploaded onto [PyPi](https://pypi.org/project/m2w/). To install `m2w`, just run this code in your shell/conda environment:\r\n\r\n```\r\npip install m2w\r\n```\r\n\r\nYou can also directly download `m2w` from this repotory. The usage is exactly the same.\r\n\r\nYou can specify version or resource when installing `m2w`:\r\n\r\n```bash\r\npip install -i https://pypi.org/simple m2w==2.5.12\r\n```\r\n\r\nGenerally, the latest version of `m2w` is recommended.\r\n\r\n## Usage\r\n\r\n### Enable REST API\r\n\r\n> This step is needed only **when you want to use the REST API mode**.\r\n\r\n+ If any, please allow Application password of WordPress in Wordfence:\r\n\r\n![WBrffVs5Ty](https://chevereto.hwb0307.com/images/2023/06/05/WBrffVs5Ty.png)\r\n\r\n+ Go to personal settings and add a new REST API: \r\n\r\n![sq7kG7Vsqp](https://chevereto.hwb0307.com/images/2023/06/05/sq7kG7Vsqp.png)\r\n\r\n+ Please record the new REST API in a safe place. If you forget it or suspect its safety, please remove the old API and create a new one:\r\n\r\n![GddR0nP8mn](https://chevereto.hwb0307.com/images/2023/06/05/GddR0nP8mn.png)\r\n\r\n### Use m2w\r\n\r\n1. Install m2w from PyPi or this Github repotory. \r\n2. Build a `myblog.py` file (or other names you like) in `<path01>`. Here is the [demo](https://github.com/huangwb8/m2w/blob/main/myblog.py). Create `<path02>/config/user.json` and set `path_m2w` as `<path02>` in `myblog.py`:\r\n\r\n```python\r\npath_m2w = '<path02>' # Absolute path of m2w config folder\r\n```\r\n\r\n3. Define `<path02>/config/user.json`. You can add many websites like `web01`! Please go to the [demo](https://github.com/huangwb8/m2w/blob/main/config/user.json) for more details. Here are some interpretations: \r\n + **user.json** for REST API mode:\r\n\r\n\r\n```json\r\n\"web01\": {\r\n \"domain\": \"https://domain-01.com\",\r\n \"username\": \"username-01\",\r\n \"application_password\": \"password-01\",\r\n \"path_markdown\": [\r\n \"E:/Github/m2w/@test/main\",\r\n \"E:/Github/m2w/@test/main2\"\r\n ],\r\n \"post_metadata\": {\r\n \"category\": [\"test\"],\r\n \"tag\": [\"test\"],\r\n \"status\": \"publish\"\r\n },\r\n \"path_legacy_json\": \"/config/legacy\"\r\n }\r\n```\r\n\r\n+ **user.json** for Password mode: \r\n\r\n\r\n```json\r\n\"web01\": {\r\n \"domain\": \"https://domain-01.com\",\r\n \"username\": \"username-01\",\r\n \"password\": \"password-01\",\r\n \"path_markdown\": [\r\n \"E:/Github/m2w/@test/main\",\r\n \"E:/Github/m2w/@test/main2\"\r\n ],\r\n \"post_metadata\": {\r\n \"category\": [\"test\"],\r\n \"tag\": [\"test\"],\r\n \"status\": \"publish\"\r\n },\r\n \"path_legacy_json\": \"/config/legacy\"\r\n }\r\n```\r\n\r\n + **domain, username, application_password/password**: The information of your WordPress site and account. `application_password` is REST API, and `password` is the conventional passord of your account. if both `application_password` and `password` exit, only `application_password` is available for m2w.\r\n + **path_markdown**: Add as much top folders as you want! \r\n + **post_metadata/path_legacy_json**: Set default if you don't know what they are. \r\n\r\n4. Run `myblog.py` like: \r\n\r\n```bash\r\npython <path01>/myblog.py\r\n```\r\n\r\n## Demo\r\n\r\n> This demo is conducted in Win10 with [VScode](https://code.visualstudio.com/).\r\n\r\nAs shown in the following GIF, all changed or brand-new markdowns can be automatically updated/upload via just a simple command `python myblog.py`!\r\n\r\n![image-20230609173358533](https://chevereto.hwb0307.com/images/2023/06/09/image-20230609173358533.png)\r\n\r\n## LOG\r\n\r\n+ **2023-06-05**: m2w 2.0 was frozen at [v2.2.11](https://github.com/huangwb8/m2w/releases/tag/v2.2.11). Enjoy m2w 2.5+ from now on!\r\n+ **2022-12-14**\uff1a`m2w.py` is the same name as `m2w` package, which would bring some bugs. I change the name of the demo script as `myblog.py`.\r\n+ **2022-12-10**\uff1aUpload `m2w 2` to PyPi. You can install `m2w 2` with code (in Shell) like `pip install -i https://pypi.org/simple m2w`. The project url is [https://pypi.org/project/m2w](https://pypi.org/project/m2w).\r\n+ **2022-12-08**\uff1aIgnore repeated uploading of new markdown based on their file names. Update ot `m2w 2.2.4` (Strongly recommended)! \r\n+ **2022-12-06**\uff1aOptimized parameter space of m2w, which make it more flexible. Update ot `m2w 2.2`!\r\n+ **2022-12-03**\uff1aBrand-new m2w 2.0!\r\n+ **2022-11-13**\uff1aAdd error control for the `Client` function, which is helpful to avoid legacy bugs if the connection to the WordPress website is not available.\r\n+ **Before**: Create `m2w` project.\r\n\r\n## TO-DO\r\n\r\n- [ ] shuoshuo and page update & upload\r\n\r\n- [ ] Enhanced markdown support: `python-markdown` to `markdown-it-py`\r\n\r\n- [ ] Support Hexo-like YAML head\uff1a\r\n\r\n```yaml\r\ntitle: I Love You\r\ntags:\r\n - You\r\n - I\r\n - Love\r\ncategories:\r\n - Note\r\ndate: 2023-11-08 16:38:31\r\nupdate: 2023-11-08 16:40:31\r\n--\r\n```\r\n\r\n- [ ] Develop GUI across OS\r\n\r\n## Related Efforts\r\n\r\n- [nefu-ljw/python-markdown-to-wordpress](https://github.com/nefu-ljw/python-markdown-to-wordpress)\r\n\r\n## Maintainers\r\n\r\n+ [@huangwb8](https://t.me/hwb0307)\r\n\r\n## Contributing\r\n\r\n> Feel free to dive in! [Open an issue](https://github.com/huangwb8/m2w/issues/new) or submit PRs. m2w follows the [Contributor Covenant](http://contributor-covenant.org/version/1/3/0/) Code of Conduct.\r\n\r\n+ [@FoxSuzuran](https://github.com/FoxSuzuran)\r\n\r\n\r\n## License\r\n\r\nThis software depends on other packages that may be licensed under different open source licenses. \r\n\r\nm2w is released under the MIT license. See [LICENSE](https://github.com/huangwb8/m2w/blob/main/license.txt) for details.\r\n\r\n\r\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhuangwb8%2Fm2w.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhuangwb8%2Fm2w?ref=badge_large)\r\n\r\n## More\r\n\r\n> Applications similar to m2w\r\n\r\n+ [nefu-ljw/python-markdown-to-wordpress](https://github.com/nefu-ljw/python-markdown-to-wordpress): The root project of m2w!\r\n+ [WordPressXMLRPCTools](https://github.com/zhaoolee/WordPressXMLRPCTools): Manage WordPress posts in Hexo way.\r\n+ [markpress](https://github.com/skywind3000/markpress): Write WordPress in Markdown in Your Favorite Text Editor\r\n+ [wordpress-markdown-blog-loader](https://pypi.org/project/wordpress-markdown-blog-loader/): This utility loads markdown blogs into WordPress as a post. It allows you to work on your blog in your favorite editor and keeps all your blogs in git.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "2.5.13: Optimize organization of m2w configuration. Both password and REST API supported!",
"version": "2.5.13",
"project_urls": {
"Homepage": "https://github.com/huangwb8/m2w"
},
"split_keywords": [
"markdown",
" wordpress",
" xmlrpc"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "08c6bb4b050a4306aa1eeda1bc6221cc38a00eccdaa2b9588382b8a1f2c31346",
"md5": "81b7c40369052ce247ab2034fadf3bbd",
"sha256": "fb74acf8bc2009b5ddb2292bb7560792d3a588d19e24892b2f23a861c24aa77c"
},
"downloads": -1,
"filename": "m2w-2.5.13-py3-none-any.whl",
"has_sig": false,
"md5_digest": "81b7c40369052ce247ab2034fadf3bbd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.6",
"size": 23960,
"upload_time": "2024-11-13T13:56:26",
"upload_time_iso_8601": "2024-11-13T13:56:26.759963Z",
"url": "https://files.pythonhosted.org/packages/08/c6/bb4b050a4306aa1eeda1bc6221cc38a00eccdaa2b9588382b8a1f2c31346/m2w-2.5.13-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "422cf952fed918e4a2035082b149de4f4763bd3a523db1611121850a5a3ae834",
"md5": "3a2ff8a07b13b8e651840aeaa9b85c94",
"sha256": "c61bbce643629ee3fe49ac2a42c51e6f68961bcd5e552f412dec47d6f5de6bae"
},
"downloads": -1,
"filename": "m2w-2.5.13.tar.gz",
"has_sig": false,
"md5_digest": "3a2ff8a07b13b8e651840aeaa9b85c94",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.6",
"size": 20756,
"upload_time": "2024-11-13T13:56:28",
"upload_time_iso_8601": "2024-11-13T13:56:28.620011Z",
"url": "https://files.pythonhosted.org/packages/42/2c/f952fed918e4a2035082b149de4f4763bd3a523db1611121850a5a3ae834/m2w-2.5.13.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-13 13:56:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "huangwb8",
"github_project": "m2w",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "m2w"
}