ajout d'une couleur random pour les boites
darcs-hash:20060417100007-f46e9-e8c3cdaf10a7c03ef4a56457dcee55e1d1c03b56.gz
This commit is contained in:
parent
c553d5fda0
commit
1baf6e6a58
2 changed files with 15 additions and 5 deletions
|
@ -18,6 +18,9 @@ from MoinMoin.parser import wiki
|
|||
import os,string,re,StringIO
|
||||
from MoinMoin.action import AttachFile
|
||||
|
||||
color_list = ['orange', 'black', 'red', 'green', 'blue', 'gray']
|
||||
|
||||
|
||||
#####################################################################
|
||||
# Fonctions #
|
||||
#####################################################################
|
||||
|
@ -81,6 +84,11 @@ class Parser:
|
|||
self.settings={'title': u'|'.join([u" ".join(kw.keys()), u" ".join(kw.values())])}
|
||||
self.settings = self.parseArgs(kw["format_args"])
|
||||
|
||||
def getRandomColor(self):
|
||||
nb_of_colors = color_list.__len__()
|
||||
from random import randint
|
||||
colorNum = randint(0, nb_of_colors - 1)
|
||||
return color_list[colorNum]
|
||||
|
||||
def parseArgs(self, argsString):
|
||||
argList = argsString.split(u',')
|
||||
|
@ -88,7 +96,10 @@ class Parser:
|
|||
for anArg in argList:
|
||||
anArg = anArg.strip(u' ')
|
||||
if anArg.find(u'color=')!=-1:
|
||||
settings['color'] = anArg.split(u'=')[1]
|
||||
theColor = anArg.split(u'=')[1]
|
||||
if theColor == 'random':
|
||||
theColor = self.getRandomColor()
|
||||
settings['color'] = theColor
|
||||
else:
|
||||
settings['title'] = anArg
|
||||
return settings
|
||||
|
@ -107,4 +118,3 @@ class Parser:
|
|||
boite.make(title, content, color)
|
||||
return
|
||||
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ class PortailFormatter:
|
|||
def cell(self, title, description, image):
|
||||
if self.counter==0:
|
||||
self.request.write(self.formatter.table_row(1))
|
||||
self.request.write(self.formatter.table_cell(1,{'style':'width:50%;border:none;padding:20px 20px 20px 50px;background:transparent url(\'' + image.replace("\'","\\\'") + '\') center left no-repeat; vertical-align:center;'}))
|
||||
self.request.write(self.formatter.table_cell(1,{'style':'width:50%;border:none;padding:20px 20px 20px 50px;background:transparent url(\'' + image.replace("\'","\\\'") + '\') center left no-repeat; vertical-align:middle;'}))
|
||||
self.request.write(title)
|
||||
self.request.write(description)
|
||||
self.request.write(self.formatter.table_cell(0))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue