diff --git a/engine/mk-gemini-atom.sh b/engine/mk-gemini-atom.sh new file mode 100755 index 0000000..c52dedc --- /dev/null +++ b/engine/mk-gemini-atom.sh @@ -0,0 +1,113 @@ +#!/usr/bin/env zsh + +cd "$(git rev-parse --show-toplevel)" || exit 1 +# Directory +webdir="_optim" +postsdir="$webdir/posts" +rssfile="$webdir/gem-atom.xml" + +# maximal number of articles to put in the RSS file +maxarticles=10 + +# RSS Metas +rsstitle="her.esy.fun" +rssurl="gemini://her.esy.fun/atom.xml" +websiteurl="gemini://her.esy.fun" +rssdescription="her.esy.fun articles, mostly random personal thoughts" +rsslang="en" +rssauthor="yann@esposito.host (Yann Esposito)" +rssimgurl="gemini://her.esy.fun/img/FlatAvatar.png" + +# title and keyword shouldn't be changed + +formatdate() { + # format the date for RSS + local d=$1 + LC_TIME=en_US date --date $d +'%a, %d %b %Y %H:%M:%S %z' +} + +finddate(){ < $1 | awk '/^date: /' | head -n1 | perl -pe 's/^.*\[//;s/ .*$//;' } +findtitle(){ < $1 | head -n1 | perl -pe 's/^# //' } +getcontent(){ + < $1 perl -pe 'use URI; $base="'$2'"; s# (href|src)="((?!https?://)[^"]*)"#" ".$1."=\"".URI->new_abs($2,$base)->as_string."\""#eig' } +findkeywords(){ < $1 | awk '/^keywords: /' | head -n1 | perl -pe 's/^[^:]\s+//' } +mkcategories(){ + for keyword in $*; do + printf "\\n%s" $keyword + done +} + +autoload -U colors && colors + +tmpdir=$(mktemp -d) +typeset -a dates +dates=( ) +for fic in $postsdir/**/*.gmi; do + postfile="$(echo "$fic"|sed 's#^'$postsdir'/##')" + blogfile="$(echo "$fic"|sed 's#^'$webdir'/##')" + printf "%-30s" $postfile + xfic="$fic" + d=$(finddate $xfic) + echo -n " [$d]" + rssdate=$(formatdate $d) + title=$(findtitle $xfic) + keywords=( $(findkeywords $xfic) ) + printf ": %-55s" "$title ($keywords)" + categories=$(mkcategories $keywords) + absoluteurl="${websiteurl}/${blogfile}" + { printf "\\n" + printf "\\n%s" "$title" + printf "\\n%s" "$absoluteurl" + printf "\\n%s%s" "$rssdate" + printf "%s" "$categories" + printf "\\n" "$(getcontent "$xfic" "$absoluteurl")" + printf "\\n\\n\\n" + } >> "$tmpdir/${d}-$(basename $fic).rss" + dates=( $d $dates ) + echo " [${fg[green]}OK${reset_color}]" +done +echo "Publishing" +for fic in $(ls $tmpdir/*.rss | sort -r | head -n $maxarticles ); do + echo "${fic:t}" + cat $fic >> $tmpdir/rss +done + +rssmaxdate=$(formatdate $(for d in $dates; do echo $d; done | sort -r | head -n 1)) +rssbuilddate=$(formatdate $(date)) +{ +cat < + + ${rsstitle} + + ${websiteurl} + + ${rsslang} + ${rssmaxdate} + $rssbuilddate + mkrss.sh + ${rssauthor} + + ${rssimgurl} + ${rsstitle} + ${websiteurl} + +END +cat $tmpdir/rss +cat < + +END +} > "$rssfile" + +rm -rf $tmpdir +echo "* Gemini Atom [done]" diff --git a/engine/pre-deploy.sh b/engine/pre-deploy.sh index 6c7c874..6de34ab 100755 --- a/engine/pre-deploy.sh +++ b/engine/pre-deploy.sh @@ -14,3 +14,5 @@ echo "Update file size" ./engine/update-file-size.sh echo "Building RSS" ./engine/mkrss.sh +echo "Building Gemini Atom" +./engine/mk-gemini-atom.sh diff --git a/src/index.org b/src/index.org index 68573a8..fc58f1a 100644 --- a/src/index.org +++ b/src/index.org @@ -25,9 +25,9 @@ I'm a functional programmer, working remotely for Cisco.{{{br}}} I work in Clojure and use Haskell/Purescript during the weekends. -- [[file:archive.org][blog posts]] ([[https://her.esy.fun/rss.xml][RSS]]), +- [[file:archive.org][blog posts]] +- [[https://her.esy.fun/rss.xml][RSS]] - [[file:slides.org][talks slides]] -- [[https://gitea.esy.fun/yogsototh][my open source code]] ([[https://github.com/yogsototh][github backup]]), ** About this website @@ -58,3 +58,7 @@ priority: | reddit | . . . . . . . . | [[https://reddit.com/u/yogsototh][/u/yogsototh]] | | stack overflow | . . . . . . . . | [[https://stackoverflow.com/users/40569/yogsototh][yogsototh]] | +** Gemini + +- [[gemini://her.esy.fun][gemlog]] +- [[gemini://her.esy.fun/gem-atom.xml][gemini atom]]