Quantcast
Viewing latest article 9
Browse Latest Browse All 10

Writing Blog Posts from the Commandline

I ran across a program that will allow you to manage your wordpress posts and pages from the commandline. Enter blogpost. I’m not sure just how often I may need or want to write blog posts from the commandline but, it’s nice to have the option. I can really see it being useful for scripting. Also, this post is more or less me just playing around since this simple test didn’t really let me experience it much.

Blogpost uses AsciiDoc as it’s backend for the html formatting for the text that gets sent to WordPress. AsciiDoc has a specific markup syntax that I currently have no experience with but, cheat sheets such as this should be quite helpful. At least I’ve figured out how to emphasize and bold and even monospace as needed. The following image was even uploaded through blogpost.

Image may be NSFW.
Clik here to view.
jpope dot org logo

Pretty sweet, eh?

The following artist list was added via a script and piped to this post. This list is the top five artists that I’ve listened to in the past seven days.

The Walkmen,Bob Marley,Trent Reznor and Atticus Ross,Sigur Rós,Snow Patrol,

This list is from a script that I use to pull the artist names from my Last.fm account and post on my StatusNet instance, such as this one.

How about some system stats?

$ uname -a Linux jpope.org 3.0.36-2-lts #1 SMP PREEMPT Tue Jul 3 15:04:30 UTC 2012 x86_64 GNU/Linux

$ vnstat -w eth0 / weekly

                   rx      |     tx      |    total    |   avg. rate
---------------------------+-------------+-------------+---------------
 last 7 days     28.49 GiB |   27.80 GiB |   56.29 GiB |  782.36 kbit/s
   last week     25.43 GiB |   27.51 GiB |   52.94 GiB |  734.26 kbit/s
current week     20.70 GiB |   19.69 GiB |   40.39 GiB |  786.56 kbit/s
---------------------------+-------------+-------------+---------------
   estimated     29.22 GiB |   27.79 GiB |   57.02 GiB |

w00t!


Posting with blogpost

To post from blogpost, you first start with writing your post in a text file using the asciidoc format, such as this example. If you have images that will need to be uploaded with the post, be sure to put them in the same directory as the text file. To link to the image, you can use

image:filename.png[alt text]

for an inline image and

image::filename.png[alt text]

for an image block. (Note the single or double colon.) When the post is uploaded, blogpost will upload the image, note the resulting url for it and insert it properly as it formats the post in html.

Once you have your post wrote and formatted how you like, you can check the raw html formatting if you like with

blogpost dump filename.txt

and it will return the html in your terminal. To actually post the post,

blogpost post filename.txt

will upload any images and the formatted text and publish it. You can use the -u flag if you just want to save it as a draft. If you need to update an entry, you can run the same command and it’ll upload the update. Also, the -U flag will publish a draft. You can also control the published status by adding

:blogpost-status: unpublished

to the text file of your post, changing it to published as needed. There are a few other items that can be signified in this way, see the Attribute Parameters section.

For the most part, this is just a basic rundown. There seems to be quite a few options to this so, more exploration will be needed on my part. A couple of things that bug me though, you can’t specify tags for a blogpost although you can assign categories. Also, (and this may not be a blogpost issue) but, as I played around with this particular post, and uploaded quite a few drafts of it, the published date kept creeping back. I initially started this post on the 24th but it eventually had moved back to the 18th. Not sure why that was but, it’s something I’ll have to keep an eye on in the future.

To see the raw text version of this post, follow this link.

Anyway, I’m done blogging from the commandline for tonight. Image may be NSFW.
Clik here to view.
:-D

Image may be NSFW.
Clik here to view.
flattr this!


Viewing latest article 9
Browse Latest Browse All 10

Trending Articles