commented routes

small-nav
Mimi Momo 4 years ago
parent 97a963172c
commit 6cf06dc3d7

@ -125,12 +125,11 @@ def snip_article(article, path):
limit = 300 limit = 300
result = article[0:min(len(article),limit)] result = article[0:min(len(article),limit)]
result = result.rsplit(' ',1)[0] result = result.rsplit(' ',1)[0]
# cut off after 5 lines, too?
return result + " ... " return result + " ... "
def sort_files(files): def sort_files(files):
files.sort(reverse=True) files.sort(reverse=True)
return files#list(reversed(files)) return files
def gather_files(loc): def gather_files(loc):
files = os.listdir(loc) files = os.listdir(loc)
@ -140,26 +139,31 @@ def gather_files(loc):
files.remove('extra') files.remove('extra')
return files return files
# Static ## Static ##
# Serve CSS
@route('/static/css/<filename:path>') @route('/static/css/<filename:path>')
def serve_css(filename): def serve_css(filename):
return static_file(filename, root='static/css') return static_file(filename, root='static/css')
# Serve images
@route('/static/img/<filename:path>') @route('/static/img/<filename:path>')
def serve_img(filename): def serve_img(filename):
return static_file(filename, root='static/img') return static_file(filename, root='static/img')
# Serve unlisted articles
@route('/static/extra/<filename:re:.*\.cpp>') @route('/static/extra/<filename:re:.*\.cpp>')
def serve_extra(filename): def serve_extra(filename):
return static_file(filename, root='static/extra', mimetype='text/plain', download=True) return static_file(filename, root='static/extra', mimetype='text/plain', download=True)
# Routes ## Routes ##
# 404 Error Page
@error(404) @error(404)
def error404(error): def error404(error):
return "unfortunately, a 404 error" return "unfortunately, a 404 error"
# Home Page - Index Template
@route('/') @route('/')
def index(): def index():
"""home page""" """home page"""
@ -167,22 +171,26 @@ def index():
info = {'css': 'index', 'news': list_headlines(sort_files(gather_files(loc))[0:10]), 'title': 'chimchooree\'s dev space - blessfrey', 'year': datetime.datetime.now()} info = {'css': 'index', 'news': list_headlines(sort_files(gather_files(loc))[0:10]), 'title': 'chimchooree\'s dev space - blessfrey', 'year': datetime.datetime.now()}
return template('index.tpl', info) return template('index.tpl', info)
# Game Page - Game Template - system, character, story info
@route('/game') @route('/game')
def game(): def game():
"""game page""" """game page"""
info = {'css': 'game', 'title': 'blessfrey - about the game', 'year': datetime.datetime.now()} info = {'css': 'game', 'title': 'blessfrey - about the game', 'year': datetime.datetime.now()}
return template('game.tpl', info) return template('game.tpl', info)
# Presskit Page - Presskit Template - product, developer info
@route('/presskit') @route('/presskit')
def presskit(): def presskit():
"""press page""" """press page"""
info = {'css': 'presskit', 'title': 'blessfrey - presskit', 'year': datetime.datetime.now()} info = {'css': 'presskit', 'title': 'blessfrey - presskit', 'year': datetime.datetime.now()}
return template('presskit.tpl', info) return template('presskit.tpl', info)
# Start on first Diary page if no page given
@route('/diary') @route('/diary')
def diary2(): def diary2():
return diary(0) return diary(0)
# Diary Page - Diary Template - list all articles
@route('/diary/<page:int>') @route('/diary/<page:int>')
def diary(page): def diary(page):
"""diary page""" """diary page"""
@ -191,6 +199,7 @@ def diary(page):
info = {'css': 'diary', 'title': 'blessfrey - developer diary', 'year': datetime.datetime.now(), 'snippets': list_snippets(sort_files(gather_files(loc))), 'latest': list_headlines(sort_files(gather_files(loc))[0:5]), 'total': len(gather_files(loc)), 'limit': 4, 'cluster': 3, 'page': page} info = {'css': 'diary', 'title': 'blessfrey - developer diary', 'year': datetime.datetime.now(), 'snippets': list_snippets(sort_files(gather_files(loc))), 'latest': list_headlines(sort_files(gather_files(loc))[0:5]), 'total': len(gather_files(loc)), 'limit': 4, 'cluster': 3, 'page': page}
return template('diary.tpl', info) return template('diary.tpl', info)
# Entry Page - Feature Template - for articles
@route('/diary/entries/<page:int>') @route('/diary/entries/<page:int>')
def entry(page): def entry(page):
"""diary entry""" """diary entry"""
@ -201,6 +210,7 @@ def entry(page):
TEMPLATE_PATH.insert(0, abs_views_path ) TEMPLATE_PATH.insert(0, abs_views_path )
return template(os.path.join(abs_views_path,'feature.tpl'), info) return template(os.path.join(abs_views_path,'feature.tpl'), info)
# Extra Page - Feature Template - for unlisted articles
@route('/diary/entries/extra/<page>') @route('/diary/entries/extra/<page>')
def extra(page): def extra(page):
"""diary extra""" """diary extra"""
@ -211,18 +221,22 @@ def extra(page):
TEMPLATE_PATH.insert(0, abs_views_path ) TEMPLATE_PATH.insert(0, abs_views_path )
return template(os.path.join(abs_views_path,'feature.tpl'), info) return template(os.path.join(abs_views_path,'feature.tpl'), info)
# Personal Page - Box Template
@route('/box') @route('/box')
def box(): def box():
"""personal page""" """personal page"""
info = {'css': 'box', 'title': 'chimchooree\'s personal page', 'year': datetime.datetime.now()} info = {'css': 'box', 'title': 'chimchooree\'s personal page', 'year': datetime.datetime.now()}
return template('box.tpl', info) return template('box.tpl', info)
# Credits Page - Credits Template
@route('/credits') @route('/credits')
def credits(): def credits():
"""credits page""" """credits page"""
info = {'css': 'box', 'title': 'blessfrey - credits', 'year': datetime.datetime.now()} info = {'css': 'box', 'title': 'blessfrey - credits', 'year': datetime.datetime.now()}
return template('credits.tpl', info) return template('credits.tpl', info)
# Contact Page - Contact Template
@route('/contact') @route('/contact')
def contact(): def contact():
"""contact page""" """contact page"""

Loading…
Cancel
Save