Probably only usefull if you participate on Amazons partner programm. Which is a good idea for wiki funding. Especially if you already direct your ISBN links to them. ;-)
--TilmannHolst, 2004-05-29
*** wiki.pl 2004-05-29 16:08:41.000000000 +0200 --- larpwiki-amazon.pl 2004-05-29 16:08:35.000000000 +0200 *************** *** 26,31 **** --- 26,33 ---- # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 USA + # applied patch: larpwiki-amazon.diff + package UseModWiki; use strict; local $| = 1; # Do not buffer output (localized for mod_perl) *************** *** 64,69 **** --- 66,74 ---- $AnchoredLinkPattern @HeadingNumbers $TableOfContents $QuotedFullUrl $ConfigError $UploadPattern ); + # amazon-patch + use vars qw($ASINPattern $AmazonPage $AmazonStuff $AmazonPartnerId $ASINUrl); + # == Configuration ===================================================== $DataDir = "/tmp/mywikidb"; # Main wiki directory $UseConfig = 1; # 1 = use config file, 0 = do not look for config *************** *** 321,326 **** --- 326,332 ---- $RFCPattern = "RFC\\s?(\\d+)"; $ISBNPattern = "ISBN:?([0-9- xX]{10,})"; $UploadPattern = "upload:([^\\]\\s\"<>$FS]+)$QDelim"; + $ASINPattern = "ASIN:?\\s?(\\w{10,10})"; } # Simple HTML cache *************** *** 568,573 **** --- 574,583 ---- $revision, $newText); $fullHtml .= "<hr class=wikilinediff>\n"; } + # amazon-patch + if ($id eq $AmazonPage and $AmazonPage ne '') { + $fullHtml .= "<div class=\"amazon\">$AmazonStuff</div>\n"; + } $fullHtml .= '<div class=wikitext>'; $fullHtml .= &WikiToHTML($Text{'text'}); $fullHtml .= '</div>'; *************** *** 1661,1666 **** --- 1671,1677 ---- } s/\b$RFCPattern/&StoreRFC($1)/geo; s/\b$ISBNPattern/&StoreISBN($1)/geo; + s/\b$ASINPattern/&StoreASIN($1)/geo; if ($UseUpload) { s/$UploadPattern/&StoreUpload($1)/geo; } *************** *** 2002,2007 **** --- 2013,2032 ---- return "<a href=\"http://www.faqs.org/rfcs/rfc${num}.html\">RFC $num</a>"; } + sub StoreASIN { + my ($num) = @_; + + return &StoreRaw(&ASINLink($num)); + } + + sub ASINLink { + my ($num) = @_; + $ASINUrl = "http://www.amazon.com/exec/obidos/ASIN" unless $ASINUrl; + $AmazonPartnerId = '' unless $AmazonPartnerId; + + return "<a href=\"$ASINUrl/$num/$AmazonPartnerId\">ASIN $num</a>"; + } + sub StoreUpload { my ($url) = @_;