index.html: head body tail
	cat head body tail >$@

body: kultura.body kulturac.body ntv.body ntvc.body delim delimc
	cat kultura.body delimc kulturac.body delim \
		ntv.body delimc ntvc.body >$@

.SUFFIXES: .body .sorted .list

.sorted.body:
	echo "<ol>" >$@
	cut -f 1 $< | sed 's/\(.*\)/<li>\1, /' >$*.dates
	cut -f 2 $< | sed 's/$$/<\/a><\/li>/' >$*.names
	cut -f 3 $< | sed 's/\(..*\)/<a href="\1">/' | \
		sed 's/^$$/<a>/' >$*.videos
	paste -d '\0' $*.dates $*.videos $*.names >>$@
	echo "</ol>" >>$@
	-rm -f $*.videos $*.names $*.dates

.list.sorted:
	sort $< >$@

clean:
	-rm -f *.sorted *.videos *.names *.dates *.body \
		body index.html
