diff options
author | Zhiming Wang <zmwangx@gmail.com> | 2015-07-17 11:48:37 -0700 |
---|---|---|
committer | Zhiming Wang <zmwangx@gmail.com> | 2015-07-17 11:48:37 -0700 |
commit | e37944f4a78ba4d2695eeec75b25b1c20aeef933 (patch) | |
tree | 446f32cc6e1b8b50c158901d3fdceb9f01d632b6 /pyblog | |
parent | 2adbde845c778e34b140f514bc2dac09688b97e8 (diff) | |
download | my_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 'pyblog')
-rwxr-xr-x | pyblog | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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: |