X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=general%2Fautolink;fp=general%2Fautolink;h=88ea1443cb18149c7d4cfc1ea35b3e5a96e542cd;hb=bdbd50ac8c30082886b3f29e88bfdeb8f088dee6;hp=0000000000000000000000000000000000000000;hpb=eeb750d0481d0cb8e27a7ccef3d39254306e7ce4;p=matthijs%2Fupstream%2Fblosxom-plugins.git diff --git a/general/autolink b/general/autolink new file mode 100644 index 0000000..88ea144 --- /dev/null +++ b/general/autolink @@ -0,0 +1,72 @@ +# Bloxsom Plugin:AutoLink +# Author: Fletcher T. Penney +# Version: 0.3 +# modelled after dictionary by Gregory Bair + +package autolink; + +# --- Configurable variables ---- + +# Where is the definition page +$link_file = "$blosxom::datadir/autolinks"; + + +# ------------------------------- + +$ignore = 0; + +sub start { + open (LINKS, $link_file); + @linkslist = ; + close LINKS; + 1; +} + +sub story { + my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; + + if ($$story_ref =~ m//gi || $$body_ref =~ m//gi) { + $ignore = 1; + } + + if ($ignore == 0) { + foreach $i (@linkslist) { + if ($i =~ /(.*?)=(.*)/) { + $word = $1; + $link = $2; + +# By default, autolinks now changes only the first occurence of a given term +# If you want to change all occurences, +# change the end of the following line to '\/a>/ig' + $$body_ref =~ s/(?<=\s)($word)(?=([\s\,\!\;]|\.\s|\:\s|[\(\)]\s))/$1<\/a>/i; + } + } + } + 1; +} + +1; + + +__END__ + +=head1 NAME + +Blosxom Plug-in: autolink + +=head1 DESCRIPTION + +Allows you to create a list of keywords that are automatically converted to a url whenever they are used in a story. You can insert "" in a story to prevent any changes + +You can set your own location for the autolinks data file, but by default it lives in your data directory. + +=head1 AUTHOR + +Fletcher T. Penney - http://fletcher.freeshell.org + + +=head1 LICENSE + +This source is submitted to the public domain. Feel free to use and modify it. If you like, a comment in your modified source attributing credit to myself and Gregory Bair for his original work would be appreciated. + +THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY WARRANTY OF ANY KIND. USE AT YOUR OWN RISK!