Attachment 'text_x_frame-1.6.0-1.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - Frame Parser
   4 
   5     This parser is used to align enclosed wiki markup.
   6         
   7     Syntax:
   8         {{{#!frame align=align,frame_thick=frame_thick,frame_style=frame_style,frame_color=frame_color,
   9         frame_background=frame_background,frame_position=frame_position,frame_width=frame_width,frame_padding=frame_padding,
  10         frame_margin=frame_margin
  11         wiki markup
  12         }}}
  13     
  14     Parameters:
  15         align:            one of ['left', 'right', 'center', 'justify', 'column:left', 'column:right','float:left','float:right']
  16                           default: left
  17         frame_thick:      one of ['thin', 'medium',' thick','1px','2px','5px','10px']
  18                           default: thin
  19         frame_style:      one of ['none','hidden', 'dotted', 'dashed', 'solid', 'double',
  20                                   'groove', 'ridge', 'inset',  'outset']
  21                           default: solid
  22         frame_color:      each which could be vrified by web.Color(str(name))
  23                           default: #9999FF
  24                        
  25         frame_background: each which could be vrified by web.Color(str(name))
  26                           default: transparent
  27                           
  28         frame_position:   one of ['static','absolute','relative','fixed','inherit']
  29                           default: relative
  30                           
  31         frame_width:      has to end with % is testet by str(float(number))
  32                           default: auto
  33                           
  34         frame_padding:    has to end with em is testet by str(float(number))
  35                           default: 0em
  36                           
  37         frame_margin:     has to end with em is testet by str(float(number))
  38                           default: 0em                 
  39         
  40         text_align:       one of ['left', 'right', 'center', 'justify']                              
  41                           default: left
  42                           
  43         wiki markup: could any wiki markup 
  44 
  45     Procedure:
  46         Please remove the version number.
  47         
  48         The units are limited for numbers. And only one value for frame_padding or frame_margin 
  49 
  50     Examples:
  51         {{{
  52         #!frame align=float:right
  53         attachment:moinmoin.png
  54         ||A||B||
  55         ||C||D||
  56         ||C||D||
  57         }}}
  58     
  59         {{{ 
  60 #!frame align=column:left,frame_position=relative,frame_width=48%,frame_margin=0em,frame_thick=2px,frame_color=blue,frame_background=yellow
  61 A WikiName is a word that uses capitalized words. WikiNames automagically become hyperlinks to the WikiName's page. What exactly is an uppercase or lowercase letter is determined by the configuration, the default configuration should work for UTF-8 characters (digits are treated like lowercase characters). 
  62 
  63 
  64 When you click on the highlighted page title (i.e. WikiName on this page), you will see a list of all pages that link to the current page. This even works on pages that are not defined yet.
  65 }}}{{{
  66 #!frame align=column:right,frame_position=relative,frame_width=50%,frame_margin=0em,frame_thick=2px,frame_color=blue
  67 When you click on the highlighted page title (i.e. WikiName on this page), you will see a list of all pages that link to the current page. This even works on pages that are not defined yet. 
  68 
  69 
  70 A question mark before a link or a different rendering in grey means that the page is not yet defined: you can click the question mark or page name to offer a definition (e.g., ?NoSuchPageForReal). If you click on such a link, you will see a default page that you can edit; only after you save the page will it be created for real. A list of all pages that are not yet created but referred on another page is on WantedPages. 
  71 
  72 
  73 To escape a WikiName, i.e. if you want to write the word WikiName without linking it, use an "empty" bold sequence (a sequence of six single quotes) like this: Wiki''''''Name. Alternatively, you can use the shorter sequence "``" (two backticks), i.e. Wiki``Name.
  74 }}}
  75 {{{ 
  76 #!frame align=clear
  77 }}}
  78         
  79         
  80     Modification History:
  81         @copyright: 2006 by Reimar Bauer
  82         @license: GNU GPL, see COPYING for details.
  83             
  84         
  85     
  86         
  87        initial version 1.6.0-1
  88 """
  89 import StringIO
  90 from random import randint
  91 from MoinMoin.parser import text_moin_wiki
  92 from MoinMoin import wikiutil
  93 from MoinMoin.action import AttachFile
  94 from MoinMoin.util import web
  95 
  96 Dependencies = []
  97 
  98 class Parser:
  99 
 100     extensions = ['*']
 101     Dependencies = Dependencies
 102 
 103     def __init__(self, raw, request, **kw):
 104         self.raw = raw
 105         self.request = request
 106         
 107         self.align = 'left'  # secured
 108         
 109         self.text_align = 'left' #secured
 110         self.frame_thick = 'thin' #secured
 111         self.frame_style = 'solid' #secured
 112         self.frame_color = '#9999FF' #secured but color code name error crashes
 113         self.frame_background = 'transparent' #secured but color code name error crashes
 114         self.frame_position = 'relative' #secured
 115         self.frame_width = 'auto' #needs a better idea to get it secure at the moment only % is allowed
 116         self.frame_padding = '0em' #needs a better idea to get it secure
 117         self.frame_margin = '0em'#needs a better idea to get it secure
 118         
 119         
 120         for arg in kw.get('format_args', '').split(','):
 121 
 122             if arg.find('=') > -1:
 123                 key, value = arg.split('=')
 124                 setattr(self, key, wikiutil.escape(value.strip(), quote=1)) 
 125                 
 126     
 127 
 128     def format(self, formatter):
 129         raw = self.raw
 130         pagename = formatter.page.page_name
 131 
 132         out = StringIO.StringIO()
 133         self.request.redirect(out)
 134         wikiizer = text_moin_wiki.Parser(raw, self.request)
 135         wikiizer.format(formatter)
 136         result = out.getvalue()
 137         self.request.redirect()
 138         del out
 139         
 140         if self.frame_position in ['static','absolute','relative','fixed','inherit']:
 141            frame_position =  self.frame_position
 142         else:
 143            frame_position = 'relative'
 144         
 145         if self.frame_thick in ['thin', 'medium',' thick','1px','2px','5px','10px']:
 146            frame_thick = self.frame_thick
 147         else: 
 148            frame_thick = '0'
 149            
 150         if self.text_align in ['left', 'right', 'center', 'justify']:
 151            text_align = self.text_align
 152         else:
 153            text_align = 'left'   
 154            
 155         if self.frame_style in ['none','hidden', 'dotted', 'dashed', 'solid', 'double',
 156                                 'groove', 'ridge', 'inset',  'outset']:
 157            frame_style = self.frame_style    
 158         else:
 159            frame_style = 'solid'   
 160                          
 161         if self.frame_color !=  'transparent':
 162             frame_color = web.Color(str(self.frame_color))
 163         else:
 164             frame_color = self.frame_color
 165             
 166         if self.frame_background !=  'transparent':
 167            frame_background = web.Color(str(self.frame_background))
 168         else:
 169            frame_background = self.frame_background
 170            
 171         if self.frame_width.endswith("%"):
 172             frame_width = str(float(self.frame_width[:-1]))+'%'
 173         else:
 174             frame_width = 'auto'   
 175             
 176         if self.frame_padding.endswith("em"):
 177             frame_padding = str(float(self.frame_padding[:-2]))+'em'
 178         else:
 179             frame_padding = '0em'       
 180             
 181         if self.frame_margin.endswith("em"):
 182             frame_margin = str(float(self.frame_margin[:-2]))+'em'
 183         else:
 184             frame_margin = '0em'         
 185            
 186         if self.align in ['left', 'right', 'center', 'justify']:
 187             div = '<div align="%(align)s" style="border-width:%(frame_thick)s; border-color:%(frame_color)s; border-style:%(frame_style)s; position:%(frame_position)s; padding:%(frame_padding)s; margin:%(frame_margin)s; background-color:%(frame_background)s" width="%(frame_width)s">' % { 
 188                     "frame_thick": frame_thick,
 189                     "frame_style": frame_style,
 190                     "frame_color": frame_color,
 191                     "frame_position": frame_position,
 192                     "frame_padding": frame_padding,
 193                     "frame_margin": frame_margin,
 194                     "frame_background": frame_background,
 195                     "frame_width": frame_width,
 196                     "text_align": text_align,
 197                     "align": self.align,
 198                     }
 199             self.request.write("%(div)s%(result)s</div>" % {
 200                  "div": div,
 201                  "result": result}) 
 202         
 203         if self.align in ['column:left', 'column:right','float:left','float:right']:         
 204             if self.align == 'column:left':
 205                 align = 'float:left'
 206             if  self.align == 'column:right':
 207                 align = 'float:right'
 208             if self.align == 'float:left':
 209                 align = self.align
 210             if  self.align == 'float:right':
 211                 align = self.align
 212                 
 213             tab = '<table style="%(align)s;" position="%(frame_position)s" width="%(frame_width)s" border="%(frame_thick)s"; bgcolor="%(frame_background)s"><tbody><tr><td style="border-style:none;">' % {
 214                     "align": align,
 215                     "frame_position": frame_position,
 216                     "frame_width": frame_width,
 217                     "frame_thick": frame_thick,
 218                     "frame_background": frame_background,
 219                 } 
 220             self.request.write("%(tab)s%(result)s</td></tr></tbody></table>" % {
 221                                "tab": tab,
 222                                "result": result})  
 223             
 224         if self.align == 'clear':
 225             self.request.write('<br clear="both">')                        
 226             
 227                  
 228             
 229             
 230         
 231         
 232         
 233         
 234         

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-08-15 19:58:26, 11.9 KB) [[attachment:Frame-1.5.4-3.py]]
  • [get | view] (2006-08-22 20:38:27, 12.8 KB) [[attachment:Frame-1.5.4-4.py]]
  • [get | view] (2006-09-04 06:51:24, 15.7 KB) [[attachment:Frame-1.5.4-5.py]]
  • [get | view] (2006-08-13 21:29:52, 9.7 KB) [[attachment:text_x_frame-1.6.0-1.py]]
  • [get | view] (2006-08-14 18:38:28, 11.7 KB) [[attachment:text_x_frame-1.6.0-2.py]]
  • [get | view] (2006-08-15 20:45:50, 11.4 KB) [[attachment:text_x_frame-1.6.0-3.py]]
  • [get | view] (2006-08-22 20:23:17, 12.4 KB) [[attachment:text_x_frame-1.6.0-4.py]]
  • [get | view] (2006-09-03 14:18:49, 15.7 KB) [[attachment:text_x_frame-1.6.0-5.py]]
 All files | Selected Files: delete move to page copy to page

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