formatting in archives page

This commit is contained in:
Frederic Peters 2009-05-25 16:47:33 +02:00
parent e0fb2d6a74
commit 7d4ebded93
2 changed files with 31 additions and 5 deletions

View File

@ -71,6 +71,11 @@ class RevuesDePresse(BaseContent):
return all_links[offset:]
return all_links[offset:offset+num]
def getYear(self, year):
if not year:
year = time.localtime()[0]
return int(year)
def getArchives(self, year):
if not year:
year = time.localtime()[0]
@ -80,7 +85,11 @@ class RevuesDePresse(BaseContent):
t = []
for month in range(12):
caltuples = calendar.monthcalendar(int(year), month+1)
t.append('<table>')
t.append('<table class="ploneCalendar">')
t.append('<thead>')
t.append('<tr><th colspan="7">%s / %s</th></tr>' % (month+1, year))
t.append('</thead>')
t.append('<tbody>')
for weektuple in caltuples:
t.append('<tr>')
for day in weektuple:
@ -93,7 +102,10 @@ class RevuesDePresse(BaseContent):
t.append('%s' % day)
t.append('</td>')
t.append('</tr>')
t.append('</tbody>')
t.append('</table>')
if month % 3 == 2:
t.append('<br />')
return '\n'.join(t)
registerType(RevuesDePresse)

View File

@ -17,6 +17,22 @@
<metal:cssslot fill-slot="css_slot">
<style type="text/css">
div.archives table.ploneCalendar {
width: auto;
border: 1px solid #8cacbb;
margin: 1em;
float: left;
}
div.archives table.ploneCalendar th {
background: #dee7ec;
border-bottom: 1px solid #8cacbb;
}
div.archives br {
clear: both;
}
</style>
</metal:cssslot>
@ -28,14 +44,12 @@
year python:context.REQUEST.get('year')">
<div tal:replace="structure provider:plone.abovecontenttitle" />
<h1 metal:use-macro="here/kss_generic_macros/macros/generic_title_view">
Title or id
</h1>
<h1 class="documentFirstHeading"><span tal:replace="context/title"/> - <span tal:replace="python: context.getYear(year)"/></h1>
<div tal:replace="structure provider:plone.belowcontenttitle" />
<div tal:replace="structure provider:plone.abovecontentbody" />
<div tal:replace="structure python: context.getArchives(year)"/>
<div class="archives" tal:content="structure python: context.getArchives(year)"/>
<div tal:replace="structure provider:plone.belowcontentbody" />
</tal:main-macro>