summaryrefslogtreecommitdiffstats
path: root/update_latest.py
diff options
context:
space:
mode:
authormjfernez <mjf@mjfer.net>2023-11-25 13:04:03 -0500
committermjfernez <mjf@mjfer.net>2023-11-25 13:04:03 -0500
commit1cb8cd68cc7e4e244c66a73ea69dcb0461b9b41d (patch)
treefe55e0bbedcc6a3d92a61a8cb0cba7d236c522b7 /update_latest.py
parentf084b6b60b0b19f3a5586ac7508fc8be1ce04624 (diff)
downloadsite-files-1cb8cd68cc7e4e244c66a73ea69dcb0461b9b41d.tar.gz
Change latest page to show first write date
Previous was to show the last update to the page
Diffstat (limited to 'update_latest.py')
-rw-r--r--update_latest.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/update_latest.py b/update_latest.py
index 94bf5a2..26bff62 100644
--- a/update_latest.py
+++ b/update_latest.py
@@ -5,9 +5,11 @@ from datetime import date
from email.utils import parsedate
def file_last_modified(path):
- git_time = f"git log -n1 --pretty=%aD {path}".split()
+ git_log = f"git log --pretty=%aD {path}".split()
try:
- mod_time = subprocess.check_output(git_time)
+ ps = subprocess.Popen(git_log, stdout=subprocess.PIPE)
+ mod_time = subprocess.check_output(["tail", "-n1"],
+ stdin=ps.stdout)
except:
# File is not in the git log, no biggie, just blank the date
return None
@@ -30,14 +32,14 @@ for top in dirs:
updates[path] = mktime(t)
print("<html>")
print("<body>")
-print("<h3>LATEST CHANGES</h3>")
+print("<h3>LATEST POSTS</h3>")
print("<ul>")
for f, t in sorted(updates.items(),
key=lambda x: x[1],
reverse=True)[:10]:
#print(f, ctime(t), sep="\t")
if f != "latest.html":
- print(f"\t<li><a href=/{f}>{f.split()[-1]}</a> - Updated: {date.fromtimestamp(t)}</li>")
+ print(f"\t<li><a href=/{f}>{f.split()[-1]}</a> - Published: {date.fromtimestamp(t)}</li>")
print("</ul>")
print("</body>")