aboutsummaryrefslogtreecommitdiff
path: root/pyblog
diff options
context:
space:
mode:
authorZhiming Wang <zmwangx@gmail.com>2015-07-17 11:48:37 -0700
committerZhiming Wang <zmwangx@gmail.com>2015-07-17 11:48:37 -0700
commite37944f4a78ba4d2695eeec75b25b1c20aeef933 (patch)
tree446f32cc6e1b8b50c158901d3fdceb9f01d632b6 /pyblog
parent2adbde845c778e34b140f514bc2dac09688b97e8 (diff)
downloadmy_new_personal_website-e37944f4a78ba4d2695eeec75b25b1c20aeef933.tar.xz
my_new_personal_website-e37944f4a78ba4d2695eeec75b25b1c20aeef933.zip
take generator source modification time into account
Regenerate a page if the generator mtime is later than the page's mtime (just like for the template). Previewer still should be relaunched after modification to the generator, since the generator won't be patched until the next run.
Diffstat (limited to '')
-rwxr-xr-xpyblog5
1 files changed, 4 insertions, 1 deletions
diff --git a/pyblog b/pyblog
index 8817d5e4..6cb0db90 100755
--- a/pyblog
+++ b/pyblog
@@ -58,6 +58,7 @@ ROOTDIR = os.path.dirname(os.path.realpath(__file__))
SOURCEDIR = os.path.join(ROOTDIR, "source")
POSTSDIR = os.path.join(SOURCEDIR, "blog")
INDEXMD = os.path.join(SOURCEDIR, "index.md")
+GENERATORSOURCE = os.path.join(ROOTDIR, "pyblog")
TEMPLATEDIR = os.path.join(ROOTDIR, "templates")
HTMLTEMPLATE = os.path.join(TEMPLATEDIR, "template.html")
BUILDDIR = os.path.join(ROOTDIR, "build")
@@ -659,7 +660,9 @@ def generate_blog(fresh=False, report_total_errors=True):
pass
failed_builds = 0
+ generator_mtime = os.path.getmtime(GENERATORSOURCE)
template_mtime = os.path.getmtime(HTMLTEMPLATE)
+ fundamental_mtime = max(generator_mtime, template_mtime)
anything_modified = False
for root, _, files in os.walk(SOURCEDIR):
@@ -685,7 +688,7 @@ def generate_blog(fresh=False, report_total_errors=True):
dstpath = os.path.join(dstroot, name)
if ((not os.path.exists(dstpath) or
os.path.getmtime(dstpath) <=
- max(template_mtime, os.path.getmtime(srcpath)))):
+ max(fundamental_mtime, os.path.getmtime(srcpath)))):
# new post or modified post
anything_modified = True
if srcpath == INDEXMD: