summaryrefslogtreecommitdiffhomepage
path: root/www
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-12-12 17:07:16 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-12-12 17:07:16 +0800
commit51265f08cb9b19ebb01375d05057fdbc338b6355 (patch)
tree8f02e0c2cab0e0772655133cd67d221594753936 /www
parent015923746c4d3db65cb7eef3327b34532a7c1ae9 (diff)
add build for rss feeds
Diffstat (limited to 'www')
-rw-r--r--www/Makefile11
-rwxr-xr-xwww/scripts/update-feeds.sh28
-rw-r--r--www/templates/header.html5
3 files changed, 37 insertions, 7 deletions
diff --git a/www/Makefile b/www/Makefile
index 699abb2..d54081b 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -4,10 +4,15 @@ ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
4# build html files for public/ 4# build html files for public/
5build: 5build:
6 cd $(ROOT_DIR) 6 cd $(ROOT_DIR)
7 @input_dir=~/log/public \ 7 export input_dir=~/log/public
8 output_dir=/srv/http \ 8 export output_dir=/srv/http
9 scripts/build.sh 9 @scripts/build.sh
10 10
11# Migrage frontmatter from '---' to HTML comment '<!-- -->' 11# Migrage frontmatter from '---' to HTML comment '<!-- -->'
12frontmatter: 12frontmatter:
13 find content -type f -name '*.md' | xargs sed -i ':frontmatter { 1s/^---/<!--/; 1!s/^---/-->/; 1!b}; /^---/ {1b frontmatter}' 13 find content -type f -name '*.md' | xargs sed -i ':frontmatter { 1s/^---/<!--/; 1!s/^---/-->/; 1!b}; /^---/ {1b frontmatter}'
14
15rss:
16 cd /srv/rss
17 export LIST=~/log/public/links/rss.list
18 $(ROOT_DIR)/scripts/update-feeds.sh
diff --git a/www/scripts/update-feeds.sh b/www/scripts/update-feeds.sh
new file mode 100755
index 0000000..8dff837
--- /dev/null
+++ b/www/scripts/update-feeds.sh
@@ -0,0 +1,28 @@
1#! /bin/bash
2
3cd /srv/rss
4mkdir -p feeds
5
6LIST=${LIST:?}
7curlOpts='--insecure'
8
9cat "${LIST}" | while read url interval tags; do
10 feed=feeds/${url//\//%2F}
11 unset next_fetch; declare -i next_fetch=0
12
13 # Get time of next fetch
14 if [ -f $feed ]; then
15 interval=$(<<<"$interval" sed 's/m/minute/; s/h/hour/; s/d/day/;')
16 next_fetch=$(date -d "$(date -r $feed) + $interval" +'%s')
17 fi
18
19 # Do not fetch feed if interval covers current time
20 [ $(date +'%s') -lt $next_fetch ] && continue
21
22 # Set limit of HTTP connections
23 while [ $(jobs -p | wc -l) -ge 10 ]; do
24 sleep 0.5;
25 done
26
27 curl -s $curlOpts $url -o $feed || echo Fail to fetch $url >&2 &
28done
diff --git a/www/templates/header.html b/www/templates/header.html
index a77079a..d5975fd 100644
--- a/www/templates/header.html
+++ b/www/templates/header.html
@@ -4,10 +4,7 @@
4 <a href="/about.html" data-tooltip="About this site">About</a> | 4 <a href="/about.html" data-tooltip="About this site">About</a> |
5 <a href="/posts/">Posts</a> | 5 <a href="/posts/">Posts</a> |
6 <a href="/projects.html" data-tooltip="Not valid now...">Projects</a> | 6 <a href="/projects.html" data-tooltip="Not valid now...">Projects</a> |
7 <!-- 7 <a href="/links/" data-tooltip="Not valid now...">Links</a>
8 <a href="/links.html" data-tooltip="Cool sites you might be interested">Links</a>
9 -->
10 <a href="/links.html" data-tooltip="Not valid now...">Links</a>
11 </nav> 8 </nav>
12 <nav class="right"> 9 <nav class="right">
13 <a href="/rss.xml" data-tooltip="Not valid now...">RSS</a> | 10 <a href="/rss.xml" data-tooltip="Not valid now...">RSS</a> |