From 2c8bb9312059ae9aa4ccb9e5514588296149cf92 Mon Sep 17 00:00:00 2001 From: /dev/urandom Date: Mon, 24 Aug 2020 09:42:43 +0300 Subject: [PATCH] modified scripts to sort files based on git commits --- .gitignore | 1 + blogindex.sh | 12 +++++++++++- blogrss.sh | 12 +++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 69626ac..57bbe07 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +blogdates.txt localhashes.txt remotehashes.txt Makefile.cfg diff --git a/blogindex.sh b/blogindex.sh index 667cf08..6ced1a5 100755 --- a/blogindex.sh +++ b/blogindex.sh @@ -2,7 +2,17 @@ DIRECTORY="pages/blog" -FILES=`ls $DIRECTORY/*.md -1t` +FILES=`ls $DIRECTORY/*.md -1` + +echo -n > blogdates.txt +for f in $FILES; do + MTIME=`git log -n 1 --pretty=format:%at $f` + MTIME=${MTIME-9999999999} + printf "%d\t%s\n" $MTIME $f >> blogdates.txt +done + +# resort by last git commit time +FILES=`cat blogdates.txt | sort -nr | cut -f 2-` cat tpl/blog_header.md diff --git a/blogrss.sh b/blogrss.sh index ea740c8..6968088 100755 --- a/blogrss.sh +++ b/blogrss.sh @@ -2,7 +2,17 @@ DIRECTORY="pages/blog" -FILES=`ls $DIRECTORY/*.md -1t` +FILES=`ls $DIRECTORY/*.md -1` + +echo -n > blogdates.txt +for f in $FILES; do + MTIME=`git log -n 1 --pretty=format:%at $f` + MTIME=${MTIME-9999999999} + printf "%d\t%s\n" $MTIME $f >> blogdates.txt +done + +# resort by last git commit time +FILES=`cat blogdates.txt | sort -nr | cut -f 2-` cat << RSSHEADER