logo

blog

My website can't be that messy, right? git clone https://hacktivis.me/git/blog.git
commit: 9cd74aa6174e2f6c3e1916790f1c40ac40ef281d
parent 7658194f5de5f584cfeab9e0480373177e93735c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon,  9 Dec 2019 20:31:10 +0100

new_article.sh: Init

Diffstat:

Anew_article.sh56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+), 0 deletions(-)

diff --git a/new_article.sh b/new_article.sh @@ -0,0 +1,56 @@ +#!/bin/sh -v +if [ ${#} -lt 1 ] +then +${ht}echo 'Usage: articles/new.sh Title' +${ht}exit 1 +fi +title="${1}" +title_url="$(echo \"$title\" | jq -r '@uri')" +timestamp="$(date -u +%FT%TZ)" +ht=" " +WORKDIR="$(dirname $0)" + +cat >"${WORKDIR}/articles/${title}.shtml" <<-EOF +<!DOCTYPE html> +<html lang="en"> +${ht}<head> +<!--#include file="/templates/head.shtml" --> +${ht}${ht}<meta property="og:type" content="article"/> +${ht}${ht}<meta property="og:title" content="${title}"/> +${ht}${ht}<title>${title} — Cyber-home of lanodan</title> +${ht}</head> +${ht}<body> +<!--#include file="/templates/en/nav.shtml" --> +<!--#include file="/articles/${title}.xhtml"--> +${ht}${ht}<a href="/articles/${title_url}.xhtml">article only(plain XHTML)</a> +<!--#include file="/templates/en/footer.html" --> +${ht}</body> +</html> +EOF + +cat >"${WORKDIR}/articles/${title}.xhtml" <<-EOF +<article xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" class="h-entry"> +<a href="/articles/${title_url}"><h1>${title}</h1></a> +<p><a href="">Fediverse post for comments</a>, published on ${timestamp}, last updated on ${timestamp}</p> +</article> +EOF + +#TODO: Grep for the id before appending +grep "<id>https://hacktivis.me/articles/${title_url}</id>" \ +"${WORKDIR}/feed.atom" || ed "${WORKDIR}/feed.atom" <<-EOF +/new.sh: new articles here/ +a +${ht}<entry> +${ht}${ht}<title>${title}</title> +${ht}${ht}<link rel="alternate" type="text/html" href="/articles/${title_url}"/> +${ht}${ht}<id>https://hacktivis.me/articles/${title_url}</id> +${ht}${ht}<published>${timestamp}</published> +${ht}${ht}<updated>${timestamp}</updated> +${ht}${ht}<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> +<!--#include file="/articles/${title}.xhtml"--> +${ht}${ht}</div></content> +${ht}</entry> + +. +wq +EOF