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
|
import os,string,re,StringIO
|
||||||
from MoinMoin.action import AttachFile
|
from MoinMoin.action import AttachFile
|
||||||
|
|
||||||
|
color_list = ['orange', 'black', 'red', 'green', 'blue', 'gray']
|
||||||
|
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# Fonctions #
|
# Fonctions #
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
@ -81,6 +84,11 @@ class Parser:
|
||||||
self.settings={'title': u'|'.join([u" ".join(kw.keys()), u" ".join(kw.values())])}
|
self.settings={'title': u'|'.join([u" ".join(kw.keys()), u" ".join(kw.values())])}
|
||||||
self.settings = self.parseArgs(kw["format_args"])
|
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):
|
def parseArgs(self, argsString):
|
||||||
argList = argsString.split(u',')
|
argList = argsString.split(u',')
|
||||||
|
@ -88,7 +96,10 @@ class Parser:
|
||||||
for anArg in argList:
|
for anArg in argList:
|
||||||
anArg = anArg.strip(u' ')
|
anArg = anArg.strip(u' ')
|
||||||
if anArg.find(u'color=')!=-1:
|
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:
|
else:
|
||||||
settings['title'] = anArg
|
settings['title'] = anArg
|
||||||
return settings
|
return settings
|
||||||
|
@ -104,7 +115,6 @@ class Parser:
|
||||||
color = self.settings['color']
|
color = self.settings['color']
|
||||||
except:
|
except:
|
||||||
color=None
|
color=None
|
||||||
boite.make( title,content, color)
|
boite.make(title, content, color)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ class PortailFormatter:
|
||||||
def cell(self, title, description, image):
|
def cell(self, title, description, image):
|
||||||
if self.counter==0:
|
if self.counter==0:
|
||||||
self.request.write(self.formatter.table_row(1))
|
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(title)
|
||||||
self.request.write(description)
|
self.request.write(description)
|
||||||
self.request.write(self.formatter.table_cell(0))
|
self.request.write(self.formatter.table_cell(0))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue