Reducing Authoring Time with Textpattern Bookmarklets ¬

2010-01-08

Posting around here has been sporadic, at best, lately. With little to no time to author full articles this time of year, I figured I’d better improve the efficiency of my quick linking to tidbits I’ve found elsewhere online. I’ve got a ‘hyper’ section in Textpattern (my CMS of choice) for just such a task, akin to and inspired by the Daring Fireball Linked List, but it’s actually more cumbersome to post to. I usually include a quote and the title from the target site, it’s URL, switch it to the ‘hyper’ section, add some tags and a little commentary. A bookmarklet that could pull in much of that data for me to just tweak and comment could drastically reduce the amount of tab switching and cutting & pasting required.

Fortunately, just such a bookmarklet exists. It pulls your selection into a new post body, sets the post title to the page title, and allows you to customize what section & category it gets posted in:

javascript:
var d=document,
w=window,
e=w.getSelection,
k=d.getSelection,
x=d.selection,
s=(e?e():(k)?k():(x?x.createRange().text:0)),
f='http://PathToYourTXPFolder/index.php',
l=d.location,
e=encodeURIComponent,
p='?bm=1&Section=SectionName&from_view=1&Category1=CategoryName&Title='+e(d.title)+'&Body='+e(s),
u=f+p;
a=function(){
  if(!w.open(u,'t','toolbar=0,resizable=0,status=1,width=800,height=800'))
    l.href=u;
}
;
if(/Firefox/.test(navigator.userAgent))
  setTimeout(a,0);
else
  a();
void(0)

However, I require the target URL in a custom field in order to automatically build the link to the target site. It was designed to do that, but no example was given. You merely need to insert the following (replacing ‘custom_1’ with the number of the appropriate custom field) after Category1 and before Title1:

custom_1='+e(l.href)+'&

But there’s one more thing I found necessary to tweak: the size of the pop-up window. It was a bit too narrow for my install, so I increased the width to ‘960’, but more importantly, I made it scrollable by adding scrollable=1 to the call to w.open().

So, with the my aforementioned modifications, you get something like this (still requiring replacement of PathToYourTXPFolder, SectionName, CategoryName, and custom_1 with your particulars, of course):

javascript:
var d=document,
w=window,
e=w.getSelection,
k=d.getSelection,
x=d.selection,
s=(e?e():(k)?k():(x?x.createRange().text:0)),
f='http://PathToYourTXPFolder/index.php',
l=d.location,
e=encodeURIComponent,
p='?bm=1&Section=SectionName&from_view=1&Category1=CategoryName&custom_1='+e(l.href)+'&Title='+e(d.title)+'&Body='+e(s),
u=f+p;
a=function(){
  if(!w.open(u,'t','toolbar=0,resizable=0,scrollable=1,status=1,width=960,height=800'))
    l.href=u;
}
;
if(/Firefox/.test(navigator.userAgent))
  setTimeout(a,0);
else
  a();
void(0)

What now? Run it through something like Bookmarklet Builder to name it and further minify it, then merely drag it to your bookmarks bar. I ended up whipping up two: one for use on this site and one for use on Slotted Pig.

1 You can obviously move it around elsewhere in the query if you’re careful with the quoting.

  1. So much work :)

    I use the delicious.com add-on for Firefox and import the RSS feed via Textpattern plug-in asv_tumblelog.

    If I want I add some meta content if not I just leave it ‘as is’.

    Using the Textpattern XML-RPC server:

    The new thingy on the web to use for that purpose is Posterous.com which also adds all the social media buzz for a subject.

    The old thingy on the web to use for that purpose is ScribeFire which is a full featured blog editor.

  2. This is brilliant! I have a Tumblog style blog and regularly post links, this will cut down the posting time hugely.

    I just created mine and posted a link back to here.

    Thank you.

  Textile help