/
views.py
71 lines (54 loc) · 1.93 KB
/
views.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
from flask import render_template
from app import app, pages
from functions import *
import os
# functions are imported in main.py to avoid circular imports
# Index Page
@app.route('/')
def home():
pages = get_pages()
projects,n,m = get_data()
return render_template('index.html',projects=projects, n=n, m=m, page=pages[0])
# Blog Roll
@app.route('/blog/')
def blog():
projects,n,m = get_data()
pages = get_pages()
return render_template('blog.html', pages=pages, projects=projects, n=n, m=m)
# Single blog page
@app.route('/pages/<path>/')
def page(path):
projects,n,m = get_data()
# Path is the filename of a page, without the file extension
# e.g. "welcome.md" --> "welcome"
page = pages.get_or_404(path)
return render_template('page.html', page=page, projects=projects, n=n, m=m)
# Project page
@app.route('/project/<name>/')
def project(name):
projects,n,m = get_data()
df = get_project_df()
project = df[df.markdown_tag == name]
# If the template file exists
#if os.path.exists("templates/%s.html" %(name)):
# Note - this is disabled because it ran into trouble on freezing
page = "%s.html" %(name)
#else:
# page = "project.html"
return render_template(page, projects=projects, n=n, m=m,
project=project["name"].tolist()[0],
classname=project["class"].tolist()[0],
url=project["url"].tolist()[0],
github=project["github"].tolist()[0])
@app.route('/help/')
def help():
projects,n,m = get_data()
return render_template('help.html', projects=projects, n=n, m=m)
@app.route('/conduct/')
def conduct():
projects,n,m = get_data()
return render_template('conduct.html', projects=projects, n=n, m=m)
@app.route('/contribute/')
def contribute():
projects,n,m = get_data()
return render_template('contribute.html', projects=projects, n=n, m=m)