|
|
|
import datetime, os
|
|
|
|
from bottle import route, run, template
|
|
|
|
|
|
|
|
# diary
|
|
|
|
|
|
|
|
def build_nav():
|
|
|
|
return "nav"
|
|
|
|
|
|
|
|
def make_latest():
|
|
|
|
# for article in array (just 5 or something)
|
|
|
|
# link to webpage
|
|
|
|
return "latest"
|
|
|
|
|
|
|
|
def list_snippets(articles):
|
|
|
|
# take articles between 0-4, 5-8, 9-13,...) based on current page
|
|
|
|
# for each one of those articles,
|
|
|
|
# snip_article(article)
|
|
|
|
limit = 4
|
|
|
|
total = len(articles)
|
|
|
|
head = count_lines('entries/raw/res/head.txt')
|
|
|
|
result = []
|
|
|
|
|
|
|
|
for article in articles:
|
|
|
|
text = []
|
|
|
|
a = []
|
|
|
|
|
|
|
|
with open('entries/feature/' + article) as f:
|
|
|
|
text = f.readlines()
|
|
|
|
|
|
|
|
a.append(text[head])
|
|
|
|
a.append(snip_article("words words words"))
|
|
|
|
a.append("11/22/33")
|
|
|
|
a.append("social")
|
|
|
|
a.append("link")
|
|
|
|
result.append(a)
|
|
|
|
return result
|
|
|
|
|
|
|
|
def count_lines(fname):
|
|
|
|
with open(fname) as f:
|
|
|
|
for linenum, line in enumerate(f,1):
|
|
|
|
pass
|
|
|
|
return linenum
|
|
|
|
|
|
|
|
def snip_article(article):
|
|
|
|
# read text in article
|
|
|
|
# clean 250 first characters
|
|
|
|
# add to snippet
|
|
|
|
# add "read more" button that links to article to snippet
|
|
|
|
return article
|
|
|
|
|
|
|
|
def sort_files(files):
|
|
|
|
# sort array so articles are latest to earliest
|
|
|
|
m = list(reversed(files))
|
|
|
|
return files
|
|
|
|
|
|
|
|
def gather_files():
|
|
|
|
# directory to list
|
|
|
|
return os.listdir('entries/feature/')
|
|
|
|
|
|
|
|
# Webpages
|
|
|
|
|
|
|
|
@route('/')
|
|
|
|
def index():
|
|
|
|
"""home page"""
|
|
|
|
info = {'news': 'News goes here', 'title': 'chimchooree\'s dev space - blessfrey', 'year': datetime.datetime.now()}
|
|
|
|
return template('index.tpl', info)
|
|
|
|
|
|
|
|
@route('/game')
|
|
|
|
def game():
|
|
|
|
"""game page"""
|
|
|
|
info = {'title': 'blessfrey - about the game', 'year': datetime.datetime.now()}
|
|
|
|
return template('game.tpl', info)
|
|
|
|
|
|
|
|
@route('/presskit')
|
|
|
|
def presskit():
|
|
|
|
"""press page"""
|
|
|
|
info = {'title': 'blessfrey - presskit', 'year': datetime.datetime.now()}
|
|
|
|
return template('presskit.tpl', info)
|
|
|
|
|
|
|
|
@route('/diary')
|
|
|
|
def diary():
|
|
|
|
"""diary page"""
|
|
|
|
info = {'title': 'blessfrey - about the game', 'year': datetime.datetime.now(), 'snippets': list_snippets(sort_files(gather_files())), 'latest': make_latest()}
|
|
|
|
return template('diary.tpl', info)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
run()
|