summaryrefslogtreecommitdiff
path: root/Makefile
blob: 0ea41fc1fbb911a31e61fe62d70fc7954f14bbe9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
GEMTEXT=$(shell find -L site -type f -name "*.gmi" -print)
HTML=$(GEMTEXT:%.gmi=%.html)
RSS=$(shell find -L . -type d -name "*.rss" -print)
RSS_XML=$(RSS:%.rss=%.xml)

.PHONY: clean
.PHONY: all

all: $(HTML) $(RSS_XML)

%.html: %.gmi header.html footer.html gmi2html
	@echo "GMI2HTML $@"
	cp header.html $@
	./gmi2html < $< | sed -e 's/\.gmi/\.html/g ; /^<h2>.*/i </div><div class="content">' >> $@
	echo "</div>" >> $@
	cat footer.html >> $@

%.xml: %.rss %.rss.header.xml %.rss.item_header.xml rss_item_footer.xml rss_footer.xml
	@echo "RSS $@"
	cat $<.header.xml > $@
	for i in $(shell ls -r $</*.gmi | head -n 15) ; do \
		cat $<.item_header.xml >> $@; \
		echo "<title>`sed -n '/^# .*/p' $$i | cut -c 3-`</title>" >> $@; \
		echo "<pubDate>`basename $$i | head -c8 | xargs date '+%a, %d %b %Y' -d`</pubDate>" >> $@; \
		echo "<link>https://leagueh.xyz/$$i</link>" | sed 's/site\///g ; s/.gmi/.html/g' >> $@; \
		echo "<description>`./gmi2html < $$i | sed '/^#.*/d ; s/</\&lt;/g ; s/>/\&gt;/g '`</description>" >> $@; \
		cat rss_item_footer.xml >> $@; \
	done
	cat rss_footer.xml >> $@

gmi2html: gmi2html.c
	@echo "CC $@"
	$(CC) $(CFLAGS) $^ -o $@

.PHONY: clean
clean:
	rm -f gmi2html
	rm -f $(HTML)
	rm -f $(RSS_XML)

$(V).SILENT: