Singpolyma

Archive of "Hack"

Archive for the "Hack" Category

Trackback Inside Blogger

Posted on

It is reccomended that you use the new del.icio.us, pinging, AND trackback script. This one may still work, but I no longer actively support it.

Blogger has no native trackback capabilities. While trackback is a wonderful tool, it can sometimes just be too much of a pain for Blogger users. After all, you just went to the work of writing a wonderful post, who wants to bother making a hop over to Haloscan afterwards to send trackbacks to others? With the advent of the semi-automatic Backlinks we seem to be ever less inclined to make the extra hop.

Now, the extra hop can be a thing of the past. Install the Blogger Trackback Userscript and get trackback functionality directly from your Blogger dashboard! Every time you publish a post, the script harvests the title, permalink, and post excerpt (as well as blog title) and then displays a form on the ‘post complete’ page for trackbacks. Enter the trackback URLs one at a time and hit enter. The trackbacks will be completed AJAXially.

Much thanks to Johan’s Blogger del.icio.us helper script which facilitated much of the code for this script.

Possible Future Features

  1. Support for autodiscovery trackback RDF so that one can enter simply the post URL for a trackback and not have to use the full trackback URL
  2. Optionally try auto-trackbacking to all posts linked to from the post

Comment Photos and Highlighting

Posted on

PurpleMoggy has created a set of instructions for using this on Blogger BETA. I have updated my hack to support his new features and fix the bugs he found. There is also now a new ‘no image’ image.

Awhile back I wrote a post detailing my hack for adding profile photos to comments. Unfortunately that post was rather technical in its explanation. This post attempts to deal with adding the hack to your blog in a more user-friendly fashion and also with using the hack to highlight blog-contributor comments.

Step 1 – The first thing you need to do is find the comment section in your blog template. Edit your template and scroll down until you find the <BlogItemComments> tag. The code inside should look something like this:

<div class=”comment-poster” id=”c<$BlogCommentNumber$>”>
<a name=”c<$BlogCommentNumber$>”></a>
<$BlogCommentAuthor$> said…
</div>

<div class=”comment-body”>
<div class=”innerCmntBody”><$BlogCommentBody$></div>
</div>

<div class=”comment-timestamp”>
<a href=”#c<$BlogCommentNumber$>” title=”comment permalink”>4/26/2006 07:49:51 PM</a>
</div>

Step 2 – If you plan to use comment highlighting (so that the comments made by blog authors look different from those of users) this must be wrapped in another tag so that all of the code for each comment is in one tag. Like so:

<div class=”commentelem”>

<div class=”comment-poster” id=”c<$BlogCommentNumber$>”>
<a name=”c<$BlogCommentNumber$>”></a>
<$BlogCommentAuthor$> said…
</div>

<div class=”comment-body”>
<div class=”innerCmntBody”><$BlogCommentBody$></div>
</div>

<div class=”comment-timestamp”>
<a href=”#c<$BlogCommentNumber$>” title=”comment permalink”>4/26/2006 07:49:51 PM</a>
</div>

</div>

Some blog templates will already have a tag around their comments, as will those using the ‘standard’ comment markup. If you have one of those templates just write down the class of the wrapping tag or add one (the underlined section above).

Step 3 – Next we need the class of the element where we can look for the link to the author. In the example code above this would be comment-poster. When in doubt use the class of the overall wrapping tag. Once you have it, write it down. Count the number of <a> tags there are before the <$BlogCommentAuthor$> tag and write this number down (in the above example it is 1).

Step 4 – The only thing left to do in this part of the code is to insert the element where the profile photo will go. Add this code right before the <$BlogCommentBody$> tag: <div class=”commentphoto”></div>

Step 5 – Now go to the <head> section of your blog and add the following code:

<script type=”text/javascript” src=”http://jscripts.ning.com/get.php?xn_auth=no&amp;id=830605;
<script type=”text/javascript”>
//<![CDATA[
function thisblog_showCommentPhotos() {showCommentPhotos(‘commentphoto’,’class of author wrapper‘,# of a tags,’main wrapper class‘,'<$BlogURL$>’,’highlighted text colour‘,’highlighted text background‘;}
addLoadEvent(thisblog_showCommentPhotos);});
//]]>
</script>

Where class of author wrapper is the class you wrote down in step 3, the # of a tags is the number you wrote down in step 3, and the main wrapper class is the class you wrote down in step 2. If you are not going to use comment highlighting the last for parameters can be left off (from main wrapper class to highlighted tex background) otherwise you have to fill in the color you with the text and background of highlighted comments to be in their appropriate spots above.

Step 6 – Save and Republish!

Profile Photos With Comments

Posted on

Blogger does not provide a template tag for displaying the profile pictures of commentors in your blog template. Johan Sundström had created a way around this using an IFrame, but I found that solution to be somewhat buggy, even on his own blog. I have modified some of his code and added some of my own to create what I feel is a cleaner hack. I have bundled the majority of the JavaScript into a JScripts entry and it also uses a script I wrote to scrape Blogger profiles to JSON(P) [example]. The code to include the hack into your template is surprisingly simple:

<script type="text/javascript" src="http://jscripts.ning.com/get.php?xn_auth=no&amp;id=830605 </script>
<script type="text/javascript">
//<![CDATA[
addLoadEvent(function(){showCommentPhotos(‘class of elements to put photos in‘,’class of elements where links to authors can be found‘,number of <a> tags before the link to the author (0 if none));});
//]]>
</script>

You will need to add a <div> or other tag (with the class you pass in first) to the comment section, and style it so that the images show up the way you want. The second class you pass is the element containing the link to the comment author, you must add a class to this element if one does not exist. The third parameter is the number of <a> elements in this element before the link to the author. The script runs after page load and should thus have no adverse affects on initial load times.

Inline Comments Form Updated

Posted on

I have updated my inline comments form hack to be compatible with coComment. Note that if you have the comments forms visible on your main and archive pages like I do there will still be a problem there, but on item pages the values will be filled it and the coComment detector automatically invoked.

FreshTags-Singpolyma

Posted on

This post has been ‘deprecated’. Please see FreshTags-Singpolyma 2

I have for some time had my own version of the FreshTags system. In the past, all upgrades to this version have been seamless to the user, but this time the changes were too radical to allow that to work. I have rewritten the entire hack based off of the FreshTags v0.5 code. The major changes from FreshTags 0.5 are:

  • Hidden post page is used for displaying tags, instead of reloading the current page and displaying in the sidebar (the primary purpose of the original modifications)
  • Completely asynchronous data load — FreshTags no longer loads before the page content, but rather loads afterwards, resulting in a faster page load time
  • If no tag is selected one can be automatically pulled from relTag data on the page
  • Full support for peek-a-boo headlines in blogrolls

Please Note : If you are upgrading from my previous hack, you will need to remove all of its code from your template before upgrading. You will also have to edit the Tags post.

Basic Installation Instructions

  1. Create a new post on the blog you would like to implement this hack on with the title ‘Tags’ and click the ‘Edit Html’ tab for the post body, pasting the exact code ‘<div id=”freshtags_postpage”><i>Loading…</i></div>’ into the post body. Turn comments off for the post and set the post date to January 1, 2000. The time doesn’t matter. Post this post. (If you are upgrading from the previous version, just edit the post to contain the new code.)
  2. Edit the template for your blog and insert this code into the <head> section:
    <script type=”text/javascript”>
    //<![CDATA[
    var del_user = “delicious username“;
    var anchor = “anchor tag“;
    var defs = “”;
    var maxposts = 10;
    var freshtags_tags_id = “freshtags_tags”;
    var freshtags_posts_id = “freshtags_posts”;
    var freshtags_postpage_id = “freshtags_postpage”;
    //]]>
    </script>
    <script type=”text/javascript” src=”http://jscripts.ning.com/get.php?xn_auth=no&amp;id=818185

    Where ‘delicious username’ is the del.icio.us username you store your blog data in and ‘anchor tag’ is the anchor tag you use (if you use one). If you don’t use an anchor tag, just replace the words ‘anchor tag’ with nothing.

  3. Insert this code where you would like the tags drop-down to go:
    <div id=”freshtags_tags”><i>Loading…</i></div>
    <div id=”freshtags_posts”></div>
  4. Save your template and republish your blog

Customisation Options

  • no_autocapture — setting this variable to true will keep the script from attempting to grab relTag data from the page. For example, to keep a Blogger blog using this script from grabbing relTag data when on the main page use <MainPage><script type=”text/javascript”>var no_autocapture = true;</script></MainPage>
  • defs — setting this variable sets what tag(s) will be selected be default if the user has not selected any. This will do nothing if no_autocapture is not set to true unless the autocapture failes.
  • maxposts — the maximum number of posts to display in the sidebar
  • freshtags_tags_id — the ID of the block to put the tags dropdown in
  • freshtags_posts_id — the ID of the block to put the posts list
  • freshtags_postpage_id — the ID of the block in the Tags post
  • freshtags_tag_format — the format for the tags list (default is ‘drop-add’). For example, to use asynchronous post loading add this code to your template: <script type=”text/javascript”>var freshtags_tag_format = “drop-add-async”;</script>

Peek-A-Boo Blogroll Headlines
To add peek-a-boo headlines to your blogrolls follow the following steps:

  1. Add this code to the <head> section of your blog to facilitate the actual show/hide:
    <script type=”text/javascript”>
    //<![CDATA[
    function toggleitem(postid,linkid,newtxt,displaytype) {
    if(!displaytype) {displaytype = ‘block’;}
    var whichpost = document.getElementById(postid);
    if (whichpost.style.display != “none”) {
    whichpost.style.display = “none”;
    } else {
    whichpost.style.display = displaytype;
    }
    if(linkid) {
    var lnk = document.getElementById(linkid);
    lnk.href = “javascript:toggleitem(‘”+postid+”‘,'”+linkid+”‘,'”+lnk.innerHTML+”‘);”;
    lnk.innerHTML = newtxt;
    }
    }
    //]]>
    </script>
  2. Add this code just after the blogroll link you want to add peek-a-boo headlines for (it’s invisible defaultly, just the container for the headlines) ‘<div id=”blognameheadlines” style=”display:none;”><i>Loading…</i></div>
  3. If this blog stores post data in del.icio.us (they don’t have to use FreshTags necessarily) add this code just before the blogroll link (it’s the +/- link for showing/hiding the headlines):

    <a id=”blognamelink” href=”javascript:toggleitem(‘blognameheadlines’,’blognamelink’,’-‘); load_otherblog_titles(‘del.icio.us’,’other blog’s del.icio.us account username‘,’other blog’s anchor tag (if they use one)‘,’URL to other blog’s feed (optional)‘,’blognameheadlines’);”>+</a>

    Otherwise add this code to use just their feed:

    <a id=”blognamelink” href=”javascript:toggleitem(‘blognameheadlines’,’blognamelink’,’-‘); load_otherblog_titles(‘feed’,”,”,’URL to other blog’s feed‘,’blognameheadlines’);”>+</a>