Blogmarks

Clagnut posts have been getting longer and less frequent of late, which means a bunch of sites are going noticed but unreported. So I figured it was time to emulate the trend of a rolling list of noteworthy links. I took my lead from Simon Willison’s blogmarks, reverse engineering his solution and even stealing the name (which Simon himself borrowed from elsewhere).

Like Simon I use a bookmarklet to capture blogmark URL, blogmark title, via URL (based on referrer) and a server-side script to pull out the title of the referrer. I also categorise the blogmarks using the same scheme as my blog posts – hopefully this will help find forgotten blogmarks in the future. Since people are asking, this is the bookmarklet:

javascript:var url = 'editblogmark.php?link_url='
+ document.location + '&link_title=' + document.title +
'&via_url=' + document.referrer; var w = window.open(url,
'blogmark', 'width=600, height=360, resizable=1,
scrolling=auto'); w.focus()

It pops up a window into my homebrewed CMS and passes through the current page URL, title and referrer URL – you should be able to hook these into your own blogging software easily enough.

I then use this PHP script to find the title of the referrer:

if ($open=@fopen("$via_url","r")) {
  while(!feof($open)) {
    $line=@fgets($open, 1024);
    $string = $line;
    while(eregi('<title>([^<]*)</title>(.*)',$string,$regs)) {
      $string = $regs[2];
      break 2;
    }
  }
  $via_title = $regs[1];
} else {
  $via_title = "- could not open referrer page -";
}

Hope that’s of some use.