diff options
author | Zhiming Wang <zmwangx@gmail.com> | 2015-05-13 15:01:31 -0700 |
---|---|---|
committer | Zhiming Wang <zmwangx@gmail.com> | 2015-05-13 15:06:24 -0700 |
commit | b6d0d727c5be9a5180fb9baf9565fc1768c0ddfe (patch) | |
tree | d0c1efd7d672cc2def8c5f91efb76fef9da87831 /pyblog | |
parent | 4e9325b194f069030c5c192bc3f11c24f1295fd2 (diff) | |
download | my_new_personal_website-b6d0d727c5be9a5180fb9baf9565fc1768c0ddfe.tar.xz my_new_personal_website-b6d0d727c5be9a5180fb9baf9565fc1768c0ddfe.zip |
pyblog: smarter autotouch in gen_deploy
Diffstat (limited to '')
-rwxr-xr-x | pyblog | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -744,13 +744,23 @@ def gen_deploy(args): latest_post = None latest_mtime = 0 for name in os.listdir(POSTSDIR): - if not name.endswith(".md"): + matchobj = re.match(r"^([0-9]{4})-([0-9]{2})-([0-9]{2})-.*\.md", name) + if not matchobj: continue fullpath = os.path.join(POSTSDIR, name) ctime = os.path.getctime(fullpath) mtime = os.path.getmtime(fullpath) - # skip the post if it was created more than three days ago - if current_time - ctime > 3 * 24 * 3600: + # get date registered in the filename, which has the format + # xxxx-xx-xx-blah-blah.md + cdate = datetime.datetime(year=int(matchobj[1]), + month=int(matchobj[2]), + day=int(matchobj[3]), + hour=23, minute=59, second=59, + tzinfo=dateutil.tz.tzlocal()).timestamp() + # skip the post if its source file was created more than three + # days ago, or the date registered in its filename is more than + # three days ago + if max(current_time - ctime, current_time - cdate) > 3 * 24 * 3600: continue if mtime > latest_mtime: latest_post = name |