{"id":62,"date":"2010-01-14T02:35:00","date_gmt":"2010-01-14T02:35:00","guid":{"rendered":"http:\/\/www.dresan.com\/blog\/?p=62"},"modified":"2010-01-14T02:35:00","modified_gmt":"2010-01-14T02:35:00","slug":"making-blogging-easier-part-i","status":"publish","type":"post","link":"https:\/\/dresan.com\/blog\/2010\/01\/14\/making-blogging-easier-part-i\/","title":{"rendered":"Making Blogging Easier, Part I"},"content":{"rendered":"<p><a href=\"http:\/\/www.dresan.com\/images\/chihuly1.jpg\"><img decoding=\"async\" border=\"0\" width=\"600\" alt=\"chihuly art at palo alto medical foundation\" src=\"http:\/\/www.dresan.com\/images\/chihuly1.jpg\" \/><\/a><\/p>\n<p>So I want to blog more, ideally approaching one a day.\u00a0 If I was just tossing up blog entries for filler, like I sometimes do, that wouldn&#8217;t be a problem; however, I&#8217;d like to put up more <em>substantive<\/em> articles.\u00a0 But I find that putting up more substantive articles takes a lot of time &#8211; so keep up the pace I need to improve my process.<\/p>\n<p>I already have trained myself to use\u00a0<a href=\"http:\/\/www.blogger.com\/\">Blogger<\/a> more efficiently, use tools like <a href=\"http:\/\/www.qumana.com\/\">Qumana<\/a> to make it easier to access Blogger while offline, and am experimenting with <a href=\"http:\/\/code.google.com\/p\/androblogger\/\">AndroBlogger<\/a> in an attempt to make it easy to post while, well, anywhere I&#8217;ve got my <a href=\"http:\/\/www.google.com\/phone\/static\/en_US-nexusone_tech_specs.html\">Nexus One<\/a>.\u00a0 But there are still barriers to putting up entries.<\/p>\n<p>One barrier is my process.\u00a0 Note the last paragraph?\u00a0 It has four links.\u00a0 I like to put in links to topics I reference, so a certain amount of time is taken up finding appropriate web pages and linking them in.\u00a0 There isn&#8217;t much I can do about this except not go down the rabbit hole &#8211; ideally, I&#8217;d like to post a short paragraph about each link, but that&#8217;s too much detail.<\/p>\n<p>Another barrier are my goals.\u00a0 One of my friends, <a href=\"http:\/\/www.jimdavies.org\/\">Jim Davies<\/a>, thinks that blog posts should have pictures &#8211; and I agree, though I can&#8217;t immediately find the blog post in which he said it &#8211; perhaps that means we discussed it aloud.\u00a0 So ANYWAY, there was another chunk of time wasted trying to find a link.\u00a0 Where was I?\u00a0 Ah.\u00a0 The barriers of my goals.<\/p>\n<p>If I want to blog an article with a picture, the picture needs to be on the web.\u00a0 But I try to avoid linked images for copyright\u00a0 reasons (and to prevent brittleness in case the target takes it down; for embedded Youtubes, which, well, there isn&#8217;t a good substitute for yet).\u00a0 So I need to upload the image to MY site, a chore I currently do with the <a href=\"http:\/\/cyberduck.ch\/\">Cyberduck<\/a> ftp client.<\/p>\n<p>And here the constraints get harder: in precisely the same way I don&#8217;t let iTunes tell me where to put songs, I choose not to use Blogger&#8217;s interface because I have scheme for posting images which predates Blogger and which I will continue to use after Blogger is gone: <em>http:\/\/www.dresan.com\/images\/imagename.jpg<\/em>, which is simple and easy to remember.<\/p>\n<p>What&#8217;s worse, my cameras take images at huge resolutions, so I need to shrink and resize the images to fit in the width that fits on my website.\u00a0\u00a0 For a variety of reasons, I go with 800&#215;600 or 600&#215;800, in a standard block of HTML which shrinks the image, adds a link to the source of the image, and ads some alt text.<\/p>\n<p>So now I&#8217;ve put on myself a huge set of constraints which makes the simple task of putting up images on my website a chore &#8211; get the picture, resize it, start Cyberduck, upload it, write the two lines of HTML gloop necessary to display it, and then and only then see the preview so I can see I made a mistake.\u00a0 There has to be a better way.<\/p>\n<p><a href=\"http:\/\/www.dresan.com\/images\/chihuly2.jpg\"><img decoding=\"async\" border=\"0\" width=\"600\" alt=\"chihuly art at palo alto medical foundation\" src=\"http:\/\/www.dresan.com\/images\/chihuly2.jpg\" \/><\/a><\/p>\n<p>Enter <a href=\"http:\/\/tldp.org\/LDP\/abs\/html\/\">UNIX shell scripting<\/a>, <a href=\"http:\/\/www.python.org\/\">Python<\/a> and the <a href=\"http:\/\/www.imagemagick.org\/script\/index.php\">ImageMagick<\/a> toolkit.<\/p>\n<p>The first thing that I did to make my life easier was to auto-generate the stanza of text that displays the image.\u00a0 I mean, it&#8217;s the same thing each time &#8211; an anchor tag pointing to the image, with alt text, then the img tag itself, with the same alt text, sizing and border information, like this:<\/p>\n<blockquote>\n<pre><a href=\"http:\/\/www.dresan.com\/images\/image.jpg\"> <br \/> <img border=\"0\" width=\"600\" alt=\"some alt text\" \/><br \/>  src=\"http:\/\/www.dresan.com\/images\/image.jpg\" \/><\/a><br \/><\/pre>\n<\/blockquote>\n<p>So why write ALL of that every time?  Why not just write the changes and let the computer do it for you?  SO I wrote a piece of code in Python which does just that, produces that text for me:<\/p>\n<blockquote>\n<pre>#!\/usr\/bin\/python<br \/>import sys<br \/><br \/>TEXT= \"\"\"<br \/><a href=\"%s\"><img decoding=\"async\" border=\"0\" width=\"600\" alt=\"%s\" src=\"%s\" \/><\/a><br \/>\"\"\"<br \/>if len(sys.argv) < 3:<br \/>  print \"usage: %s image alt text\" % sys.argv[0]<br \/>else:<br \/>  image = \"http:\/\/www.dresan.com\/images\/%s\" % sys.argv[1]<br \/>  alt = ' '.join(sys.argv[2:])<br \/>  print TEXT % (image, alt, image, alt)<br \/><\/pre>\n<\/blockquote>\n<p>I&#8217;m not going to turn this into a Python tutorial, so, briefly, all this does is check to make sure I specify a filename and some alt text, stuffs it into a template, and prints it out so I can cut and paste. Here&#8217;s an example of that in operation, turning <b>chihuly.jpg<\/b> and &#8220;chihuly art at palo alto medical foundation&#8221; into a stanza of HTML (spaces added for readability):<\/p>\n<blockquote>\n<pre>centaur@Deliverance (Wed Jan 13, 22:48:25) [520] ~\/Development\/Workspace\/Webworks:<br \/>$ .\/imagelink.py chihuly.jpg chihuly art at palo alto medical foundation<br \/><br \/><a href=\"http:\/\/www.dresan.com\/images\/chihuly.jpg\"><br \/> <img border=\"0\" width=\"600\" \/><br \/>  alt=\"chihuly art at palo alto medical foundation\"<br \/>  src=\"http:\/\/www.dresan.com\/images\/chihuly.jpg\" \/><\/a><br \/><\/pre>\n<\/blockquote>\n<p>That saves me several minutes of typing each time. This is one of the great Programmer&#8217;s Virtues: laziness &#8211; making the computer do something you don&#8217;t want to do for yourself.\u00a0 The maybe thirty minutes I&#8217;ve spent tweaking that little script have paid off not just in the time that I saved typing, but in the extra blog posts that I&#8217;ve done because they were easier to do.<\/p>\n<p>In the next installment (or two, depending), I&#8217;ll write a tool to shrink the images to size with ImageMagick and upload them automatically with UNIX tools, and discuss some of the other tools and organization schemes I use which make it easier for me to collect the images and keep them organized &#8211; schemes that work even if you switch between operating systems.<\/p>\n<p>-the Centaur<\/p>\n<p>\u00a0<a href=\"http:\/\/www.dresan.com\/images\/chihuly3.jpg\"><img decoding=\"async\" border=\"0\" width=\"600\" alt=\"chihuly art at palo alto medical foundation\" src=\"http:\/\/www.dresan.com\/images\/chihuly3.jpg\" \/><\/a><\/p>\n<p>The images are <a href=\"http:\/\/en.wikipedia.org\/wiki\/Dale_Chihuly\">Chihuly<\/a> glass sculptures hanging in the <a href=\"http:\/\/www.pamf.org\/mv\/\">Mountain View campus of the Palo Alto Medical Foundation<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I want to blog more, ideally approaching one a day.\u00a0 If I was just tossing up blog entries for filler, like I sometimes do, that wouldn&#8217;t be a problem;&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3],"class_list":["post-62","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-webworks","ratio-2-1","entry"],"_links":{"self":[{"href":"https:\/\/dresan.com\/blog\/wp-json\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dresan.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dresan.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dresan.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dresan.com\/blog\/wp-json\/wp\/v2\/comments?post=62"}],"version-history":[{"count":0,"href":"https:\/\/dresan.com\/blog\/wp-json\/wp\/v2\/posts\/62\/revisions"}],"wp:attachment":[{"href":"https:\/\/dresan.com\/blog\/wp-json\/wp\/v2\/media?parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dresan.com\/blog\/wp-json\/wp\/v2\/categories?post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dresan.com\/blog\/wp-json\/wp\/v2\/tags?post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}