Plugins OK

This commit is contained in:
Gregory Soutade
2014-11-21 10:41:29 +01:00
parent 34aec57c46
commit 7dada493ab
5 changed files with 93 additions and 55 deletions

View File

@@ -1,3 +1,4 @@
def createPage(display, filename, title):
page = {}
page['title'] = title;
@@ -14,27 +15,37 @@ def createTable(title, cols):
table['cols'] = cols
table['rows'] = []
return table
def appendRowToTable(table, row):
table['rows'].append(row)
def buildPages(display):
def buildTable(block, f):
print 'Write table %s' % block['title']
f.write('<table>')
f.write('<tr>')
for title in block['cols']:
f.write('<th>%s</th>' % (title))
f.write('</tr>')
for row in block['rows']:
f.write('<tr>')
for v in row:
f.write('<td>%s</td>' % (v))
f.write('</tr>')
f.write('</table>')
def buildPages(display_root, display):
for filename in display.keys():
page = display[filename]
with open(DISPLAY_ROOT + filename, 'w') as f:
print "OPEN %s" % (display_root + filename)
with open(display_root + filename, 'w') as f:
f.write('<html><title>%s</title><body>' % (page['title']))
for block in page['blocks']:
print "Bluid block"
print block
print "End block"
if block['type'] == 'html':
f.write(block['value'])
elif block['type'] == 'table':
f.write('<table>')
f.write('<tr>')
for title in block['cols']:
f.write('<th>%s</th>' % (title))
f.write('</tr>')
for row in block['rows']:
f.write('<tr>')
for v in row:
f.write('<td>%s</td>' % (v))
f.write('</tr>')
f.write('</table>')
buildTable(block, f)
f.write('</body></html>')