phlog

Source code for my blog/gemlog. It used to be on gopher, hence the name
git clone http://shtanton.xyz/git/repo/phlog
Log | Files | Refs

Makefile (1949B)


      1 POSTS = subex_design gripes_with_pipes domain_specific_languages best_social_media all_the_protocols ex
      2 WEB_POSTS = $(POSTS:%=html/posts/%.html)
      3 GEMINI_POSTS = $(POSTS:%=gemini/posts/%.gmi)
      4 
      5 WEB = $(WEB_POSTS) html/post.css html/colours.css html/index.html html/posts/index.html
      6 GEMINI = $(GEMINI_POSTS) gemini/index.gmi gemini/posts/index.gmi
      7 
      8 .PHONY: all clean publish
      9 
     10 all: html/rss.xml $(WEB) $(GEMINI)
     11 
     12 html/rss.xml: posts-config.json html_src/rss.xml.mustache
     13 	jq '.posts[] |= (.formattedDate = (.date | strptime("%Y-%m-%d") | strftime("%d %b %y 12:00:00 GMT")))' < posts-config.json | mustach - html_src/rss.xml.mustache > $@
     14 
     15 html/%.css: html_src/%.css
     16 	cp $^ $@
     17 
     18 html_src/nav.html: posts-config.json html_src/nav.html.mustache
     19 	mustach posts-config.json html_src/nav.html.mustache > $@
     20 
     21 html/posts/%.html: posts/%.gmi html_src/posts/post_template.html.mustache posts-config.json html_src/nav.html
     22 	jq\
     23 		--arg content "$$(gmi2html < $<)"\
     24 		--arg nav "$$(tee < html_src/nav.html)"\
     25 		--arg slug '$(<:posts/%.gmi=%)'\
     26 		'.posts[] | select(.slug==$$slug) | (.content |= $$content) | (.nav |= $$nav)'\
     27 		< posts-config.json | mustach - html_src/posts/post_template.html.mustache > $@
     28 
     29 html/posts/index.html: posts-config.json html_src/posts/index.html.mustache html_src/nav.html.mustache
     30 	mustach posts-config.json html_src/posts/index.html.mustache > $@
     31 
     32 html/index.html: html_src/index.html
     33 	cp $^ $@
     34 
     35 gemini/posts/%.gmi: posts/%.gmi posts-config.json
     36 	jq\
     37 		-r\
     38 		--arg slug '$*'\
     39 		'.posts[] | select(.slug==$$slug) | ("# " + .name)'\
     40 		< posts-config.json > $@
     41 	echo "" >> $@
     42 	tee < $< >> $@
     43 
     44 gemini/posts/index.gmi: posts-config.json gemini_src/posts/index.gmi.mustache
     45 	mustach $< > $@
     46 
     47 gemini/index.gmi: gemini_src/index.gmi
     48 	cp $^ $@
     49 
     50 clean:
     51 	rm html_src/nav.html
     52 	rm -r html/*
     53 	rm -r gemini/*
     54 
     55 publish: all
     56 	rsync -vr --delete gemini/ charlie@shtanton.xyz:gemini
     57 	rsync -vr --delete --exclude="/git/" html/ charlie@shtanton.xyz:http