главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTessa L. <tessa@volumetrics.io>2024-11-03 18:22:56 -0800
committerTessa L. <tessa@volumetrics.io>2024-11-03 18:22:56 -0800
commit3ffccc3bac4384cc5045091439ce5162a3df27ec (patch)
tree6d45c4aee526749caa9330858a3b58dbc5e8ac73
parentbc7df6c2df7cb39fdd24c521e499cf3068c99783 (diff)
parent7a127c634eecdb3bec1c52b1bd96d6c53be5a3d3 (diff)
Merge remote-tracking branch 'keep-timestamp-patch/keep-original-timestamp-when-regenerating-blog'
-rw-r--r--bb.sh16
1 files changed, 14 insertions, 2 deletions
diff --git a/bb.sh b/bb.sh
index d4e45d6..dc24b31 100644
--- a/bb.sh
+++ b/bb.sh
@@ -668,6 +668,9 @@ all_posts() {
while IFS='' read -r i; do
is_boilerplate_file "$i" && continue
echo -n "." 1>&3
+ # Read timestamp from post, and sync file timestamp
+ timestamp=$(awk '/<!-- '$date_inpost': .+ -->/ { print }' "$i" | cut -d '#' -f 2)
+ [[ -n $timestamp ]] && touch -t "$timestamp" "$i"
# Month headers
month=$(LC_ALL=$date_locale date -r "$i" +"$date_allposts_header")
if [[ $month != "$prev_month" ]]; then
@@ -682,7 +685,7 @@ all_posts() {
# Date
date=$(LC_ALL=$date_locale date -r "$i" +"$date_format")
echo " $date</li>"
- done < <(ls -t ./*.html)
+ done < <(list_html_by_timestamp)
echo "" 1>&3
echo "</ul>"
echo "<div id=\"all_posts\"><a href=\"./$index_file\">$template_archive_index_page</a></div>"
@@ -752,7 +755,7 @@ rebuild_index() {
fi
echo -n "." 1>&3
n=$(( n + 1 ))
- done < <(ls -t ./*.html) # sort by date, newest first
+ done < <(list_html_by_timestamp) # sort by file timestamp, newest first
feed=$blog_feed
if [[ -n $global_feedburner ]]; then feed=$global_feedburner; fi
@@ -1124,6 +1127,15 @@ date_version_detect() {
fi
}
+# Lists html files in directory ordering by their timestamps
+# instead of modified date
+list_html_by_timestamp() {
+ grep "$date_inpost" ./*.html \
+ | sed -nr 's/<!-- '"$date_inpost"': #(.*)# -->$/\1/p' \
+ | sort --field-separator=: --key=2 --stable --reverse \
+ | sed -nr 's/^(.*):.*$/\1/p'
+}
+
# Main function
# Encapsulated on its own function for readability purposes
#