Singpolyma

Archive of "Hacks"

Archive for the "Hacks" Category

Blogger Recent Comments Source Released

Posted on

Older readers will remember my Blogger Recent Comments service that was hosted on Ning.  It has be obsolete for some time now (since Blogger now has provided their own comment feeds since v3) and has long since been shut down by Ning for being a horrible bandwidth hog.  I have thus decided to delete the app (since it’s just taking up space on my Ning account) and release the code under an MIT-style license on my devjavu repository.  Maybe someone will find it useful.

Now to go see if I can use Ning for my next project… Google App Engine not having a decent cron/fakecron is not at all useful… and my Python sucks.

Content in Footer for Single-Author Blogger Blogs

Posted on

Awhile ago I received this message from an unidentified user:

Title: photo for authors
Can you use javascript to show an author’s photo in the footer of a post? I’ve looked everywhere and only find it in the old blogger Any help would be awesome!

While a script based on my new comment author photos could be built to inject the image for the post author (multi-author blogs), I thought it might first be useful to provide basic information about hard-coding this.

  1. Go to the Template tab on your blog’s dashboard
  2. Select Edit HTML
  3. Check the Expand Widget Templates box
  4. Find the code block starting with <div class='post-footer'> or after <data:post.body/>
  5. Insert the content you want there
  6. Save!

FreshTags’ Static Widgets

Posted on

This enhancement to FreshTags in response to Amit, who has been persistently requesting the feature in comments and a ticket. FreshTags now has the ability to generate widgets (from any source) which are locked on to a particular tag(s). For example:

<!-- FreshTags0.5-Singpolyma2 -->
<script type="text/javascript">
if(typeof(WidgetData) != 'object') WidgetData = {};
if(typeof(WidgetData['freshtags']) != 'object') WidgetData['freshtags'] = {};
WidgetData['freshtags']['freshtags_static'] = {
"type":"posts",
"source":"source",
"format":"drop",
"defs":"tags",
"force_defs":true,
"username":"del.icio.us username",
"url":"blog url",
"join_char":"/",
"tag_url":"/search/label/%tags%",
"sort":"alpha",
"rows":100
};
</script>
<script src="http://jscripts.ning.com/get.php?xn_auth=no&id=818185" type="text/javascript"></script>
<div id="freshtags_static"></div>
<a href="http://ghill.customer.netspace.net.au/freshtags/" title="Categories by FreshTags"><img alt="FreshTags" src=" http://ghill.customer.netspace.net.au/freshtags/freshtags-btn.png"/></a>
<!-- /FreshTags0.5-Singpolyma2 -->

The above code must (for new Blogger users) be inserted into a new HTML/JavaScript sidebar widget. Source (in red) must be either del.icio.us, blogger, or mediawiki (use blogger for labels on posts in the new Blogger). Defs (in red) should be a +-separated list of tags to load into the widget (or just one tag). Username (in blue) must be replaced with your del.icio.us username (if source is del.icio.us) or the whole line must be removed. URL (in blue) must be replaced with the full URL to your Blogger blog (ie, http://you.blogspot.com/) if source is blogger or the whole line must be removed. Join_char (in blue) must be / if source is blogger and + otherwise.

The ID (in purple) is fine to leave if you are only going to insert this widget once. For the second, third, etc widgets you must change it to something like freshtags_static2. The higher reference (also in purple) to freshtags_static must also be changed. Second, third, etc widgets do not need the <script> tag that is in purple near the end.

If you have any questions, just ask!

New Comment Photo Hack (Blogger)

Posted on

By demand, I have added a maxheight option to this hack as well, it works the same way as maxwidth 🙂

Some people have really liked my comment photos and highlighting hack. Many have hated it. Especially since the move to the new Blogger, the hack is just unstable and difficult to implement or understand. Even my own implementation (before the move) was doing odd things.

So I decided that a complete rewrite was in order. The old scripts are still intact, but this new hack uses none of the old code. This hack does only comment author photos (highlighting is better handled other ways in the new Blogger).

This hack is 100% compatible with the newest version of my asynchronous peek-a-boo comments.

Without further ado, the instructions:

  1. Go to ‘Edit HTML’ under Template and check the ‘Expand Widget Templates’ box.
  2. Find the following code:

    <dl id='comments-block'>
    <b:loop values='data:post.comments' var='comment'>

    and insert the following code directly after it:

    <div style="clear:both">
    <dt style="float:left;margin-right:5px;clear:both;" expr:id='"commentphoto" + data:comment.id'></dt>
    <script type="text/javascript">if(typeof(commentPhotoIds) == 'undefined') var commentPhotoIds = []; commentPhotoIds.push({'id':'commentphoto<data:comment.id 'url':'<data:comment.authorUrl/>'});</script>
  3. If you go down a very small ways from where you were in the previous step you will see a </dl>. Directly before it insert the code: </div>
  4. Directly before the </body> code in your template add this code:

    <script type='text/javascript'>
    //<![CDATA[
    function commentPhotoDo() {
    var tag;
    for(var i in commentPhotoIds) {
    tag = document.createElement('script');
    tag.type = 'text/javascript';
    tag.src = 'http://scrape.singpolyma.net/avatar.php?maxwidth=70&url='+encodeURIComponent(commentPhotoIds[i].url)+'&id='+encodeURIComponent(commentPhotoIds[i].id)+'&defaultimage='+encodeURIComponent('http://img139.imageshack.us/img139/1011/defaultavatarad7.png');
    document.body.appendChild(tag);
    }//end for var i in commentPhotoIds
    }//end function commentPhotoDo
    commentPhotoDo();
    //]]>
    </script>
  5. Save your template

My fellow hackers will not like the way I did the second-to-last step. I should be using window.onload. I am not simply because in the tests I did on a certain much-hacked template, this worked and the other didn’t. I am not prepared to say why the other didn’t, only that it didn’t and that disturbed me. So for this hack I’m doing it like this. It works.

This hack causes direct hits to my singpolyma.net hosting server every time a page loads. If your blog gets a significant amount of viewers (>300 subscribers or thereabouts) I would ask that you contact me before installing this hack so that we can work out whether it will be a bandwidth issue or not. Thank you for understanding.

BloggerHacks Toolbar

Posted on

Yet another experiment in following the community.  I have used the toolbar-creation tools from Conduit to create a social toolbar for the Blogger hacks community.

The toolbar has links to all the major Blogger hackers (if I forgot you, I’m sorry, tell me and I’ll add your link!), a drop-down to the main sections of the hacks wiki, a built-in search of the wiki (the co-op one isn’t allowed… but I linked to it), a feed-reader that alerts your when a hacker posts something new, and an announce section for community-wide alerts.  There is also a chatroom, email notification, weather, and pop-up blocking option.  All components are optional.

One of the really cool things is that there is a version for both Firefox and Internet Explorer.  If I update the toolbar components on their site, everyone’s toolbar gets updated, without a reinstall.

So, check it out at the toolbar homepage.