list all links
This commit is contained in:
parent
2ac74a424b
commit
555f8fc5e1
|
@ -1,5 +1,7 @@
|
|||
""" RevuesDePresse Class """
|
||||
|
||||
import os
|
||||
|
||||
from interfaces import IRevuesDePresse
|
||||
from zope.interface import implements
|
||||
from Products.Archetypes.public import *
|
||||
|
@ -39,6 +41,29 @@ class RevuesDePresse(BaseContent):
|
|||
_at_rename_after_creation = True
|
||||
|
||||
def getTodayLink(self):
|
||||
if not self.pressreviewsbaseurl[-1] == '/':
|
||||
self.pressreviewsbaseurl += '/'
|
||||
return self.pressreviewsbaseurl + 'revue.PDF'
|
||||
|
||||
def getAllLinks(self):
|
||||
'''Return a list of tuples (url, label)'''
|
||||
if not self.pressreviewsbaseurl[-1] == '/':
|
||||
self.pressreviewsbaseurl += '/'
|
||||
filenames = os.listdir(self.pressreviewspath)
|
||||
def cmp_filenames(x, y):
|
||||
if len(x) != 18:
|
||||
return -1
|
||||
if len(y) != 18:
|
||||
return 1
|
||||
return cmp((y[10:14], y[8:10], y[6:8]), (x[10:14], x[8:10], x[6:8]))
|
||||
filenames.sort(cmp_filenames)
|
||||
all_links = []
|
||||
for filename in filenames:
|
||||
if not os.path.splitext(filename)[-1].lower() == '.pdf':
|
||||
continue
|
||||
url = self.pressreviewsbaseurl + filename
|
||||
label = '%s/%s/%s' % (filename[6:8], filename[8:10], filename[10:14])
|
||||
all_links.append((url, label))
|
||||
return all_links
|
||||
|
||||
registerType(RevuesDePresse)
|
||||
|
|
|
@ -20,7 +20,17 @@
|
|||
div.intro {
|
||||
float: left;
|
||||
width: 60%;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
div.calendars {
|
||||
float: right;
|
||||
width: 20em;
|
||||
background: #dee7ec;
|
||||
border: 1px solid #8cacbb;
|
||||
}
|
||||
|
||||
div.calendars ul {
|
||||
list-style: none;
|
||||
}
|
||||
</style>
|
||||
</metal:cssslot>
|
||||
|
@ -47,8 +57,12 @@ div.intro {
|
|||
</div>
|
||||
|
||||
<div class="calendars">
|
||||
<a tal:attributes="href python: context.getTodayLink()"
|
||||
i18n:translate="today_press_review">Today Press Review</a>
|
||||
<ul>
|
||||
<li><a tal:attributes="href python: context.getTodayLink()"
|
||||
i18n:translate="today_press_review">Today Press Review</a></li>
|
||||
<li tal:repeat="link python: context.getAllLinks()">
|
||||
<a tal:attributes="href python: link[0]" tal:content="python: link[1]">plop</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div tal:replace="structure provider:plone.belowcontentbody" />
|
||||
|
|
Reference in New Issue