# Blosxom Plugin: bookmarklet # Author(s): Tatsuhiko Miyagawa # Changes: # 0.03 Mon Sep 22 00:39:14 JST 2003 # Added trackback discovery ($ping_url and $trackback_discovery) # 0.02 Wed Aug 20 13:35:06 JST 2003 # Fixed bug $script is empty without bookmarklet parameter # 0.01 Wed Aug 20 01:15:26 JST 2003 # first release package bookmarklet; use strict; use CGI qw(:standard); use vars qw($script $url $quote $title $trackback_discovery $ping_url); # do trackback discovery? # trackback ping URLs found will be in $ping_url $trackback_discovery = 1; sub start { $script = < 0){d=document;t=d.selection?d.selection.createRange().text:d.getSelection();void(window.open('$blosxom::url'+path+'.wikieditish?bookmarklet=1&title='+escape(d.title)+'&url='+escape(d.location.href)+'"e='+escape(t),'_blank',''))}; SCRIPT ; return unless $blosxom::flavour eq 'wikieditish' && param('bookmarklet'); while () { last if /^__END__/; my($flavour, $comp, $text) = split ' ', $_, 3; $text =~ s/\\n/\n/g; $blosxom::template{$flavour}{$comp} = $text; } return 1; } sub foot { my($pkg, $current_dir, $foot_ref) = @_; $url = escape(param('url')); $quote = escape(param('quote')); $title = escape(param('title')); my $template = $blosxom::template->('', 'bookmarklet', $blosxom::flavour); $wikieditish::body = $blosxom::interpolate->($template); $ping_url = find_ping_url($url) if $trackback_discovery; } sub escape { local $_ = shift; my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); my $escape_re = join '|' => keys %escape; s/($escape_re)/$escape{$1}/g; $_; } sub find_ping_url { my $url = shift; warn "finding trackback ping URL from $url"; require LWP::Simple; my $html = LWP::Simple::get($url); $url =~ s/#.*$//; while ($html =~ m!()!msg) { my $rdf = $1; my ($id) = ($rdf =~ m!dc:identifier="([^\"]+)"!); next if $id ne $url; my ($tb) = ($rdf =~ m!trackback:ping="([^\"]+)"!); return $tb if defined $tb; } return undef; } 1; __DATA__ wikieditish bookmarklet $bookmarklet::title\n
$bookmarklet::quote
\n __END__ =head1 NAME Blosxom Plug-in: bookmarklet =head1 SYNOPSIS Purpose: Adds your web browser to help you "blog" about any site you find on the web. As you are visiting different web sites, when you access the "Bookmarket", it automatically opens a new entry with wikieditish flavour and inserts into the editing field a hypertext link for the site you are viewing. This plugin is a MT's bookmarklet counterpart in blosxom. =head1 REQUIREMENT This plugin requires wikieditish plugin installed. =head1 USAGE Add following chunk to your foot.wikieditish flavour: POST to $blosxom::blog_title (Bookmarklet) C<$bookmarklet::script> is a javascript chunk. Browser may warn you about script security, which you can ignore. Then surf around the web. When you find something interesting, drag the text and choose 'POST to [Your blogname]' from the bookmarks. You'll first be prompted about new entry's path. Filled-in template is defined as bookmarklet.wikieditish in bookmarklet plugin itself. Surely you can change as you like in your flavours. =head1 TRACKBACK AUTO DISCOVERY If plugin variable C<$trackback_discovery> is on (it's on by default), this plugin tries to find trackback ping URL from remote html. If found, URI is set to C<$bookmarklet::ping_url>. You can use this varibale in combination with trackback sending plugins like C like this: meta-tb_ping: $bookmarklet::ping_url =head1 AUTHOR Tatsuhiko Miyagawa , http://shibuya.pm.org/ =head1 BUGS Address bug reports and comments to the Blosxom mailing list [http://www.yahoogroups.com/group/blosxom]. =head1 LICENSE Copyright 2003, Tatsuhiko Miyagawa This program is licensed under the GPL or Perl Artistic License. =cut