Friday, November 13, 2015

blurl: Blogger, now with a command line option

I've finished another round of blurl development, adding support for creating, updating and deleting posts. That means that you can now manage your Blogger Blog from any ssh connection. You're welcome to grab the source code from github and play with it.

Along with being able to edit and post content on your blog from anywhere, you've also got the ability to automate publishing tasks. Here's a few examples to get the creative juices going. Like any Unix tool, you're only limited by your imagination.

Generate automated content. Throw this one-liner in cron, and you can start the day off with a quippy blog entry.

 (echo "<p>" ; fortune | tr '\n' '@' | sed 's/@/<br>/g' ; echo "</p>") | \
   blurl -a new -t "Words of Wisdom" -l 'advice,blurl'

Have your server blog its own status.. Again, drop this code into cron and your server can blog about itself.

echo -e "<h1>Memory</h1>\n<pre>`free -m`</pre>\n<h1>CPU</h1>\n<pre>`cat /proc/cpuinfo`</pre>;<h1>Disk</h1><pre>`df -h`</pre>" | \
   blurl -a new -t "`date +%B` Server Report" -l "server,blurl"

Bulk Publishing of Content. Here's an example that publishes 20 image files from a given directory, but it could just as easily published 200.

puburl `ls | grep .jpg | tail -30 | head -20` | \
  while read url ; \
    do echo "<a href='$url'><img src='$url' width='100' style='float: left; margin: 0 5px 5px 0px'/></a>" ; \
  done | \
    blurl -a new -t "Hiking Photos" -l  "blurl,photos"

Grab content from another site and publish it as your own. Now there's an idea that can get you into a heap of trouble quickly. Don't evil (or stupid).

curl -s '' | grep 'title="Today' | sed -e 's/^.*title="//' -e 's/".*//' | blurl -a new  -t "Weather Report" -l 'weather,blurl'

Publish the outcome of a software build. Keep the team up to date by having everyone subscribe to the blog being published to.

(echo "<pre>" ;  make;echo "</pre>" ) | \
   blurl -a new -t "sitecopy Build Status" -l "software,blurl"

Practice Append Only writing. Think Hemingway Mode but on the command line. Great for your next novel, or for just keeping a server transcript going with ease.

 # Set up the blank post
 echo "" | blurl -a new -t "My Novel" -l "novel,work-in-progress,blurl"
 blurl -a list | head -1
 export NOVEL_ID=6149764004006809175 

 # Now 'write'
 (blurl -a get -i $NOVEL_ID ; echo "Sophie was happy. But then again, Sophie was a ") | \
    blurl -a update -i $NOVEL_ID -t "My Novel"

Delete posts in bulk. Yeah, good luck with removing all trace of content from the web. But at least you can keep your blog tidy with little effort.

  blurl -a list|grep 'Quote of the Day' | cut -d : -f 1 | \
    while read id ; \
      do blurl -a delete -i $id ; \
    done ;

Happy Blogging!

No comments:

Post a Comment