shithub: sirjofri_de

ref: da1e835da6ae30e3645566d0ab4d68f08be190a7
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 changeblog/*.ms | sed -e 's/\.ms$/.ht/g'}
OBJECTS=`{echo 'pub/'^$PATHS^'/index.html'}
DOMAIN='https://sirjofri.de/'

nl='
'

test:V: pub/changeblog.xml

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

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

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

pub/changeblog.xml:Q: `{ls changeblog/*.ms}
	{
		echo '<?xml version="1.0" encoding="utf-8"?>
	<feed xmlns="http://www.w3.org/2005/Atom">
	<author>
		<name>sirjofri</name>
	</author>
	<title>changeblog</title>'
		for(i in $prereq){
			title=`"{deroff $i | sed '1,2d;3q'}
			content=`"{deroff $i | sed '1,4d'}
			link=$DOMAIN^`{echo -n $i | sed 's:\.ms$:/:'}
			echo '<entry>
	<title>'^$title^'</title>
	<link href="'^$link^'"/>
	<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
		}
		echo '<article>
	<header>
	<h2>'^$title^'</h2>
	</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>
	<ul>' > $target
	obs=`{ls 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^'/">'$OB': '$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