-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
38 lines (24 loc) · 1020 Bytes
/
index.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
import markdown
import os
import datetime
import logger
import markdown_homepage_break
import markdown_frontpage
hpbext = markdown_homepage_break.makeExtension({'trim': True})
fpext = markdown_frontpage.makeExtension()
def generate_index (projects, jinja_env):
index_tmpl = jinja_env.get_template('index.html')
index_item_tmpl = jinja_env.get_template('index_proj_item.html')
footer_tmpl = jinja_env.get_template('footer.html')
projects_html = ''
proj_list = []
right = True
for project in projects.getList():
project.project['content'] = markdown.markdown(project.project['md'], extensions=[hpbext, fpext])
projects_html += index_item_tmpl.render(project=project.project, paths=project.paths, right=right)
if right: right = False
else: right = True
proj_list.append(project.project)
html = index_tmpl.render(projects=projects_html, proj_list=proj_list, footer=footer_tmpl.render(curr_year=datetime.datetime.now().year))
with open('docs/index.html', 'w') as f:
f.write(html)