diff --git a/deploy.sh b/deploy.sh index 951b455..8e93985 100755 --- a/deploy.sh +++ b/deploy.sh @@ -3,4 +3,9 @@ rootdir=${0:h} echo $rootdir +echo -n "Building RSS" +./mkrss.sh +echo " [done]" +echo -n "Publishing" rsync --progress --partial -avHe ssh $rootdir/_site/ root@shoggoth1:/var/www/her.esy.fun/ --delete +echo " [done]" diff --git a/mkrss.sh b/mkrss.sh new file mode 100755 index 0000000..a6ed227 --- /dev/null +++ b/mkrss.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env zsh + +rsstpl="rss.tpl" +webdir="_site" +rssfile="$webdir/rss.xml" + +formatdate() { + local d=$1 + LC_TIME=en_US date --date $d +'%a, %d %b %Y %H:%M:%S %z' +} +finddate(){ + local fic="$1" + grep 'article-date' < $fic | perl -pe 's#.*([^<]*).*#$1#'|egrep '[0-9]+-[0-9]+-[0-9]+' +} +getcontent(){ + local fic="$1" + cat $fic | perl -pe 's#.*<(link|meta).*$##;s#<(img|input) ([^>]*[^/])>##g' | hxselect '#content' +} + +realname="Yann Esposito" +website="https://her.esy.fun" + +tmpdir=$(mktemp -d) +for fic in $webdir/posts/**/*.html; do + rssdate=$(formatdate $(finddate $fic)) + blogfile="$(echo $fic | perl -pe 's#.*?/posts/#/posts/#')" + printf "\\n\\n%s\\n%s%s\\n%s\\n\\n\\n\\n" "$realname" "$website" "$blogfile" "$rssdate" "$(getcontent "$fic")" >> "$tmpdir/rss" +done + +sed "//r $tmpdir/rss" "$rsstpl" > "$rssfile" diff --git a/rss.tpl b/rss.tpl new file mode 100644 index 0000000..fe03740 --- /dev/null +++ b/rss.tpl @@ -0,0 +1,30 @@ + + + her.esy.fun + + https://her.esy.fun + + en + Mon, 23 Sep 2019 09:59:16 +0200 + Mon, 23 Sep 2019 09:59:16 +0200 + Emacs 26.3 Org-mode 9.2.5 + yann@esposito.host (Yann Esposito) + + https://her.esy.fun/img/FlatAvatar.png + her.esy.fun + https://her.esy.fun + + + + + + diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..6a3968c --- /dev/null +++ b/shell.nix @@ -0,0 +1,5 @@ +# { pkgs ? import {} }: +{ pkgs ? import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09-beta.tar.gz) {} }: + pkgs.mkShell { + buildInputs = [ pkgs.html-xml-utils ]; + }