-
Notifications
You must be signed in to change notification settings - Fork 2
/
update.py
62 lines (47 loc) · 1.85 KB
/
update.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: AGPL-3.0-or-later
from jinja2 import Environment, FileSystemLoader
import os
from pages import index as page_index
from pages import download_desktop as page_download_desktop
from pages import donate as page_donate
from pages import community_plugins as page_community_plugins
from pages import __filelist__ as page_filelist
from pages import __utils__ as page_utils
def generate_page(page):
template = env.get_template(page)
markers = {'active_page': page}
if page == 'index.html':
widget = page_index.get_telegram_widget("iitc_news")
if widget is None:
print("Error updating telegram")
markers['telegram_widget'] = widget
markers['screenshots_carousel'] = page_index.get_screenshots_carousel()
if page in ["download_desktop.html", "download_mobile.html"]:
markers.update(page_utils.get_meta_markers())
if page == "download_desktop.html":
markers.update(page_download_desktop.get_zip_file_names())
if page == "community_plugins.html":
markers.update(page_community_plugins.get_community_plugins_by_categories())
if page == "donate.html":
markers.update(page_donate.get_donations_data())
html = template.render(markers)
path = "static/" + page
with open(path, "w") as fh:
fh.write(html)
if __name__ == '__main__':
env = Environment(
loader=FileSystemLoader("template"),
trim_blocks=True
)
env.filters['md5sum'] = page_utils.file_add_md5sum
page_utils.copy_last_build_from_archive()
page_filelist.recursive_generate_index_pages(env)
files = os.listdir("template")
files = filter(lambda x: x.endswith(".html"), files)
for _page in files:
if _page.startswith("_"):
continue
generate_page(_page)
print("done")