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