summaryrefslogtreecommitdiff
path: root/Makefile
blob: 2602a2ef23b78014de78fe84b80174d3bcd60405 (plain)
  1. infiles := $(wildcard data/*.ttl data/*/*.ttl)
  2. turtlefiles := $(infiles:data/%.ttl=build/%/index.ttl)
  3. textfiles = $(turtlefiles:%.ttl=%.txt)
  4. rdfxmlfiles = $(turtlefiles:%.ttl=%.rdf)
  5. # TODO: resolve event:Event with prog:Programme being foaf:primaryTopic of <>
  6. htmlprogrammefiles = build/2014/europe/index.html \
  7. build/2014/bruxelles-05/index.html \
  8. build/2014/bruxelles-05-2/index.html
  9. htmlfiles = $(htmlprogrammefiles)
  10. getbase = $(shell perl -ne '/^\@base\s+<(http.+)>/ and print $$1 and exit;' "$1")
  11. all: $(textfiles) $(rdfxmlfiles) $(htmlfiles)
  12. clean:
  13. rm -rf build
  14. $(turtlefiles): build/%/index.ttl : data/%.ttl
  15. mkdir -p $(dir $@)
  16. cp $< $@
  17. # $(eval base = $(call getbase, $<))
  18. # rapper $(base:%=-I "%") -i turtle -o turtle "$<" > "$@"
  19. # perl -i -pe 's/ {4}/\t/g' "$@"
  20. $(textfiles): %.txt : %.ttl
  21. ln -fs $(notdir $<) $@
  22. $(rdfxmlfiles): %.rdf : %.ttl
  23. $(eval base = $(call getbase, $<))
  24. rapper $(base:%=-I "%") -i turtle -o rdfxml-abbrev "$<" > "$@"
  25. # Fetch and tidy programme rendering
  26. # * add doctype and title to validate
  27. # * add charset to not rely on server hinting
  28. # * refer to plaintext serialization (not self) of dataset
  29. $(htmlprogrammefiles): %.html : %.ttl
  30. $(eval base = $(call getbase, $<))
  31. wget -O"$@" "http://programme.ecs.soton.ac.uk/tool.php?src=$(base)"
  32. perl -pi -0 \
  33. -e 's,^(.*?<h1[^>]*>)(.*?)(?=</h1>),<!DOCTYPE html>\n<meta charset="utf-8">\n<title>$$2</title>$$1$$2,ms;' \
  34. -e 's,$(base)\K,/index.txt,;' \
  35. -e "s,class='[^'] *\Kprogramme_current',',;" \
  36. -e "s,<div class='programme_now_message'>now</div>,,g;" \
  37. "$@"