From 5b7dad4a7856bf3aba635727d56dfcd4137479b1 Mon Sep 17 00:00:00 2001 From: Phyks Date: Mon, 22 Jul 2013 11:13:34 +0200 Subject: [PATCH] Not HTML files + Not published articles Added the ability to handle not HTML files (such as images, directly copied in the blog folder) and not published articles (by the use of .ignore extension in filename) --- TODO | 2 -- pre-commit.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index cc16539..64fde97 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ Finish gen.py -> RSS Recherche ? Pages par années / mois -images etc. -Ignorer articles (en cours de rédaction) What happen when a file is moved with git ? Flake8 the whole thing ! :) diff --git a/pre-commit.py b/pre-commit.py index 05361c6..bd9a6e9 100755 --- a/pre-commit.py +++ b/pre-commit.py @@ -108,6 +108,19 @@ for filename in list(added_files): int(filename[4:8]) except ValueError: added_files.remove(filename) + continue + + if filename[-4:] != "html" and filename[-6:] != "ignore": + print("[INFO] (Not HTML file) Copying directly not html file "+filename[4:]+" to blog dir.") + auto_dir("blog/"+filename[4:]) + shutil.copy(filename, "blog/"+filename[4:]) + added_files.remove(filename) + continue + + if filename[-6:] == "ignore": + print("[INFO] (Not published) Found not published article "+filename[4:-7]+".") + added_files.remove(filename) + continue for filename in list(modified_files): if filename[:4] != "raw/": @@ -118,6 +131,19 @@ for filename in list(modified_files): int(filename[4:6]) except ValueError: modified_files.remove(filename) + continue + + if filename[-4:] != "html" and filename[-6:] != "ignore": + print("[INFO] (Not HTML file) Updating directly not html file "+filename[4:]+" to blog dir.") + auto_dir("blog/"+filename[4:]) + shutil.copy(filename, "blog/"+filename[4:]) + modified_files.remove(filename) + continue + + if filename[-6:] == "ignore": + print("[INFO] (Not published) Found not published article "+filename[4:-7]+".") + added_files.remove(filename) + continue for filename in list(deleted_files): if filename[:4] != "raw/": @@ -128,7 +154,19 @@ for filename in list(deleted_files): int(filename[4:6]) except ValueError: deleted_files.remove(filename) + continue + if filename[-4:] != "html" and filename[-6:] != "ignore": + print("[INFO] (Not HTML file) Copying directly not html file "+filename[4:]+" to blog dir.") + auto_dir("blog/"+filename[4:]) + shutil.copy(filename, "blog/"+filename[4:]) + deleted_files.remove(filename) + continue + + if filename[-6:] == "ignore": + print("[INFO] (Not published) Found not published article "+filename[4:-7]+".") + added_files.remove(filename) + continue print("[INFO] Added files : "+", ".join(added_files))