shithub: sirjofri_de

ref: 9c704c0dff7b774d613448e51cc6e7d01004b5d3
dir: /mkfile/

View raw version
PATHS=`{ls *.ht | sed -e 's/\.ht$//g' | grep -v 'index' | grep -v 'changeblog/';ls changeblog/*.ms | sed -e 's/\.ms$//g'}
BLOG=`{ls -r changeblog/*.ms | sed -e 's/\.ms$/.ht/g'}
OBJECTS=`{echo 'pub/'^$PATHS^'/index.html'}
DOMAIN='https://sirjofri.de/'

nl='
'

build:QV: changeblog.ht $OBJECTS pub/index.html pub/changeblog.xml pub/changeblog/changeblog.pdf
	echo 'Build complete'

prepare:QV: changeblog.ht
	echo 'Prepare complete'
	mk build

pub/changeblog/changeblog.pdf:Q: `{ls -r changeblog/*.ms}
	{
		echo '.TL
	sirjofri.de changeblog'
		for(i in $prereq){
			echo '.PP
	.PP
	.B'
			echo `"{date -m `{basename $i | sed 's:\.ms$::g' | tr -d $nl}}^:
			echo .R
			cat $i
		}
	} | troff -ms | lp -dstdout | ps2pdf > $target
	echo '√ '^$target^' created'

pub/changeblog.xml:Q: `{ls -r changeblog/*.ms}
	{
		echo '<?xml version="1.0" encoding="utf-8"?>
	<feed xmlns="http://www.w3.org/2005/Atom">
	<author>
		<name>sirjofri</name>
		<email>sirjofri@sirjofri.de</email>
	</author>
	<link rel="self" href="'^$DOMAIN^'changeblog.xml"/>
	<rights>© Copyright 2020 sirjofri</rights>
	<id>'^$DOMAIN^'</id>
	<title>changeblog</title>
	<updated>'^`{date -t | tr -d $nl}^'</updated>'
		for(i in $prereq){
			title=`"{deroff $i | sed '1,2d;3q' | tr -d $nl}
			content=`"{deroff $i | sed '1,4d' | tr -d $nl}
			link=$DOMAIN^`{echo -n $i | sed 's:\.ms$:/:' | tr -d $nl}
			updated=`{date -t `{basename $i | sed 's/\.ms$//'} | tr -d $nl}
			echo '<entry>
	<title>'^$title^'</title>
	<id>'^$link^'</id>
	<link href="'^$link^'"/>
	<updated>'^$updated^'</updated>
	<content>'^$content^'</content>
	</entry>'
		}
		echo '</feed>'
	} > $target
	echo '√ '^$target^' created'

changeblog/%.ht:Q: changeblog/%.ms
	{
		title=`"{
			sed -n '/\.HTML/s/\.HTML //p' changeblog/$stem.ms | tr -d $nl
		}
		echo '<article>
	<header>
	<h2>'^$title^'</h2>
	<b>'^`"{date -m $stem | tr -d $nl}^'</b>
	</header>'
		htmlroff -ms changeblog/$stem.ms
		echo '</article>'
	} > $target
	echo '√ '^$target^' prepared'

changeblog.ht:Q: $BLOG
	echo '<section>
	<header>
	<h2>all articles</h2>
	</header>
	<a href="changeblog.pdf">Download pdf</a><br>
	<a href="/changeblog.xml">Feed</a><br>
	<ul>' > $target
	obs=`{ls -r changeblog/*.ms | sed -e 's/\.ms$//g' -e 's:changeblog/::g'}
	for(OB in $obs){
		OBN=`"{sed -n '/^\.HTML /s:\.HTML::p' changeblog/^$OB^.ms | tr -d $nl}
		echo '<li><a href="/changeblog/'^$OB^'/">'^`"{date -m $OB | tr -d $nl}^': '$OBN'</a></li>' >> $target
	}
	echo '</ul>
	</section>' >> $target
	echo '√ '^$target^' prepared'

pub/index.html:QV: head.htf index.ht foot.htf
	if(! test -d pub)
		mkdir pub
	cat $prereq | sed -e 's:PAGETITLE:sirjofri:g' > pub/index.html
	echo '√ '^$target

pub/%/index.html:QV: head.htf %.ht foot.htf
	dirpart=`{basename -d $target}
	if(! test -d $dirpart)
		mkdir -p $dirpart
	cat $prereq | sed -e 's:PAGETITLE:'^$stem^':g' > pub/$stem/index.html
	echo '√ '^$target