diff options
author | mjfernez <mjf@mjfer.net> | 2022-03-13 15:21:11 -0400 |
---|---|---|
committer | mjfernez <mjf@mjfer.net> | 2022-03-13 15:21:11 -0400 |
commit | 94f71d6f8fc7301dfd470ccf2fee27e078321a78 (patch) | |
tree | 4a6864a043f764dd01e9d5c288ebb70b9be45abb /view_functions.py | |
parent | 150b9695fdb0ebfeca0f8d5b268249bea46ea3f3 (diff) | |
download | ezcms-94f71d6f8fc7301dfd470ccf2fee27e078321a78.tar.gz |
Pull changes from mjfer.net
This commit adds the changes from the mjfer.net which enable using git
as the file last update tracker
Diffstat (limited to 'view_functions.py')
-rw-r--r-- | view_functions.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/view_functions.py b/view_functions.py index 3de8687..4163c2e 100644 --- a/view_functions.py +++ b/view_functions.py @@ -3,8 +3,8 @@ view_functions.py - defines functions called by views to display the correct dat about files and paths. """ import os -from time import ctime -from siteconfig import siteconfig +import subprocess +from siteconfig import siteconfig, config def default_context(): @@ -20,7 +20,18 @@ def default_context(): def file_last_modified(path): - return ctime(os.stat(path).st_mtime) + git_time = f"git log -n1 --pretty=%aD {path}".split() + try: + mod_time = subprocess.check_output( + git_time, cwd=config.BASE_DIR + ) + except: + # File is not in the git log, no biggie, just blank the date + return None + + # Git outputs in RFC2822 format + return mod_time.decode('ascii').strip() + def index_dir(path): """ |