blob: 01555aa64a7fcfd2f127c32c2f0215b49cabd9cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import template
import plugin
import string
import os
class NewsPlugin:
def __init__(self):
newspath = os.path.join(template.path, 'news')
newsfiles = [ os.path.join(newspath, entry) for entry in sorted(os.listdir(newspath)) \
if not entry.startswith('.') ]
self._news = []
for newsfile in reversed(newsfiles):
self._news.append(open(newsfile, 'r').read())
def process_content(self, page_content):
return_value = {}
for filename, content in page_content.iteritems():
template = string.Template(content)
return_value[filename] = template.safe_substitute(
news = ''.join(self._news),
latest_news = ''.join(self._news[:5]),
)
return return_value
plugin.plugin_manager.register(NewsPlugin())
|