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