Attachment 'UserSmileys.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 
   3 """
   4     MoinMoin - UserSmileys
   5 
   6     UserSmileys is a solution suggestion for user smileys and subtraction of smileys.
   7 
   8     See FeatureRequests/SubtractSmileys
   9     See http://moinmoin.wikiwikiweb.de/FeatureRequests/SubtractSmileys
  10 
  11 
  12     Installation:
  13 
  14         Place UserSmiley.py in your wikipath, i.e. in the same directory as
  15           * moin.py
  16           * wikiconfig.py
  17           * wikiserverconfig.py
  18 
  19 
  20     Usage:
  21 
  22         UserSmiley.py defines 4 functions:
  23           has_smiley( key ) -- to ask if a smiley exists
  24           add_smiley( key, width, height, border, filename ) -- to add a smiley - currently a probably existing smiley will be redefined
  25           redefine_smiley( key, width, height, border, filename ) -- to redefine a smiley - a probably existing smiley will be removed, the new smiley will be added
  26           remove_smiley( key ) -- to remove an existing smiley
  27 
  28         Call this functions from your wikiconfig.py.
  29         This ensures you can define the smileys on a wiki-by-wiki basis.
  30 
  31         Example (from wikiconfig.py):
  32 
  33             # user smiley management
  34             # remove some unwanted smileys:
  35             if True:
  36                 UserSmileys.remove_smiley(':(')
  37                 UserSmileys.remove_smiley(':-(')
  38                 UserSmileys.remove_smiley(':-?')
  39                 UserSmileys.remove_smiley(':o')
  40                 UserSmileys.remove_smiley('{*}')
  41                 UserSmileys.remove_smiley('{o}')
  42                 UserSmileys.remove_smiley('|-)')
  43 
  44                 UserSmileys.remove_smiley(':)')
  45                 UserSmileys.remove_smiley(';)')
  46                 UserSmileys.remove_smiley('<:(')
  47                 UserSmileys.remove_smiley(':))')
  48                 UserSmileys.remove_smiley(':\\')
  49                 UserSmileys.remove_smiley('>:>')
  50                 UserSmileys.remove_smiley('X-(')
  51                 UserSmileys.remove_smiley('|)')
  52 
  53             # redefine some flags:
  54             if True:
  55                 UserSmileys.redefine_smiley('{en}',18,12,0,'flag-en-normal.png')
  56                 UserSmileys.redefine_smiley('{es}',18,12,0,'flag-es-normal.png')
  57                 UserSmileys.redefine_smiley('{us}',18,12,0,'flag-us-normal.png')
  58                 UserSmileys.redefine_smiley('{fi}',18,12,0,'flag-fi-border.png')
  59                 UserSmileys.redefine_smiley('{ja}',18,12,0,'flag-ja-border.png')
  60                 UserSmileys.redefine_smiley('{ko}',18,12,0,'flag-ko-border.png')
  61 
  62             # add some flags:
  63             if True:
  64                 UserSmileys.add_smiley('{au}',18,12,0,'flag-au-normal.png')
  65 
  66 
  67     Tests:
  68 
  69         This feature has been successfully tested with MoinMoin version MoinDesktop_1.3.4-2 (zipped standalone version) and python 2.4
  70 """
  71 
  72 from MoinMoin import config
  73 
  74 def has_smiley(key):
  75     return config.smileys.has_key[key]
  76 
  77 
  78 def add_smiley(key, width, height, border, filename ):
  79     print "Performing add_smiley() ..."
  80 
  81     config.smileys[key] = (width, height, border, filename)
  82     return
  83 
  84 
  85 def redefine_smiley(key, width, height, border, filename ):
  86     print "Performing redefine_smiley() ..."
  87 
  88     remove_smiley(key)
  89     add_smiley(key, width, height, border, filename)
  90     return
  91 
  92 
  93 def remove_smiley(key):
  94     print "Performing remove_smiley() ..."
  95 
  96     if config.smileys.has_key( key ):
  97         del config.smileys[key]
  98 
  99     return

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] (2005-08-08 20:10:29, 3.4 KB) [[attachment:UserSmileys.py]]
 All files | Selected Files: delete move to page copy to page

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