From 04f23c4e29d92cfa744479ceed484ad046d60ba9 Mon Sep 17 00:00:00 2001 From: chimchooree Date: Thu, 1 Oct 2020 18:37:38 -0500 Subject: [PATCH] diary nav shows 3 preceding and 3 suceding numbers --- src/index.py | 38 +++++++------------------------------- src/views/diary.tpl | 10 +++++++++- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/index.py b/src/index.py index f68c88e..084da62 100644 --- a/src/index.py +++ b/src/index.py @@ -6,34 +6,6 @@ from bottle import error, route, run, static_file, template # write diary -def build_nav(): - nav = "nav" - return nav - -#function build_nav($page, $total) { - # echo '
'; - - # $limit = 4; - - # $min = max($page - $limit, 0); - #$max = min($page + $limit, $total); -# if($min > 0) { - # echo "first"; - # } - # for($i = $min; $i < $max; $i++) { - # if ($i == $page) { - # echo "$i"; - # } else { - # echo "$i"; - #} -# } - # if($max < $total) { - # $t = $total - 1; - # echo "last"; - #} -# echo '
'; -#} - def make_latest(): # for article in array (just 5 or something) # link to webpage @@ -115,7 +87,7 @@ def serve_css(filename): return static_file(filename, root='static/css') @route('/static/img/') -def serve_css(filename): +def serve_img(filename): return static_file(filename, root='static/img') # Routes @@ -143,9 +115,13 @@ def presskit(): return template('presskit.tpl', info) @route('/diary') -def diary(): +def diary2(): + return diary(0) + +@route('/diary/') +def diary(page): """diary page""" - info = {'css': 'diary', 'title': 'blessfrey - about the game', 'year': datetime.datetime.now(), 'snippets': list_snippets(sort_files(gather_files())), 'latest': make_latest(), 'nav': build_nav()} + info = {'css': 'diary', 'title': 'blessfrey - about the game', 'year': datetime.datetime.now(), 'snippets': list_snippets(sort_files(gather_files())), 'latest': make_latest(), 'total': len(gather_files()), 'limit': 3, 'page': page} return template('diary.tpl', info) if __name__ == '__main__': diff --git a/src/views/diary.tpl b/src/views/diary.tpl index 80d0e0a..78ec87a 100644 --- a/src/views/diary.tpl +++ b/src/views/diary.tpl @@ -2,7 +2,15 @@
- {{nav}} + % for i in range(max(0,page - limit), min(total,page + limit)): + % if i == page: + + % end + {{i}} + % if i == page: + + % end + % end