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