summaryrefslogtreecommitdiffstats
path: root/web/macros.py
diff options
context:
space:
mode:
Diffstat (limited to 'web/macros.py')
-rw-r--r--web/macros.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/web/macros.py b/web/macros.py
index 3ef93e6..9dfadb2 100644
--- a/web/macros.py
+++ b/web/macros.py
@@ -1,4 +1,5 @@
1import email.utils 1import email.utils
2import math
2import os.path 3import os.path
3import time 4import time
4 5
@@ -68,9 +69,8 @@ def hook_postconvert_rss():
68 desc = 'Announcements published by the Monitoring Plugins Development Team.' 69 desc = 'Announcements published by the Monitoring Plugins Development Team.'
69 date = email.utils.formatdate() 70 date = email.utils.formatdate()
70 rss = _RSS % (title, link, desc, date, date, items) 71 rss = _RSS % (title, link, desc, date, date, items)
71 fp = open(os.path.join(output, 'rss.xml'), 'w') 72 with open(os.path.join(output, 'rss.xml'), 'w', encoding='utf-8') as fp:
72 fp.write(rss.encode('utf-8')) 73 fp.write(rss)
73 fp.close()
74 74
75# 75#
76# News 76# News
@@ -80,7 +80,7 @@ def hook_preconvert_news():
80 posts_per_page = 10 80 posts_per_page = 10
81 posts = [p for p in pages if 'date' in p] 81 posts = [p for p in pages if 'date' in p]
82 posts.sort(key=lambda p: p.date, reverse=True) 82 posts.sort(key=lambda p: p.date, reverse=True)
83 n_news_pages = len(posts) / posts_per_page 83 n_news_pages = math.ceil(len(posts) / posts_per_page)
84 if len(posts) % posts_per_page > 0: 84 if len(posts) % posts_per_page > 0:
85 n_news_pages += 1 85 n_news_pages += 1
86 for i, chunk in enumerate(next_news_chunk(posts, posts_per_page)): 86 for i, chunk in enumerate(next_news_chunk(posts, posts_per_page)):
@@ -108,7 +108,7 @@ def make_news_page(posts, current_index):
108 teaser = ['# ' + title] 108 teaser = ['# ' + title]
109 for p in posts: 109 for p in posts:
110 source = list() 110 source = list()
111 author = p.author.encode('ascii', 'xmlcharrefreplace') 111 author = p.author
112 timestamp = time.strptime(p.date, '%Y-%m-%d') 112 timestamp = time.strptime(p.date, '%Y-%m-%d')
113 author_date = author + ', ' + time.strftime('%B %-e, %Y', timestamp) 113 author_date = author + ', ' + time.strftime('%B %-e, %Y', timestamp)
114 teaser.append('## %s' % p.title) 114 teaser.append('## %s' % p.title)