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