2.5.13: Optimize organization of m2w configuration. Both password and REST API supported!
Project description
English | 简体中文
m2w: Markdown to WordPress
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
Table of Contents
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 withm2w 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
andupload.py
inm2w 1.0
). - Ignore repeated new markdown files for uploading (
v2.2.4+
)
Install
Miniconda is recommended to manage Python version and related dependencies.
Here is the dependency:
# 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. 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
:
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:
- Go to personal settings and add a new REST API:
- 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:
Use m2w
- Install m2w from PyPi or this Github repotory.
- Build a
myblog.py
file (or other names you like) in<path01>
. Here is the demo. Create<path02>/config/user.json
and setpath_m2w
as<path02>
inmyblog.py
:
path_m2w = '<path02>' # Absolute path of m2w config folder
- Define
<path02>/config/user.json
. You can add many websites likeweb01
! Please go to the demo for more details. Here are some interpretations:
- user.json for REST API mode:
"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:
"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, andpassword
is the conventional passord of your account. if bothapplication_password
andpassword
exit, onlyapplication_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.
- Run
myblog.py
like:
python <path01>/myblog.py
Demo
This demo is conducted in Win10 with VScode.
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
!
LOG
- 2023-06-05: m2w 2.0 was frozen at v2.2.11. Enjoy m2w 2.5+ from now on!
- 2022-12-14:
m2w.py
is the same name asm2w
package, which would bring some bugs. I change the name of the demo script asmyblog.py
. - 2022-12-10:Upload
m2w 2
to PyPi. You can installm2w 2
with code (in Shell) likepip install -i https://pypi.org/simple m2w
. The project url is 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
tomarkdown-it-py
-
Support Hexo-like YAML head:
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
Maintainers
Contributing
Feel free to dive in! Open an issue or submit PRs. m2w follows the Contributor Covenant Code of Conduct.
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 for details.
More
Applications similar to m2w
- nefu-ljw/python-markdown-to-wordpress: The root project of m2w!
- WordPressXMLRPCTools: Manage WordPress posts in Hexo way.
- markpress: Write WordPress in Markdown in Your Favorite Text Editor
- 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file m2w-2.5.13.tar.gz
.
File metadata
- Download URL: m2w-2.5.13.tar.gz
- Upload date:
- Size: 20.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c61bbce643629ee3fe49ac2a42c51e6f68961bcd5e552f412dec47d6f5de6bae |
|
MD5 | 3a2ff8a07b13b8e651840aeaa9b85c94 |
|
BLAKE2b-256 | 422cf952fed918e4a2035082b149de4f4763bd3a523db1611121850a5a3ae834 |
File details
Details for the file m2w-2.5.13-py3-none-any.whl
.
File metadata
- Download URL: m2w-2.5.13-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb74acf8bc2009b5ddb2292bb7560792d3a588d19e24892b2f23a861c24aa77c |
|
MD5 | 81b7c40369052ce247ab2034fadf3bbd |
|
BLAKE2b-256 | 08c6bb4b050a4306aa1eeda1bc6221cc38a00eccdaa2b9588382b8a1f2c31346 |