[Home]WikiPatches/IsbnCleanup

UseModWiki | WikiPatches | RecentChanges | Preferences

For 1.0, the ISBN names and links are easy-to-change configuration options, allowing an arbitrary number of sites. Here is a sample from my testing wiki:

# Names of sites.  (The first entry is used for the number link.)
@IsbnNames = ('bn.com', 'amazon.com', 'powells.com', 'search');
# Full URL of each site before the ISBN
@IsbnPre = ('http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=',
            'http://www.amazon.com/exec/obidos/ISBN=',
            'http://www.powells.com/cgi-bin/biblio?isbn=',
            'http://www.pricescan.com/books/BookDetail.asp?isbn=');
# Rest of URL of each site after the ISBN (usually not needed)
@IsbnPost = ('', '', '', '');

I decided not to translate the names, since I think many non-US wikis would rather change the links to local sites. --CliffordAdams


ISBNLink Clean-up, Makes Changing Bookstores Easier

This patch moves the words "alternate" and "search" out of the URL variables for the bookstore and down a few lines where the ISBNLink string gets assembled. With the URLs isolated in the string variables, it's easier to swap other bookstores in or change the order (on my wiki I swap BN and Amazon, for instance).
--- usemod092/wiki.pl   Sat Apr 21 17:44:10 2001
+++ wiki.pl     Sun Aug 12 11:08:33 2001
@@ -1482,11 +1482,11 @@
   $first  = "<a href=\"http://shop.barnesandnoble.com/bookSearch/"
             . "isbnInquiry.asp?isbn=$num\">";
   $second = "<a href=\"http://www.amazon.com/exec/obidos/"
-            . "ISBN=$num\">" . T('alternate') . "</a>";
+            . "ISBN=$num\">";
   $third  = "<a href=\"http://www.pricescan.com/books/"
-            . "BookDetail.asp?isbn=$num\">" . T('search') . "</a>";
+            . "BookDetail.asp?isbn=$num\">";
   $html  = $first . "ISBN " . $rawprint . "</a> ";
-  $html .= "($second, $third)";
+  $html .= "($second" . T('alternate') . "</a>, " .  $third . T('search') . "</a>)";
   $html .= " "  if ($rawnum =~ / $/);  # Add space if old ISBN had space.
   return $html;
 }
-- PeterKaminski

ISBN translated

The following copy of ISBNLink will make the URLs subject to translation, so that changing URLs is a matter of adding them to the translation file.

sub ISBNLink {
  my ($rawnum) = @_;
  my ($rawprint, $html, $num, $first, $second, $third); 
  $num = $rawnum;
  $rawprint = $rawnum;
  $rawprint =~ s/ +$//;
  $num =~ s/[- ]//g;
  if (length($num) != 10) {
    return "ISBN $rawnum";
  }
  $first  = $q->a({-href => Ts('http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=%s', $num)},
		  "ISBN " . $rawprint);
  $second = $q->a({-href => Ts('http://www.amazon.com/exec/obidos/ISBN=%s', $num)},
		  T('alternate'));
  $third  = $q->a({-href => Ts('http://www.pricescan.com/books/BookDetail.asp?isbn=%s', $num)},
		  T('search'));
  $html  = "$first ($second, $third)";
  $html .= ' '  if ($rawnum =~ / $/);  # Add space if old ISBN had space.
  return $html;
}


WikiPatches

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited October 15, 2007 4:13 am by MarkusLude (diff)
Search: