Weekend project: How to show under each static blog engine post the tweets that mentioned it.
bucket3 is my static-blog-generation engine, but it's also my little software project that helps me relax and learn new things.
After some time I hadn't added any (important) new features, this weekend I decided to add something I've been thinking about for years: I wanted my blog to show under each post tweets that mentioned it.
There are some easy ways to do it, probably by using Disqus or something like it. But I want my blog to be
I ended up using TwitterSearch, a pytrhon library "to easily iterate tweets found by the Twitter Search API" to add a new command to bucket3, invoked using
When I run
bucket3 mentions on my computer (where I write and render this blog, and then upload it to S3), bucket3 queries twitter for any reference to "blog.vrypan.net". The script checks each reference to see if there is a link to a specific blog post, and if so saves the tweet in a local file. It also saves the twitter user avatar, because I didn't want to reference the one hosted by twitter in my pages. Then it marks the corresponding post source (usually a markdown file) as modified.
So, next time I run
bucket3 update all modified posts are re-rendered (this has nothing to do with the post pub date) to include the referring tweets.
bucket3 mentionsin a cron job that runs every 30 minutes or so.
In a way, my static blog has a commenting engine too, now.