make comments plugin observe frag ID

20 Oct

We’re doing a new ideas hackathon today in the osmoplex. I’ve been
working @buddenisms on the profile. Normally tiddlyweb instances just
have users, but in this app, we have a “profiles” bag with info about
the users.

As well as votes and ideas submitted, we’re showing comments the user
has made. This works fine simply by searching for all tiddlers in the
comment bag with “modifier” field set to the user whose profile we’re
showing. But I wanted to link to the idea they commented on, not the
comment itself which has no real UI. Easy enough – link to
/ideas/{{comment.topic}}. But I want it to jump down to the actual

Normally, this would be a frag ID, so
/ideas/{{comment.topic}}#{{comment.title}}. I thought that would work,
since the comments do include permalinks. But it didn’t, because the
comments are loaded dynamically, so they’re not present when the page
loads. So I modded comments.js to run the following on startup:

plugin.jumpToFragmentID = function(context) {
var hash = document.location.hash;
if (hash.length document.location.hash = “#_”; // dummy
setTimeout(function() { document.location.hash = hash; }, 100);

(While I remember, the other change is to link from the comment to the
profile. Since we’re not using openID, but a profile inside the
system, it required a hack of the part that generates the user’s URL.
I’ll need to make that an option to the comments plugin in the


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: