Added basic params support : Number of articles on index page + blog title.
Still problems to work on, see TODO. Added CSS support.
This commit is contained in:
parent
1e7dcbf6a2
commit
2447c12e3f
2
TODO
2
TODO
@ -1,10 +1,10 @@
|
|||||||
Finish gen.py -> RSS
|
Finish gen.py -> RSS
|
||||||
Recherche ?
|
Recherche ?
|
||||||
Pages par années / mois
|
Pages par années / mois
|
||||||
PARAMS
|
|
||||||
images etc.
|
images etc.
|
||||||
Ignorer articles (en cours de rédaction)
|
Ignorer articles (en cours de rédaction)
|
||||||
What happen when a file is moved with git ?
|
What happen when a file is moved with git ?
|
||||||
|
Flake8 the whole thing ! :)
|
||||||
|
|
||||||
Known bugs :
|
Known bugs :
|
||||||
===========
|
===========
|
||||||
|
@ -36,7 +36,7 @@ def latest_articles(directory, number):
|
|||||||
latest_articles = []
|
latest_articles = []
|
||||||
|
|
||||||
for i in range(int(now.strftime('%Y')), 0, -1):
|
for i in range(int(now.strftime('%Y')), 0, -1):
|
||||||
if counter>=25:
|
if counter>=number:
|
||||||
break
|
break
|
||||||
|
|
||||||
if os.path.isdir(directory+"/"+str(i)):
|
if os.path.isdir(directory+"/"+str(i)):
|
||||||
@ -52,7 +52,7 @@ def latest_articles(directory, number):
|
|||||||
if len(latest_articles) < number-counter:
|
if len(latest_articles) < number-counter:
|
||||||
counter+=len(articles_list)
|
counter+=len(articles_list)
|
||||||
else:
|
else:
|
||||||
counter=25
|
counter=number
|
||||||
|
|
||||||
#Delete directory in file names
|
#Delete directory in file names
|
||||||
return latest_articles
|
return latest_articles
|
||||||
@ -72,6 +72,13 @@ try:
|
|||||||
except:
|
except:
|
||||||
sys.exit("[ERROR] An error occured when running git diff.")
|
sys.exit("[ERROR] An error occured when running git diff.")
|
||||||
|
|
||||||
|
#Set parameters
|
||||||
|
with open("raw/params", "r") as params_fh:
|
||||||
|
params = {}
|
||||||
|
for line in params_fh.readlines():
|
||||||
|
option, value = line.split("=", 1)
|
||||||
|
params[option.strip()] = value.strip()
|
||||||
|
|
||||||
#Fill lists for modified, deleted and added files
|
#Fill lists for modified, deleted and added files
|
||||||
modified_files = []
|
modified_files = []
|
||||||
deleted_files = []
|
deleted_files = []
|
||||||
@ -271,7 +278,6 @@ try:
|
|||||||
header = header_fh.read()
|
header = header_fh.read()
|
||||||
tags_header = "<ul>"
|
tags_header = "<ul>"
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
print(tag)
|
|
||||||
tags_header += "<li><a href=\""+tag[4:-4]+".html\">"+tag[9:-4]+"</a></li>"
|
tags_header += "<li><a href=\""+tag[4:-4]+".html\">"+tag[9:-4]+"</a></li>"
|
||||||
tags_header += "</ul>"
|
tags_header += "</ul>"
|
||||||
header = header.replace("@categories", tags_header, 1)
|
header = header.replace("@categories", tags_header, 1)
|
||||||
@ -327,7 +333,7 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
#Regenerate index file
|
#Regenerate index file
|
||||||
last_25_articles = latest_articles("gen/blog/2013/06/test.html", 25)
|
last_25_articles = latest_articles("gen/", int(params["NB_ARTICLES_INDEX"]))
|
||||||
try:
|
try:
|
||||||
auto_dir("blog/index.html")
|
auto_dir("blog/index.html")
|
||||||
with open("blog/index.html", "w") as index_fh:
|
with open("blog/index.html", "w") as index_fh:
|
||||||
|
Loading…
Reference in New Issue
Block a user