From 0c7b9e61725b26ce95aa9e24f9eec61d1495a80e Mon Sep 17 00:00:00 2001 From: TiynGER Date: Wed, 27 May 2020 14:38:46 +0200 Subject: [PATCH] adding dates to archive --- README.md | 17 ++++++++++------- src/content.py | 7 +++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index eacbe57..9a77658 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,21 @@ This is a simple blog based on Pythons Flask framework. ## Features/To-Dos - [x] Plain text support for blog entries - - [x] HTML files (.html) - - [x] Markdown Files (.md) + - [x] HTML files (.html) + - [x] Markdown Files (.md) - [x] Infinite-scroll blog page - [x] Archive page - - [ ] Months as headings + - [x] Months as headings + - [x] Links to scrolling blog page + - [ ] Links to standalone article +- [ ] Standalone article page - [x] RSS feed - [ ] Better navigation - - [ ] Header - - [ ] Footer + - [ ] Header + - [ ] Footer - [ ] Switchable CSS - - [ ] CSS dark-theme - - [ ] CSS light-theme + - [ ] CSS dark-theme + - [ ] CSS light-theme - [x] Docker installation ## Usage diff --git a/src/content.py b/src/content.py index 651b1f0..e6c69a1 100644 --- a/src/content.py +++ b/src/content.py @@ -17,12 +17,19 @@ def gen_arch_string(): full_list = [os.path.join(path_ex, i) for i in name_list] contents = sorted(full_list, key=os.path.getctime) content_string = '' + last_month = '' for file in reversed(contents): + curr_date = datetime.fromtimestamp(os.path.getctime(file)).strftime('%Y-%m-%d') + curr_month = datetime.fromtimestamp(os.path.getctime(file)).strftime('%b %Y') + if curr_month != last_month: + content_string += '

' + curr_month + '

' + last_month = curr_month filename = pathlib.PurePath(file) title = open(filename).readline().rstrip('\n') filename = filename.name if filename[0] != '.': filename = filename.split('.', 1)[0] + content_string += curr_date + ' - ' content_string += '' + title + '
\n' return content_string