Bug correction
Correction of a bug that prevented correct generation of index.html by year. Articles are now sorted by date in month and year index pages.
This commit is contained in:
parent
dd39ba0c47
commit
a74f4f3feb
2
TODO
2
TODO
@ -1,4 +1,3 @@
|
||||
Search ?
|
||||
What happen when a file is moved with git ?
|
||||
Flake8 the whole thing ! :)
|
||||
basepath ?
|
||||
@ -6,5 +5,4 @@ tags / smileys / ...
|
||||
|
||||
Known bugs:
|
||||
==========
|
||||
* Articles in page by month and page by year are not sorted by date
|
||||
* Test RSS in Firefox (different view than traditionnal RSS view ?)
|
||||
|
@ -79,6 +79,7 @@ try:
|
||||
except getopt.GetoptError:
|
||||
sys.exit("Error while parsing command line arguments. See pre-commit -h for more infos on how to use.")
|
||||
|
||||
force_regen = False
|
||||
for opt, arg in opts:
|
||||
if opt in ("-h", "--help"):
|
||||
print("Usage :")
|
||||
@ -90,8 +91,6 @@ for opt, arg in opts:
|
||||
sys.exit(0)
|
||||
elif opt in ("-f", "--force-regen"):
|
||||
force_regen = True
|
||||
else:
|
||||
force_regen = False
|
||||
|
||||
#Set parameters
|
||||
with open("raw/params", "r") as params_fh:
|
||||
@ -487,7 +486,9 @@ with open("gen/header.gen", "r") as header_gen_fh:
|
||||
with open("gen/footer.gen", "r") as footer_gen_fh:
|
||||
footer_gen = footer_gen_fh.read()
|
||||
|
||||
for i in os.listdir("blog/"):
|
||||
years_list = os.listdir("blog/")
|
||||
years_list.sort(reverse=True)
|
||||
for i in years_list:
|
||||
try:
|
||||
int(i)
|
||||
except ValueError:
|
||||
@ -496,18 +497,23 @@ for i in os.listdir("blog/"):
|
||||
#Generate page per year
|
||||
page_year = header_gen.replace("@titre", params["BLOG_TITLE"]+" - "+i, 1)
|
||||
|
||||
for j in os.listdir("blog/"+i):
|
||||
if not os.path.isdir(j):
|
||||
months_list = os.listdir("blog/"+i)
|
||||
months_list.sort(reverse=True)
|
||||
for j in months_list:
|
||||
if not os.path.isdir("blog/"+i+"/"+j):
|
||||
continue
|
||||
|
||||
#Generate pages per month
|
||||
page_month = header_gen.replace("@titre", params["BLOG_TITLE"]+" - "+i+"/"+j, 1)
|
||||
|
||||
for article in list_directory("gen/"+i+"/"+j): # TODO : Sort by date
|
||||
articles_list = list_directory("gen/"+i+"/"+j)
|
||||
articles_list.sort(key=lambda x: os.stat(x).st_mtime, reverse=True)
|
||||
for article in articles_list:
|
||||
try:
|
||||
with open(article, "r") as article_fh:
|
||||
page_month += article_fh.read()
|
||||
page_year += article_fh.read()
|
||||
article_content = article_fh.read()
|
||||
page_month += article_content
|
||||
page_year += article_content
|
||||
except IOError:
|
||||
sys.exit("[ERROR] Error while generating years and months pages. Check your gen folder, you may need to regenerate some articles. The error was due to "+article+".")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user