1.16.2011

kenholic.com updates finally pushed to twitter (how to)

One thing that I've always wanted for my website was an automated way to publish titles and short links for my new articles onto twitter. I was looking at third party services like twitterfeed, but I discovered that I also wanted more control over the process.

After languishing over the idea for about 2 months, I had all but given up. However, I was talking to one of coworkers today, and he told me that Google had built that feature into Blogger. I was in denial ... it couldn't be that easy, so "no way" was my response. Turns out it was indeed implemented around 6 months ago in the summer of 2010 as Blogger Share Buttons. You click a button, it asks you to log into your twitter account if you aren't already, it summarizes the blog title and appends a short link url in a text box that you can edit, then hit 'Tweet'. Two clicks with the option to edit ... I was ecstatic. Long story short, my website templating is powered by Blogger (for some history on the infrastructure of my site, see building kenholic.com or my site notes), so it should be a piece of cake to get the share feature integrated into my site.

After 10 minutes worth of dabbling, I got it working! By default, the buttons are publicly viewable; this was quite an unexpected benefit because given any post, any visitor can share the article via their own twitter/facebook/buzz account. Unfortunately, the button graphics aren't easily customizable and they don't look very nice on my site. The things I sacrifice for style, o well; for the time being, I've made the share buttons admin viewable/usable only (kind of like the quick edit pencil; if you used blogger, you know what I'm talking about).

Anyways, I accomplished this feat by editing my blog template and adding the following 2 lines (in bold) into the shareButtons object:
<b:includable id='shareButtons' var='post'>
<span expr:class='&quot;item-control &quot; + data:post.adminClass'>
... shareButtons code ...
</span>
</b:includable>

Hiding access to the share buttons is fine I guess, because my original goal all along were quick and easy twitter pushes, and the posts can always just get retweeted from my twitter feed anyways. I just don't get enough direct traffic to justify it yet. I might change my mind soon and re-enable them on the expanded post pages (i.e. not my front page), but that'll take a little bit more tinkering on my part. For now, next up for this site is either setting up a database using App Engine or migrating all of the images on the site to the datastore.

3 comments: