ajout d'une couleur random pour les boites

darcs-hash:20060417100007-f46e9-e8c3cdaf10a7c03ef4a56457dcee55e1d1c03b56.gz
This commit is contained in:
gdetrez 2006-04-17 12:00:07 +02:00
parent c553d5fda0
commit 1baf6e6a58
2 changed files with 15 additions and 5 deletions

View file

@ -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
@ -104,7 +115,6 @@ class Parser:
color = self.settings['color']
except:
color=None
boite.make( title,content, color)
boite.make(title, content, color)
return

View file

@ -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))