diff options
-rwxr-xr-x | sfeed_html.sh | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/sfeed_html.sh b/sfeed_html.sh index 31d4702..a2f7cc4 100755 --- a/sfeed_html.sh +++ b/sfeed_html.sh | |||
@@ -3,7 +3,9 @@ | |||
3 | echo() { printf '%s\n' "$*"; } | 3 | echo() { printf '%s\n' "$*"; } |
4 | 4 | ||
5 | html() { | 5 | html() { |
6 | : "${LIMIT:=25}" | 6 | : "${LIMIT:=12}" |
7 | : "${FRESH_DAYS:=1}" | ||
8 | : "${STALE_DAYS:=4}" | ||
7 | aside="$(mktemp /tmp/sfeed_html_aside.XXXXXX)" | 9 | aside="$(mktemp /tmp/sfeed_html_aside.XXXXXX)" |
8 | cat <<EOF | 10 | cat <<EOF |
9 | $(html_head) | 11 | $(html_head) |
@@ -80,11 +82,12 @@ filter_invidious() { | |||
80 | html_feed() { # html_feed FEED(file) => HTML | 82 | html_feed() { # html_feed FEED(file) => HTML |
81 | filename="$(basename "$1")" | 83 | filename="$(basename "$1")" |
82 | now="$(date +%s)" | 84 | now="$(date +%s)" |
83 | fresh_days=1 | 85 | fresh_secs="$((FRESH_DAYS * 24 * 60 * 60))" |
84 | fresh_secs="$((fresh_days * 24 * 60 * 60))" | 86 | stale_secs="$((STALE_DAYS * 24 * 60 * 60))" |
85 | 87 | ||
86 | ## ENTRIES | 88 | ## ENTRIES |
87 | entries="$(awk -v NOW="$now" -v FRESH_SECS="$fresh_secs" \ | 89 | entries="$(awk -v NOW="$now" \ |
90 | -v FRESH_SECS="$fresh_secs" -v STALE_SECS="$stale_secs" \ | ||
88 | -v NAME="$filename" -v FNAME="$filename" \ | 91 | -v NAME="$filename" -v FNAME="$filename" \ |
89 | -v ASIDE="$aside" -v limit="$LIMIT" \ | 92 | -v ASIDE="$aside" -v limit="$LIMIT" \ |
90 | 'BEGIN { FS="\t"; fresh_feed = 0; FRESH = (NOW - FRESH_SECS); } | 93 | 'BEGIN { FS="\t"; fresh_feed = 0; FRESH = (NOW - FRESH_SECS); } |
@@ -115,7 +118,7 @@ html_feed() { # html_feed FEED(file) => HTML | |||
115 | enclosure=$8; | 118 | enclosure=$8; |
116 | category=$9; | 119 | category=$9; |
117 | 120 | ||
118 | if (limit && (timestamp < (NOW - (FRESH_SECS * 21)))) next; | 121 | if (limit && (timestamp < (NOW - STALE_SECS))) next; |
119 | show_in_sidebar = 1; | 122 | show_in_sidebar = 1; |
120 | #print timestamp, title, link > "/dev/stderr"; | 123 | #print timestamp, title, link > "/dev/stderr"; |
121 | 124 | ||
@@ -128,7 +131,7 @@ html_feed() { # html_feed FEED(file) => HTML | |||
128 | fresh = (timestamp >= FRESH) | 131 | fresh = (timestamp >= FRESH) |
129 | if (fresh) fresh_feed = 1; | 132 | if (fresh) fresh_feed = 1; |
130 | 133 | ||
131 | print "<tr class=\"entry " (fresh ? "fresh" : "") "\">" | 134 | print "<tr class=\"entry " (fresh ? "fresh" : "stale") "\">" |
132 | print "<td class=\"entry-timestamp\">" ts "</td>" | 135 | print "<td class=\"entry-timestamp\">" ts "</td>" |
133 | printf "%s", "<td class=\"entry-extra\">" | 136 | printf "%s", "<td class=\"entry-extra\">" |
134 | if (enclosure) { | 137 | if (enclosure) { |
@@ -148,7 +151,7 @@ html_feed() { # html_feed FEED(file) => HTML | |||
148 | } | 151 | } |
149 | END { | 152 | END { |
150 | if (show_in_sidebar) { | 153 | if (show_in_sidebar) { |
151 | printf "<li%s>", (fresh_feed?" class=\"fresh\"":"") >> ASIDE | 154 | printf "<li class=\"%s\">", (fresh_feed?"fresh":"stale") >> ASIDE |
152 | printf "<a%s href=\"#%s\">%s</a></li>\n", (yt ? " class=\"yt\"" : ""), FNAME, NAME >> ASIDE | 155 | printf "<a%s href=\"#%s\">%s</a></li>\n", (yt ? " class=\"yt\"" : ""), FNAME, NAME >> ASIDE |
153 | } | 156 | } |
154 | printf "%s", (stamp ? stamp : ".") > "/dev/stderr" | 157 | printf "%s", (stamp ? stamp : ".") > "/dev/stderr" |
@@ -162,7 +165,9 @@ function silo_links(link) { | |||
162 | } | 165 | } |
163 | ' "$1" | filter_invidious)" | 166 | ' "$1" | filter_invidious)" |
164 | if [ -z "$entries" ]; then return 1; fi | 167 | if [ -z "$entries" ]; then return 1; fi |
165 | echo "<section id=\"$filename\">" | 168 | fresh_feed='stale_feed' |
169 | if echo "$entries" | grep -q 'class="[^"]*fresh"'; then fresh_feed='fresh_feed'; fi | ||
170 | printf '<section id="%s" class="%s">\n' "$filename" "$fresh_feed" | ||
166 | case "$filename" in | 171 | case "$filename" in |
167 | *\[yt\]) yt=" class=\"yt\"" ;; | 172 | *\[yt\]) yt=" class=\"yt\"" ;; |
168 | *) yt="" ;; | 173 | *) yt="" ;; |