I have been doing some work on my version of the FreshTags concept. The first major addition is the ability to pull in other FreshTags users’ data for use in the sidebar. If you look at my links sidebar you’ll see a ‘+’ to the left of some items. Only two of these use FreshTags, Freshblog and Ecmanaut. If you click the ‘+’ next to either of these when there is no query tag you will be presented with a list of the newest posts from those blogs. If there is a tag selected, however, you will be presented with a list of posts on those blogs matching that tag, unless they have none in which case the list of newest posts is again presented. The template code to do this (without the show/hide magic) is:
<script type=”text/javascript”>dynamic_delicious_load(‘DELICIOUS USER‘,’ANCHOR TAG‘,function(){write_tagged_posts(false,false,’FEED URL‘);});</script>
The three parameters passed to write_tagged_posts are:
- extendedyes — TRUE to display the contents of the extended field, otherwise FALSE
- hideonnull — TRUE to have blank output if there are no post matches, otherwise FALSE
- feedurl — The URL to the feed for this item, do not pass if you don’t know it or don’t want to display recent items on no match
- max — # limit of posts to display, not shown in example above
The second major addition is to the fetch_query_tag function. If no tag has been passed to the page, and it cannot find one in the referrer URL then it looks in the current page. It grabs the first rel=tag item and uses the contents of that as query_tag. Thus if a tag cannot be found any other way it finds related posts to the current one. The only minor problem with this addition is that including the JavaScript in the header means fetch_query_tag runs before the page has fully loaded, so it will usually not find anything. I solved this by moving the block that includes the main Delicious.posts and the tagspostpage.js to my sidebar, which is after my posts in my code. If your sidebar comes before your posts you’re stuck, because you need it loaded before the sidebar for the list_side_tags function to work. If anyone knows of a way around this I would appreciate knowing.
I was unable to actually hook this to onload (per Johan’s comment) because the data must be loaded before list_side_tags or write_tagged_posts can be run. I found a solution in using the callbacks again, and this time list_side_tags will load tags if they are unloaded when called and same for posts for write_tagged_posts. return_tagged_posts can therefore not be called until one of these others (or you call load_data(‘posts’) yourself), however since the main use of return_tagged_posts is at the end of the code, after write_tagged_posts, for use on the inline tags page, this should not be a problem. So autocapture should now work without modifying your template code to move the javascript stuff from the <haed> section.
If you place code similar to:
<MainPage><script type=”text/javascript”>var no_autocapture = true;</script></MainPage>
in your <head> section it will stop the tag autocapture on your main page (per Richard’s comment)
13 Responses
Johan Sundström •
The typical way around it is hooking up with the onload event, waiting for the page to be fully realized before you scoot up the bits from it you want.
Singpolyma •
Ah, right, thanks… don’t know why I didn’t see that before. That should be easy enough 🙂
Greg •
Hi Singpolyma,
Very impressed with your mods here … especially forcing the script to pick up the current tags with virtually no clues. Grabbing it from the rel=”tag” links – I didn’t think of looking in the most obvious place! Maybe tags are like car keys – always in the last place you look.
Also, the peek over the fence at neighbouring blogs is neat. Giving readers a taste (without losing them off your page) is a great way to enrich your blog without alienating your readers with mystery links.
Perhaps you’d like to join me in my campaign for delicious to support grouping-by-user?
http://del.icio.us/singpolyma+thetan/blogger
(Sure, we could cobble something together that had the same effect, but that’s hardly the point.)
Singpolyma •
Hey, thanks for the feedback 🙂
That user-group thing is a great idea, once you get your head around it 😀
Richard •
Like Greg, I have to say that is two very cool ideas!
However, I usually begin my post tags list with a generic ‘philosophy’ tag, and I’m not sure I’d want all my philosophy posts automatically listed in the sidebar (it would be too big!). Is there any way to limit the number listed? (10 would be a nice number, for example.) I figure readers can always click the double-arrow link to del.icio.us if they want the full list.
The same goes for the expandable RSS feeds in your blogroll. It’s a neat idea, but needs limiting. (It’s a bit overwhelming to click the ‘+’ by Freshblog and have about 50 links appear!)
It would also be cool if I could enable the tag auto-capture for item pages only (in particular, not the main page).
Greg •
Hey – you may have noticed that we launched FreshTags v0.5 on Freshblog just now. The code has been upgraded to allow for more features.
Subsequent work will focus on getting asynchronous loading of the JSON objects, to improve responsiveness and take delicious off the critical path for page rendering. Oh, and not require a page reload to refresh your tags/titles!
I’d be interested in your thoughts on the current implementation (good/bad) and extensions for future work.
Singpolyma •
Reply to Greg’s comment
Richard •
Major bug: the freshtags drop box no longer displays if there is not already a tag selected! (I noticed this when using your suggested ‘mainpage’ no-capture script. But it also happens when I click ‘reset’ here on your site.)
Singpolyma •
Oops! Sorry about that — fixed now 🙂
Richard •
Thanks for fixing that earlier thing.
Pity how del.icio.us seem to have disabled the functionality for them. (I assume that’s why your tags aren’t working anymore?) Do you know if this will be permanent?
Singpolyma •
Thanks for calling this to my attention! It seems that del.icio.us slightly altered the formatting on their JSON feeds during the switch, breaking some of the cleanup my proxy did… it’s fixed now 🙂
Richard •
(Are you sure? I tried refreshing the page and it still looks broken to me?)
Singpolyma •
Del.icio.us had another hiccup at that point, which was the problem. It seems to be working now, and it also now supports all the same tag-selection features of the new Freshtags 0.5 and loads selected tags into the blogger navbar 🙂