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