-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.py
48 lines (42 loc) · 1.76 KB
/
build.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
from staticjinja import Site
import json
from urllib.parse import urlparse
if __name__ == "__main__":
# load in news posts - temporarily before moving to non-static server?
f = open("news_posts.json")
posts = json.loads(f.read())
f.close()
# load in curriculum problems - temporarily before moving to non-static server?
f = open("problems.json")
problems = json.loads(f.read())
f.close()
# some processing of the problems
for itemSet in problems:
for item in itemSet["items"]:
if item['type'] == "problem":
if "usaco.org" in item["url"]:
item["source"] = "USACO"
elif "atcoder.jp" in item["url"]:
item["source"] = "AtCoder"
elif "cses.fi" in item["url"]:
item["source"] = "CSES"
elif "codechef.com" in item["url"]:
item["source"] = "Codechef"
elif "codeforces" in item["url"]:
item["source"] = "Codeforces"
elif "szkopul.edu.pl" in item["url"]:
item["source"] = "SZKOPUL"
elif "spoj.com" in item["url"]:
item["source"] = "SPOJ"
elif "customSource" in item:
item["source"] = item["customSource"]
else:
item["source"] = "Other"
# news context
news_context = {"posts":posts}
# curriculum context
curriculum_context = {"meeting_problems":problems}
# generate site files
site = Site.make_site(contexts=[("news.html",news_context),("curriculum.html",curriculum_context)],searchpath="templates",outpath="output",staticpaths=["static/"])
# enable automatic reloading
site.render()