From 6e0226028dc5cf975efe330cae5afcfd8d44c01f Mon Sep 17 00:00:00 2001 From: maste9 Date: Mon, 2 Mar 2015 21:18:49 +0100 Subject: [PATCH] Still dealing with this sorting issue. I must sort the list in any way which it doesn't actually. --- picoblogger/main.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/picoblogger/main.py b/picoblogger/main.py index e546b5b..ad34061 100755 --- a/picoblogger/main.py +++ b/picoblogger/main.py @@ -148,7 +148,8 @@ def parse_article(path): body = markdown.markdown(article.split("HEADER_END")[1]) article_dict = parse_conf(header) article_dict['BODY'] = body - article_dict['MODIFIED'] = time.strftime("%x",time.gmtime(os.stat(path).st_mtime)) + article_dict['MODIFIED_DATE'] = time.strftime("%x",time.gmtime(os.stat(path).st_mtime)) + article_dict['MODIFIED_TIME'] = time.strftime("%H:%M:%S",time.gmtime(os.stat(path).st_mtime)) return article_dict @@ -161,8 +162,10 @@ def article_to_html(article_dict): tplSub = { "ARTICLE_TITLE":article_dict['TITLE'], "ARTICLE_AUTHOR":article_dict['AUTHOR'], - "ARTICLE_CREATED":article_dict['DATE'], - "ARTICLE_MODIFIED":article_dict['MODIFIED'], + "ARTICLE_CREATED_DATE":article_dict['DATE'], + "ARTICLE_CREATED_TIME":article_dict['TIME'], + "ARTICLE_MODIFIED_DATE":article_dict['MODIFIED_DATE'], + "ARTICLE_MODIFIED_TIME":article_dict['MODIFIED_TIME'], "ARTICLE_BODY":article_dict['BODY'], "ARTICLE_TAGS":article_dict['TAGS'] } @@ -176,12 +179,13 @@ def join_articles(): articles_dict = {} for name in [os.path.splitext(item)[0] for item in os.listdir(draftDir) if not "\~" in item]: article = (parse_article(os.path.join(artDir, name + ".txt"))) - time = time.strptime(article['DATE'] + " " + article['time'] - articles_dict[] = article + # Bring articles into chronological order + t = time.mktime(time.strptime(article['DATE'] + " " + article['TIME'],"%m/%d/%y %H:%M:%S")) + articles_dict[str(t)] = article dates_of_creation = [value for value in articles_dict.keys()] print(dates_of_creation) for date in dates_of_creation: - joined_html += article_to_html(articles_dict[date]) + joined_html += article_to_html(articles_dict[str(time.strftime(date))]) return joined_html