Still dealing with this sorting issue. I must sort the list in any way which it doesn't actually.

This commit is contained in:
maste9 2015-03-02 21:18:49 +01:00 committed by Homer S
parent f3169226c2
commit 6e0226028d
1 changed files with 10 additions and 6 deletions

View File

@ -148,7 +148,8 @@ def parse_article(path):
body = markdown.markdown(article.split("HEADER_END")[1]) body = markdown.markdown(article.split("HEADER_END")[1])
article_dict = parse_conf(header) article_dict = parse_conf(header)
article_dict['BODY'] = body 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 return article_dict
@ -161,8 +162,10 @@ def article_to_html(article_dict):
tplSub = { tplSub = {
"ARTICLE_TITLE":article_dict['TITLE'], "ARTICLE_TITLE":article_dict['TITLE'],
"ARTICLE_AUTHOR":article_dict['AUTHOR'], "ARTICLE_AUTHOR":article_dict['AUTHOR'],
"ARTICLE_CREATED":article_dict['DATE'], "ARTICLE_CREATED_DATE":article_dict['DATE'],
"ARTICLE_MODIFIED":article_dict['MODIFIED'], "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_BODY":article_dict['BODY'],
"ARTICLE_TAGS":article_dict['TAGS'] "ARTICLE_TAGS":article_dict['TAGS']
} }
@ -176,12 +179,13 @@ def join_articles():
articles_dict = {} articles_dict = {}
for name in [os.path.splitext(item)[0] for item in os.listdir(draftDir) if not "\~" in item]: 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"))) article = (parse_article(os.path.join(artDir, name + ".txt")))
time = time.strptime(article['DATE'] + " " + article['time'] # Bring articles into chronological order
articles_dict[] = article 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()] dates_of_creation = [value for value in articles_dict.keys()]
print(dates_of_creation) print(dates_of_creation)
for date in 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 return joined_html