diff options
Diffstat (limited to 'www')
-rw-r--r-- | www/Makefile | 11 | ||||
-rwxr-xr-x | www/scripts/update-feeds.sh | 28 | ||||
-rw-r--r-- | www/templates/header.html | 5 |
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/ |
5 | build: | 5 | build: |
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 '<!-- -->' |
12 | frontmatter: | 12 | frontmatter: |
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 | |||
15 | rss: | ||
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 | |||
3 | cd /srv/rss | ||
4 | mkdir -p feeds | ||
5 | |||
6 | LIST=${LIST:?} | ||
7 | curlOpts='--insecure' | ||
8 | |||
9 | cat "${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 & | ||
28 | done | ||
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> | |