Haven’t been blogging for quite a while. I recently got around to redeploying and updating my WordPress blog to AWS Lightsail. It works so much better (and less expensive) now!
I had to figure out how to go from Emacs org mode to WordPress, so I am first trying it here on my personal blog. Since I use Spacemacs (in holy mode of course) as my form of Emacs, I wanted to add it as a Layer.
Spacemacs prefers you to have layers that combine packages and configuration. I could have just added it to
dotspacemacs-additional-packages in the spacemacs init file but I wanted to try doing it as a layer. I’ve tried (unsuccessfully) to create my own layers before, but I was determined to get it to work this time! Turns out there isn’t really that much of an advantage of using a layer in this case other than being able to pull it from github dynamically.
Creating a Layer
Use Spacemacs to make a private layer template
This will prompt you for a directory where your private layers go (mine was
~/.spacemacs.d/layers). Then it will prompt you for the name of the layer. In this case
It will then create a
README.org and a
packages.el with some things filled in. The README will be used for the help for the package.
Update the scaffold files to do the actual work
packages.elto the following (removed most of the boilerplate below)
;;; packages.el --- org2blog layer packages file for Spacemacs. (setq org2blog-packages '((org2blog :location (recipe :fetcher github :repo "org2blog/org2blog")))) (defun org2blog/init-org2blog () (use-package org2blog) ;(require 'org2blog-autoloads) ) ;;; packages.el ends here
The first statement
setq org2blog-packages will pull the package from github and the second statement
org2blog/init-org2blog will be used to initialize the package when its lazily loaded.
Then needed to add the layer (
org2blog) and its basic config to the spacemacs init file (
~/.spacemacs in my case).
The config specifies a list of blogs you can log into. This example shows only one. A more complicated config could go into the
dotspacemacs/user-config section of the spacemacs init file instead if you prefer.
dotspacemacs-configuration-layers '( (org2blog :variables org2blog/wp-blog-alist '(("my.blog.com" :url "https://my.blog.com/xmlrpc.php" :username "joe"))) ;; ... additional layers )
Once you have that all set, restart Spacemacs.
Taking it for a spin
It will let you select which blog (in this case
my.blog.com) and will ask you for the password.
At that point you can start writing your post! It will have put a few headers in that you could fill in at the top.
When you are ready to push it to your WordPress blog just incantate one of the following:
|post buffer as draft||C-c M-p d||M-x org2blog/wp-post-buffer|
|publish buffer||C-c M-p p||C-u M-x org2blog/wp-post-buffer|
|post buffer as page draft||C-c M-p D||M-x org2blog/wp-post-buffer-as-page|
|publish buffer as page||C-c M-p P||C-u M-x org2blog/wp-post-buffer-as-page|