diff options
Diffstat (limited to 'web/macros.py')
| -rw-r--r-- | web/macros.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/web/macros.py b/web/macros.py index df64a26..3eb1046 100644 --- a/web/macros.py +++ b/web/macros.py | |||
| @@ -1,19 +1,19 @@ | |||
| 1 | import email.utils | 1 | import email.utils |
| 2 | import math | ||
| 2 | import os.path | 3 | import os.path |
| 3 | import time | 4 | import time |
| 4 | 5 | ||
| 5 | plugins_release = '2.3.1' | 6 | plugins_release = '3.0.0-rc1' |
| 6 | mib_release = '1.0.1' | 7 | mib_release = '1.0.1' |
| 7 | release_notes = 'news/release-%s.html' % plugins_release.replace('.', '-') | 8 | release_notes = 'news/release-%s.html' % plugins_release.replace('.', '-') |
| 8 | site_url = 'https://www.monitoring-plugins.org/' | 9 | site_url = 'https://www.monitoring-plugins.org/' |
| 9 | feeds = """These project news articles are also available as an | 10 | feeds = """These project news articles are also available as an |
| 10 | [RSS feed][rss]{: rel="alternate" type="application/rss+xml" }. Additional | 11 | [RSS feed][rss]{: rel="alternate" type="application/rss+xml" }. Additional |
| 11 | stuff is posted to [Twitter][twitter], so you might want to [follow us][follow] | 12 | stuff is posted to [Mastodon][mastodon], so you might want to follow us there as |
| 12 | there as well. | 13 | well. |
| 13 | 14 | ||
| 14 | [rss]: rss.xml "RSS Feed" | 15 | [rss]: rss.xml "RSS Feed" |
| 15 | [twitter]: https://twitter.com/ "Twitter" | 16 | [mastodon]: https://fosstodon.org/@monitoringplugins "Mastodon" |
| 16 | [follow]: https://twitter.com/intent/follow?screen_name=monitorplugins "Follow Us" | ||
| 17 | """ | 17 | """ |
| 18 | 18 | ||
| 19 | page = { | 19 | page = { |
| @@ -68,9 +68,8 @@ def hook_postconvert_rss(): | |||
| 68 | desc = 'Announcements published by the Monitoring Plugins Development Team.' | 68 | desc = 'Announcements published by the Monitoring Plugins Development Team.' |
| 69 | date = email.utils.formatdate() | 69 | date = email.utils.formatdate() |
| 70 | rss = _RSS % (title, link, desc, date, date, items) | 70 | rss = _RSS % (title, link, desc, date, date, items) |
| 71 | fp = open(os.path.join(output, 'rss.xml'), 'w') | 71 | with open(os.path.join(output, 'rss.xml'), 'w', encoding='utf-8') as fp: |
| 72 | fp.write(rss) | 72 | fp.write(rss) |
| 73 | fp.close() | ||
| 74 | 73 | ||
| 75 | # | 74 | # |
| 76 | # News | 75 | # News |
| @@ -80,7 +79,7 @@ def hook_preconvert_news(): | |||
| 80 | posts_per_page = 10 | 79 | posts_per_page = 10 |
| 81 | posts = [p for p in pages if 'date' in p] | 80 | posts = [p for p in pages if 'date' in p] |
| 82 | posts.sort(key=lambda p: p.date, reverse=True) | 81 | posts.sort(key=lambda p: p.date, reverse=True) |
| 83 | n_news_pages = len(posts) / posts_per_page | 82 | n_news_pages = math.ceil(len(posts) / posts_per_page) |
| 84 | if len(posts) % posts_per_page > 0: | 83 | if len(posts) % posts_per_page > 0: |
| 85 | n_news_pages += 1 | 84 | n_news_pages += 1 |
| 86 | for i, chunk in enumerate(next_news_chunk(posts, posts_per_page)): | 85 | for i, chunk in enumerate(next_news_chunk(posts, posts_per_page)): |
| @@ -108,7 +107,7 @@ def make_news_page(posts, current_index): | |||
| 108 | teaser = ['# ' + title] | 107 | teaser = ['# ' + title] |
| 109 | for p in posts: | 108 | for p in posts: |
| 110 | source = list() | 109 | source = list() |
| 111 | author = p.author.encode('ascii', 'xmlcharrefreplace') | 110 | author = p.author |
| 112 | timestamp = time.strptime(p.date, '%Y-%m-%d') | 111 | timestamp = time.strptime(p.date, '%Y-%m-%d') |
| 113 | author_date = author + ', ' + time.strftime('%B %-e, %Y', timestamp) | 112 | author_date = author + ', ' + time.strftime('%B %-e, %Y', timestamp) |
| 114 | teaser.append('## %s' % p.title) | 113 | teaser.append('## %s' % p.title) |
