diff --git a/TODO b/TODO index 032bb42..cc16539 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,10 @@ Finish gen.py -> RSS Recherche ? Pages par années / mois -PARAMS images etc. Ignorer articles (en cours de rédaction) What happen when a file is moved with git ? +Flake8 the whole thing ! :) Known bugs : =========== diff --git a/pre-commit.py b/pre-commit.py index 5d21a7b..05361c6 100755 --- a/pre-commit.py +++ b/pre-commit.py @@ -36,7 +36,7 @@ def latest_articles(directory, number): latest_articles = [] for i in range(int(now.strftime('%Y')), 0, -1): - if counter>=25: + if counter>=number: break if os.path.isdir(directory+"/"+str(i)): @@ -52,7 +52,7 @@ def latest_articles(directory, number): if len(latest_articles) < number-counter: counter+=len(articles_list) else: - counter=25 + counter=number #Delete directory in file names return latest_articles @@ -72,6 +72,13 @@ try: except: 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 modified_files = [] deleted_files = [] @@ -271,7 +278,6 @@ try: header = header_fh.read() tags_header = "" header = header.replace("@categories", tags_header, 1) @@ -327,7 +333,7 @@ else: #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: auto_dir("blog/index.html") with open("blog/index.html", "w") as index_fh: