![]() That way the second Hazel rule will not run a again. The easiest solution I came up with is to not overwrite the file if it exists in my “Posts” archive. If I accidentally make a small edit to an entry already tagged, It could get posted multiple times. I needed to avoid multiple posts of the same article if I made a small edit in Simplenote. Because I’m lazy and a bit squeezed for time I didn’t come up with a satisfactory way to avoid duplicate posts. Additionally, the Markdown version of the article is saved my archive folder for permanent reference. The article gets published by my server at home without any other effort from me. When I’m ready to post, I just add a Simplenote/NVAlt tag of “post” to the entry. I write as much as I want in MultiMarkdown in Simplenote/NVAlt. The new workflow looks something like this. I may yet use it to avoid double posting and make updating published posts possible. I considered using the Python WordPress XMLRPC module but it looked like over-kill for my needs. For a nice overview of the same process I went through in coming to this conclusion, see Sami Slkosuo’s post. The xmlrpclib module also supports the necessary meta data for WordPress posts. This is the bit for getting the content posted. Once I’ve extracted all of the content, I then take advantage of another common Python module, the xmlrpclib module. For multiple categories, I put each category on a subsequent indented line and the module knows they are all categories. In this example, I’m extracting the “title” and “category” fields but I could use date, author or just about anything I want. ![]() This includes footnotes, code blocks, tables and meta data. First, it supports Markdown Extras like the ones I use in MultiMarkdown. There are a couple very cool things with this module. In this instance, I’m using the most common Python Markdown module to process the text. I generally like to use as few odd-ball modules as possible to reduce maintenance overhead when upgrading or porting to another system. Python is generally my weapon of choice, when I have one. I’ve looked at several Python options for processing Markdown and posting to WordPress but I’ve never been happy with any of them. Post_id = (wpBlogid, wpUser, wpPass, data, status_published)Įxcept (RuntimeError, TypeError, NameError): # Make the error message as elaborate as you like. I don't want to hassle with parsing the file name.ĭata = # Only post if there is a title in the meta data. # extract the categories but keep them as a list # extract the title from the meta dictionary # Process with MD Extras and meta data support #Connection details for the WordPress xmlrpc connection Here’s the full script (you will need to provide your own WordPress connection credentials): Well, it’s a Python script run by Hazel’s embedded shell script action. txt file appears that has never been processed, Hazel runs it through a Shell script. The second Hazel rule does all of the work. This is critical and I’ll explain more later. Importantly, the Hazel rule will not overwrite a file if it already exists in the destination folder. The first rule looks for a file in my Simplenote folder to get the OpenMeta tag of “post” and makes a copy of the file to another folder. NVAlt supports Simplenote tags through OpenMeta extended attributes. He has a very good introduction to Hazel. For some context, take a look at Eddie’s post on Practically Efficient. Hazel watches items in a folder and performs actions based on a defined condition. Hazel is the next level of folder actions. I’ve come up with a solution that lets me write in MultiMarkdown on Simplenote or Dropbox and automatically post the article when it is tagged with “post”. I have Brett’s MD Quicktags plugin installed, but it seemed like I could streamline the process a bit. However, if I’m away from home, I must post via the web on Windows or iOS. I have a Keyboard Maestro macro that will post the html on the clipboard directly to Macdrifter. When I’m done with a post, I’ll preview it in Marked and copy the html. If it’s a long post then I’ll work in BBEdit but the document still resides in my Simplenote/NVAlt/Dropbox folder 1. Most of my posts are started in Simplenote. ![]() I’ve been tinkering with a simplified mechanism for posting to this site. This is for all of you Markdown and plain text nerds out there. ![]() Edit: See this updated post for enhancements ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |