Page generation for year / months left ro refactor
This commit is contained in:
parent
8925a3af68
commit
74102b2a08
@ -637,14 +637,7 @@ for filename in added_files+modified_files:
|
|||||||
sys.exit("[ERROR] An error occurred while generating article " +
|
sys.exit("[ERROR] An error occurred while generating article " +
|
||||||
filename[4:]+" page.")
|
filename[4:]+" page.")
|
||||||
|
|
||||||
#======================================
|
# Regenerate page for years / months
|
||||||
# Generate pages for each year and month
|
|
||||||
with open("gen/header.gen", "r") as header_gen_fh:
|
|
||||||
header_gen = header_gen_fh.read()
|
|
||||||
|
|
||||||
with open("gen/footer.gen", "r") as footer_gen_fh:
|
|
||||||
footer_gen = footer_gen_fh.read()
|
|
||||||
|
|
||||||
years_list = os.listdir("blog/")
|
years_list = os.listdir("blog/")
|
||||||
years_list.sort(reverse=True)
|
years_list.sort(reverse=True)
|
||||||
for i in years_list:
|
for i in years_list:
|
||||||
@ -654,7 +647,7 @@ for i in years_list:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# Generate page per year
|
# Generate page per year
|
||||||
page_year = header_gen.replace("@title", params["BLOG_TITLE"]+" - "+i, 1)
|
page_year = header.replace("@title", params["BLOG_TITLE"]+" - "+i, 1)
|
||||||
|
|
||||||
months_list = os.listdir("blog/"+i)
|
months_list = os.listdir("blog/"+i)
|
||||||
months_list.sort(reverse=True)
|
months_list.sort(reverse=True)
|
||||||
@ -663,7 +656,7 @@ for i in years_list:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# Generate pages per month
|
# Generate pages per month
|
||||||
page_month = header_gen.replace("@title", params["BLOG_TITLE"]+" - "+i+"/"+j, 1)
|
page_month = header.replace("@title", params["BLOG_TITLE"]+" - "+i+"/"+j, 1)
|
||||||
|
|
||||||
articles_list = list_directory("gen/"+i+"/"+j)
|
articles_list = list_directory("gen/"+i+"/"+j)
|
||||||
articles_list.sort(key=lambda x: os.stat(x).st_mtime, reverse=True)
|
articles_list.sort(key=lambda x: os.stat(x).st_mtime, reverse=True)
|
||||||
@ -676,14 +669,14 @@ for i in years_list:
|
|||||||
except IOError:
|
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+".")
|
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+".")
|
||||||
|
|
||||||
page_month += footer_gen
|
page_month += footer
|
||||||
try:
|
try:
|
||||||
with open("blog/"+i+"/"+j+"/index.html", "w") as page_month_fh:
|
with open("blog/"+i+"/"+j+"/index.html", "w") as page_month_fh:
|
||||||
page_month_fh.write(page_month)
|
page_month_fh.write(page_month)
|
||||||
except IOError:
|
except IOError:
|
||||||
sys.exit("[ERROR] Unable to write index file for "+i+"/"+j+".")
|
sys.exit("[ERROR] Unable to write index file for "+i+"/"+j+".")
|
||||||
|
|
||||||
page_year += footer_gen
|
page_year += footer
|
||||||
try:
|
try:
|
||||||
with open("blog/"+i+"/index.html", "w") as page_year_fh:
|
with open("blog/"+i+"/index.html", "w") as page_year_fh:
|
||||||
page_year_fh.write(page_year)
|
page_year_fh.write(page_year)
|
||||||
|
Loading…
Reference in New Issue
Block a user