news on index shows 9 latest headlines as links to their articles
This commit is contained in:
@@ -0,0 +1 @@
|
||||
ancient text
|
||||
@@ -0,0 +1 @@
|
||||
nothing new sorry
|
||||
@@ -0,0 +1 @@
|
||||
1 sample news <b>whoa</b>
|
||||
+18
-9
@@ -6,15 +6,24 @@ from bottle import error, route, run, static_file, template
|
||||
|
||||
# write diary
|
||||
|
||||
def make_latest():
|
||||
# for article in array (just 5 or something)
|
||||
# link to webpage
|
||||
return "latest"
|
||||
def list_headlines(articles):
|
||||
head = count_lines('entries/raw/res/head.txt')
|
||||
result = []
|
||||
text = []
|
||||
|
||||
for article in articles:
|
||||
path = 'entries/' + article
|
||||
|
||||
with open(path) as f:
|
||||
text = f.readlines()
|
||||
|
||||
b = []
|
||||
b.append(path)
|
||||
b.append(clean(text[head].replace('<br>',''), path))
|
||||
result.append(b)
|
||||
return result
|
||||
|
||||
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')
|
||||
@@ -99,7 +108,7 @@ def error404(error):
|
||||
@route('/')
|
||||
def index():
|
||||
"""home page"""
|
||||
info = {'css': 'index', 'news': 'News goes here', 'title': 'chimchooree\'s dev space - blessfrey', 'year': datetime.datetime.now()}
|
||||
info = {'css': 'index', 'news': list_headlines(sort_files(gather_files())[0:10]), 'title': 'chimchooree\'s dev space - blessfrey', 'year': datetime.datetime.now()}
|
||||
return template('index.tpl', info)
|
||||
|
||||
@route('/game')
|
||||
@@ -122,7 +131,7 @@ def diary2():
|
||||
def diary(page):
|
||||
"""diary page"""
|
||||
assert isinstance(page, int)
|
||||
info = {'css': 'diary', 'title': 'blessfrey - developer diary', 'year': datetime.datetime.now(), 'snippets': list_snippets(sort_files(gather_files())), 'latest': make_latest(), 'total': len(gather_files()), 'limit': 4, 'cluster': 3, 'page': page}
|
||||
info = {'css': 'diary', 'title': 'blessfrey - developer diary', 'year': datetime.datetime.now(), 'snippets': list_snippets(sort_files(gather_files())), 'latest': list_headlines(sort_files(gather_files())[0:5]), 'total': len(gather_files()), 'limit': 4, 'cluster': 3, 'page': page}
|
||||
return template('diary.tpl', info)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
+5
-1
@@ -14,7 +14,11 @@
|
||||
<div class="news">
|
||||
<center>. • . <strong>news</strong> ☆ .. . <br></center>
|
||||
<br>
|
||||
{{news}}
|
||||
<ul>
|
||||
% for n in news:
|
||||
<li>★ <a href={{n[0]}}>{{!n[1]}}</a><br></li>
|
||||
% end
|
||||
</ul>
|
||||
<br>
|
||||
<center>. ★ .. • . ☆</center>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user