forked from xsf/xmpp.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pelicanconf.py
123 lines (92 loc) · 3.33 KB
/
pelicanconf.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
from datetime import datetime, timedelta
import logging
import json
SITENAME = "XMPP"
SITE_URL = ""
TIMEZONE = "Europe/Paris" #Unused (Pelican complains if you don't provide it)
DEFAULT_LANG = "en"
WITH_FUTURE_DATES = False
DEFAULT_METADATA = [
('top_menu_show', 'false'),
('top_menu_order', '-1'),
('dropdown_menu_show', 'false'),
('dropdown_menu_size', '0'),
('footer_show', 'false'),
('footer_order', '-1'),
('content_layout', 'single-column'),
('is_blog', 'false')
]
STATIC_PATHS = [ 'CNAME', 'images', 'scripts', 'extensions', 'icons', 'icons/favicon.ico', 'robots.txt', 'registrar', 'docs']
PAGE_PATHS = ['pages', 'registrar']
EXTRA_PATH_METADATA = {
'icons/favicon.ico': { 'path': 'favicon.ico' }
}
DIRECT_TEMPLATES = [ 'index', 'categories', 'archives' ]
ARTICLE_PATHS = [ 'posts/blog', 'posts/learn', 'posts/newsletter' ]
ARTICLE_URL = '{date:%Y}/{date:%m}/{slug}'
ARTICLE_SAVE_AS = '{date:%Y}/{date:%m}/{slug}/index.html'
INDEX_SAVE_AS = 'blog.html'
USE_FOLDER_AS_CATEGORY = False
DEFAULT_PAGINATION = 10
YEAR_ARCHIVE_SAVE_AS = '{date:%Y}/index.html'
THEME = "xmpp.org-theme"
MD_EXTENSIONS = [ 'codehilite(css_class=highlight)', 'extra' ]
FEED_MAX_ITEMS = 20
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None
CATEGORY_FEED_ATOM = None
CATEGORY_FEED_RSS = None
TAG_FEED_ATOM = None
TAG_FEED_RSS = None
SWLISTS = {}
ENTRY_LIFETIME = timedelta(days=365)
# entires without renewal will be hidden after this point in time
STRICT_RENEWAL_DEADLINE = datetime(2017, 6, 1, 0, 0, 0)
def load_software_list(now, filename):
"""
Load, preprocess and filter a software list from JSON.
:param now: Used to determine whether software is still shown.
:param filename: Filename in the ``data`` subdirectory to load.
:return: List of dicts containing software information.
* Software whose ``last_renewal`` is not null and older than
:data:`ENTRY_LIFETIME` is omitted from the result.
* Software whose ``last_renewal`` is none is removed after
:data:`STRICT_RENEWAL_DEADLINE`.
"""
with open("data/{}".format(filename), "r") as f:
rows = json.load(f)
result = []
for row in rows:
renewed = row.get("last_renewed")
# has the software ever been renewed under the new system?
if renewed is not None:
try:
renewed = datetime.strptime(renewed, "%Y-%m-%dT%H:%M:%S")
except ValueError:
logging.error(
"failed to parse timestamp; omitting entry %r",
row,
)
# parse error -> omit
continue
if now - renewed > ENTRY_LIFETIME:
# renewal expired -> omit
continue
elif now > STRICT_RENEWAL_DEADLINE:
# not renewed ever, also over deadline -> omit
continue
# set parsed timestamp
row["last_renewed"] = renewed
# put into result list
result.append(row)
return result
NOW = datetime.utcnow()
SWLISTS["libraries"] = load_software_list(NOW, "libraries.json")
SWLISTS["clients"] = load_software_list(NOW, "clients.json")
SWLISTS["servers"] = load_software_list(NOW, "servers.json")
with open("data/members.json", "r") as f:
MEMBERLIST = json.load(f)
XEPS = []