From c654151582a77a0b459e3f55b687e43a32d4b67d Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 26 Mar 2015 19:46:45 -0700 Subject: Add HAPAX LEGOMENA support & flatten structure The list of hapax legomena for this project is available at /hapax.html. In addition, the directory structure has been further flattened. All assets (javascript, lua, images, fonts) are in /trunk/. One other thing was to update the makefile. It compiles hapax.txt from rivers. --- makefile | 73 +++++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 19 deletions(-) (limited to 'makefile') diff --git a/makefile b/makefile index 34eda34..be0806a 100644 --- a/makefile +++ b/makefile @@ -3,19 +3,35 @@ # inspired by Lincoln Mullen | lincolnmullen.com # Define directories, file lists, and options -HTMLs := $(patsubst %.txt,%.html,$(wildcard *.txt)) -HTMopts = --template=.template.html +TEXTs := $(wildcard *.txt) + +HTMLbl := index.html template.html index-txt.html +HTMLs := $(filter-out $(HTMLbl),$(patsubst %.txt,%.html,$(TEXTs))) +HTMopts = --template=template.html HTMopts+= --smart --mathml --section-divs -RIVERer = lua/river.lua -RIVERs := $(patsubst %.txt,%.river,$(wildcard *.txt)) -RIVopts = -LOZENGE = js/lozenge.js - -# Do everything -.PHONY: all html river lozenge -all : html river lozenge + +HAPAXbl:= first-lines.river common-titles.river hapax.river +RIVERer = trunk/river.lua +RIVERs := $(filter-out $(HAPAXbl),$(patsubst %.txt,%.river,$(TEXTs))) + +HAPAXs := $(filter-out $(HAPAXbl),$(RIVERs)) +HAPAXer = trunk/hapax.lua +HAPAXhd = trunk/hapax.head +HAPAXtmp= hapax.tmp +HAPAX = hapax.txt + +LOZENGE = trunk/lozenge.js + +.PHONY: all +all : hapax html river lozenge + +.PHONY: hapax +hapax : $(HAPAX) +.PHONY: html html : $(HTMLs) +.PHONY: river river : $(RIVERs) +.PHONY: lozenge lozenge : $(LOZENGE) # Generic rule for HTML targets and Markdown sources @@ -27,15 +43,34 @@ lozenge : $(LOZENGE) @echo River-ing $@ @sed -e '/^---$$/,/^...$$/d'\ -e "s/[^][A-Za-z0-9\/\"':.-]/ /g" $< |\ - pandoc - -f markdown -t $(RIVERer) $(RIVopts) -o $@ + pandoc - -f markdown -t $(RIVERer) -o $@ $(LOZENGE) : $(HTMLs) @echo "Updating lozenge.js..." - @list=`ls *.html |\ - sed -e 's,../,,g' |\ - tr '\n' ' ' |\ - sed -e 's/\(\S\+.html\) /"\1",/g'\ - -e 's/^\(.*\),$$/var files=[\1]/'` &&\ - sed -i "s/var files=.*/$$list/" $(LOZENGE) -# TODO: add compiling hapax -# TODO: add first line compiler + @list=`echo $(HTMLs) |\ + sed -e 's/\(\S\+.html\) \?/"\1",/g'\ + -e 's/^\(.*\),$$/var files=[\1]/'` &&\ + sed -i "s/var files=.*/$$list/" $(LOZENGE) + +$(HAPAX) : $(RIVERs) $(HAPAXhd) + -rm -f $(HAPAXbl) + @echo "Compiling $(HAPAX)..." + pandoc -f markdown -t $(HAPAXer) -o $(HAPAX) *.river + @echo -n "Linking $(HAPAX)..." + @cat $(HAPAXhd) > $(HAPAXtmp) &&\ + for word in `sort hapax.txt`; do\ + file=`grep -liwq "^$$word$$" *.river | grep -v '$(HAPAX)'`;\ + echo "[$$word](`basename $$file river`html)">>$(HAPAXtmp);\ + echo -n '.';\ + done && mv $(HAPAXtmp) $(HAPAX) + @echo "Done." + +# TODO: Add indices compilers (first-lines, common-titles) + +.PHONY: clean +clean: + -rm -f hapax.txt hapax.tmp *.river + -rm -f $(HTMLs) + +.PHONY: again +again: clean all -- cgit 1.4.1-21-gabe81