aboutsummaryrefslogtreecommitdiffstats
path: root/view_functions.py
diff options
context:
space:
mode:
authormjfernez <mjf@mjfer.net>2022-03-10 18:34:22 -0500
committermjfernez <mjf@mjfer.net>2022-03-10 18:34:22 -0500
commitc0be486968fe3d375d1f408eae7f954e1f5f82fc (patch)
treed5fac6cc4a8d129275bde64498b0e6662d4d47fe /view_functions.py
parentf335ff5265a96fdc0b9e0e9d8e4384f866de4e19 (diff)
downloadezcms-c0be486968fe3d375d1f408eae7f954e1f5f82fc.tar.gz
Fixes RSS issues. Changes time tracking to git
This commit primarily changes the code base to base the file last modified time on the output of "git log". This adds dateutil and git itself as a dependency, but those are pretty common... This also fixes some minor issues including: - missing / between mjfer.net and the URI - README up to date with latest changes - linting
Diffstat (limited to 'view_functions.py')
-rw-r--r--view_functions.py17
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):
"""