From 1e7dcbf6a2c19c702753c89d6a8b8c1fc5cef438 Mon Sep 17 00:00:00 2001 From: Phyks Date: Sun, 21 Jul 2013 23:39:23 +0200 Subject: [PATCH] Added CSS handling and corrected an error with the cleaning of (added|modified|deleted)_files lists --- TODO | 7 ++++++- pre-commit.py | 20 +++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 2c78b07..032bb42 100644 --- a/TODO +++ b/TODO @@ -2,6 +2,11 @@ Finish gen.py -> RSS Recherche ? Pages par années / mois PARAMS -CSS +images etc. Ignorer articles (en cours de rédaction) What happen when a file is moved with git ? + +Known bugs : +=========== +On article / tag pages : links are relative and don't work +@titre not remplaced diff --git a/pre-commit.py b/pre-commit.py index c4da937..5d21a7b 100755 --- a/pre-commit.py +++ b/pre-commit.py @@ -95,6 +95,7 @@ for changed_file in changes: for filename in list(added_files): if filename[:4] != "raw/": added_files.remove(filename) + continue try: int(filename[4:8]) @@ -104,6 +105,7 @@ for filename in list(added_files): for filename in list(modified_files): if filename[:4] != "raw/": modified_files.remove(filename) + continue try: int(filename[4:6]) @@ -113,6 +115,7 @@ for filename in list(modified_files): for filename in list(deleted_files): if filename[:4] != "raw/": deleted_files.remove(filename) + continue try: int(filename[4:6]) @@ -268,6 +271,7 @@ try: header = header_fh.read() tags_header = "" header = header.replace("@categories", tags_header, 1) @@ -312,8 +316,18 @@ try: except IOError: sys.exit("[ERROR] Unable to copy the footer.html file.") +#Copy CSS files +if not os.path.isfile("raw/css") or list_directory("raw/css") == []: + print("[INFO] (CSS) No CSS files in raw/css folder") +else: + try: + shutil.copytree("raw/css", "blog/css") + except IOError: + sys.exit("[ERROR] An error occured while copying css files.") + + #Regenerate index file -last_25_articles = latest_articles("gen/", 25) +last_25_articles = latest_articles("gen/blog/2013/06/test.html", 25) try: auto_dir("blog/index.html") with open("blog/index.html", "w") as index_fh: @@ -336,7 +350,7 @@ except IOError: for tag in list_directory("gen/tags"): try: auto_dir(tag.replace("gen/", "blog/")) - with open(tag.replace("gen/", "blog/"), "w") as tag_fh: + with open(tag.replace("gen/", "blog/")[:-4]+".html", "w") as tag_fh: with open(tag, "r") as tag_gen_fh: with open("gen/header.gen", "r") as header_fh: tag_content = header_fh.read() @@ -349,7 +363,7 @@ for tag in list_directory("gen/tags"): with open("gen/footer.gen", "r") as footer_handler: tag_content += footer_handler.read() tag_fh.write(tag_content) - print("[INFO] (TAGS) Tag page for "+tag+" has been generated successfully.") + print("[INFO] (TAGS) Tag page for "+tag[9:-4]+" has been generated successfully.") except IOError: sys.exit("[ERROR] An error occured while generating tag page \""+tag[9:-4]+"\"")