Attachment 'ISBN.py'

Download

   1 """
   2     MoinMoin - ISBN Macro (link to Amazon, B&N, etc)
   3 
   4     Usage: [[ISBN(isbn[,...])]]
   5 
   6     @copyright: 2006 by Clif Kussmaul <clif@kussmaul.org>
   7     @license:   GNU GPL, see COPYING for details
   8 """
   9 
  10 # dictionary of keys and urls that use ISBN
  11 _isbn_links = { 'Amazon':'http://www.amazon.com/dp/%s' ,
  12                    'B&N':'http://search.barnesandnoble.com/booksearch/isbninquiry.asp?ISBN=%s'}
  13 
  14 def execute(macro, args):
  15     f = macro.formatter
  16     result = ''
  17     if args:
  18         args = [arg.strip() for arg in args.split(',')] 
  19     else:
  20         args = []
  21     if 0 == len(args):
  22         result += f.strong(1) + \
  23                   f.text('Example: [[ISBN(1234567890, ...)]]') + \
  24                   f.strong(0) + \
  25                   f.text(' - links to Amazon, B&N, etc')
  26     else:
  27         for arg in args:
  28             for key in _isbn_links.keys():
  29                 result += f.text('(') + \
  30                           f.url(1, _isbn_links[key] % arg) + \
  31                           f.text(key) + \
  32                           f.url(0)    + \
  33                           f.text(')')
  34 
  35     return result

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2006-09-13 11:45:01, 1.1 KB) [[attachment:ISBN.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.