summaryrefslogtreecommitdiffstats
path: root/web/macros.py
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2024-12-29 19:40:53 +0100
committerHolger Weiss <holger@zedat.fu-berlin.de>2024-12-29 19:40:53 +0100
commit501622816878fbae771a23449eab6d274e9a147a (patch)
tree52694fad76d9a05956d41e803a151232c88f5fa5 /web/macros.py
parent7471d8fd266fa7c23c9562cabab2e370b303d476 (diff)
downloadsite-501622816878fbae771a23449eab6d274e9a147a.tar.gz
Switch to latest Poole version
Use the latest Poole code currently available at: https://hg.sr.ht/~obensonne/poole Rather than including the code in this repository, expect it to be found in the PATH (e.g., in $prefix/opt/poole/env/bin). As Poole is Python-3-based now, update web/macros.py accordingly.
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)