wpsync - Markdown to WP
wpsync is a command-line tool to sync a local directory of markdown files to your WordPress.
I really like markdown and vim. My publishing process was:
- Create a draft in markdown,
- When ready to publish v1.0 copy-paste to WordPress; the editor converts markdown nicely, and then publish
- However, when a revision is needed, it must be done in WordPress not in my markdown/vim tools.
After publishing my Working with Vim tutorial, there was a lot of revisions and additions I needed to make, and I couldn't use vim. This seemed wrong writing a tutorial for vim, not in vim.
So I wrote the wpsync program which reads a directory of markdown files, and uses the WordPresss API to publish and update posts, pages, and media.
Here's a demo:
Install and Setup
You can view the code and download binary releases at github.com/mkaz/wpsync
Authentication on the command-line is the tricky bit. The JWT Authentication plugin is required and what makes it possible. For now this does not work for WordPress.com sites. For wpcom, it is possible to use a similar token for authentication, however I don't haven't setup a way to retrieve this token via the command-line.
Create a directory for your site, and sub-directories
pages. Any files in these directories will be uploaded.
wpsync --init for initial setup
wpsync -confirm to confirm each upload
See the readme in Github for full documentation.
Usage: wpsync [args] Arguments: -confirm Confirm prompt before upload -debug Display debug messages -dryrun Test run, shows what will happen -help Display help and quit -init Create settings for blog and auth -quiet Do not display info messages -test Test config and authentication -version Display version and quit
I'll probably keep tweaking away on this, right now there is only one-way sync from local to remote. It would be nice to be able to pull down existing posts, edit, and publish.
Any feedback, comments, issues, or even pull requests are welcome.