Browse Source

added REAL RSS generator

how-i-internet
parent
commit
31fe5a7bb4
Signed by: yogsototh GPG Key ID: 7B19A4C650D59646
  1. 5
      deploy.sh
  2. 30
      mkrss.sh
  3. 30
      rss.tpl
  4. 5
      shell.nix

5
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]"

30
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#.*<span class="article-date">([^<]*)</span>.*#$1#'|egrep '[0-9]+-[0-9]+-[0-9]+'
}
getcontent(){
local fic="$1"
cat $fic | perl -pe 's#.*<(link|meta).*$##;s#<(img|input) ([^>]*[^/])>#<img $1/>#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<item>\\n<title>%s</title>\\n<guid>%s%s</guid>\\n<pubDate>%s</pubDate>\\n<description><![CDATA[\\n%s\\n]]></description>\\n</item>\\n\\n" "$realname" "$website" "$blogfile" "$rssdate" "$(getcontent "$fic")" >> "$tmpdir/rss"
done
sed "/<!-- LB -->/r $tmpdir/rss" "$rsstpl" > "$rssfile"

30
rss.tpl

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:georss="http://www.georss.org/georss"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:media="http://search.yahoo.com/mrss/"><channel>
<title>her.esy.fun</title>
<atom:link href="https://her.esy.fun/rss.xml" rel="self" type="application/rss+xml" />
<link>https://her.esy.fun</link>
<description><![CDATA[her.esy.fun articles, mostly random personal thoughts]]></description>
<language>en</language>
<pubDate>Mon, 23 Sep 2019 09:59:16 +0200</pubDate>
<lastBuildDate>Mon, 23 Sep 2019 09:59:16 +0200</lastBuildDate>
<generator>Emacs 26.3 Org-mode 9.2.5</generator>
<webMaster>yann@esposito.host (Yann Esposito)</webMaster>
<image>
<url>https://her.esy.fun/img/FlatAvatar.png</url>
<title>her.esy.fun</title>
<link>https://her.esy.fun</link>
</image>
<!-- LB -->
</channel>
</rss>

5
shell.nix

@ -0,0 +1,5 @@
# { pkgs ? import <nixpkgs> {} }:
{ pkgs ? import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09-beta.tar.gz) {} }:
pkgs.mkShell {
buildInputs = [ pkgs.html-xml-utils ];
}
Loading…
Cancel
Save