aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 2ecd379aa11472b053c5d64a72eae20995f4d74d (plain)
  1. SSH_HOST = www-ruc@xayide.jones.dk
  2. SSH_BASE_PATH = public_websites/thoughtroam.abcde.../
  3. BASE_SSH = $(SSH_HOST):$(SSH_BASE_PATH)
  4. BASE_IRI = https://thoughtroam.abcdefghijklmnopqrstuvxyzæøå.dk/
  5. BASE_URI = https://thoughtroam.xn--abcdefghijklmnopqrstuvxyz-0fc0a81c.dk/
  6. #PAD_ARTICLES = worlding
  7. ARTICLES = waste worlding
  8. ONTOLOGIES = learn waste
  9. ONTOLOGIES_LEARN = tentacular bisected trap
  10. ONTOLOGIES_VERSION = 0.1.1
  11. GRAPHS = $(patsubst ex/%.ttl,%,$(wildcard ex/*.ttl))
  12. PERL_FILES = bin/biblatex-tidy bin/hedgedoc2quarto bin/xmp2rdfxml
  13. TIDY_MARKDOWN = worlding
  14. export HEDGEDOC_COOKIES_FILE = $(CURDIR)/cookies.txt
  15. export HEDGEDOC_SERVER = https://pad.degrowth.net/
  16. get_title = $(shell \
  17. roqet -q -i sparql \
  18. -e 'SELECT ?s ?o WHERE { ?s <http://www.w3.org/2004/02/skos/core#prefLabel> ?o}' \
  19. -D $(1) \
  20. | grep -Po -m1 '#>, o=string[()]"\K[^"]+')
  21. get_desc = $(shell \
  22. roqet -q -i sparql \
  23. -e 'SELECT ?s ?o WHERE { ?s <http://purl.org/dc/elements/1.1/description> ?o }' \
  24. -D $(1) \
  25. | grep -Po '#>, o=string[()]"\K[^"]+')
  26. all: preview
  27. preview:
  28. quarto preview
  29. render:
  30. quarto render
  31. publish:
  32. rsync -avH --delete-after _site/ $(BASE_SSH)
  33. prepare: \
  34. $(patsubst %,learn/%_sdm.qmd,core $(ONTOLOGIES_LEARN)) \
  35. $(patsubst %,learn/%_ttl.qmd,core $(ONTOLOGIES_LEARN)) \
  36. $(patsubst %,learn/$(ONTOLOGIES_VERSION)/%.ttl,core $(ONTOLOGIES_LEARN)) \
  37. $(foreach ext,svg tex,learn/rdfs.$(ext)) \
  38. $(foreach dia,tentacular trap all,$(foreach ext,svg tex,learn/$(dia)_rdfs.$(ext)))
  39. learn/$(ONTOLOGIES_VERSION)/%.ttl: learn/%.ttl
  40. mkdir --parents learn/$(ONTOLOGIES_VERSION)
  41. perl -gp \
  42. -e 's,\b$(subst bisected,learn2sect,$(subst tentacular,learn10tac,$(subst core,learn,$*))):,:,g;' \
  43. -e 's,\Q$(BASE_URI)stub/foaf#,http://xmlns.com/foaf/0.1/,g;' \
  44. -e 's,\Q$(BASE_URI)stub/doap#,http://usefulinc.com/ns/doap#,g;' \
  45. -e 's,purl\.org/learn/\K(?=[^\d]),$(ONTOLOGIES_VERSION)/,g;' \
  46. -e 's,\n\s*owl:imports\s[^\n]+;(?=\n),,g;' \
  47. < $< > $@
  48. learn/%_sdm.qmd: learn/$(ONTOLOGIES_VERSION)/%.ttl
  49. sdml highlight --output-format html -i learn/$*.sdm -o learn/_$*_sdm.html
  50. $(eval title = $(call get_title,$<))
  51. $(eval desc = $(call get_desc,$<))
  52. @echo '---' > $@
  53. @echo 'title: $(title)' >> $@
  54. @echo 'subtitle: SDML source' >> $@
  55. @echo '---' >> $@
  56. @echo '$(desc)' >> $@
  57. @echo >> $@
  58. @echo '{{< include _$*_sdm.html >}}' >> $@
  59. learn/%_ttl.qmd: learn/%.sdm
  60. # sdml convert -f rdf -i learn/$*.sdm | ansifilter --html --fragment --ignore-csi -o learn/_$*_ttl.html
  61. sdml convert -f rdf -i learn/$*.sdm | ansifilter --html --fragment -o learn/_$*_ttl.html
  62. $(eval title = $(call get_title,learn/$(ONTOLOGIES_VERSION)/$*.ttl))
  63. $(eval desc = $(call get_desc,learn/$(ONTOLOGIES_VERSION)/$*.ttl))
  64. @echo '---' > $@
  65. @echo 'title: $(title)' >> $@
  66. @echo 'subtitle: Turtle format' >> $@
  67. @echo '---' >> $@
  68. @echo '$(desc)' >> $@
  69. @echo >> $@
  70. @echo '<pre><code class="turtle">' >> $@
  71. @echo '{{< include _$*_ttl.html >}}' >> $@
  72. @echo '</code></pre>' >> $@
  73. cal-all: cal-fetch cal-render cal-publish
  74. cal-fetch:
  75. bin/cal-fetch.sh
  76. cal-render:
  77. bin/cal-publish.sh
  78. cal-publish:
  79. ssh $(SSH_HOST) mkdir -p $(SSH_BASE_PATH)events/
  80. rsync -avH --delete-after $(patsubst %,events/%,$(ARTICLES) superteam) $(BASE_SSH)events/
  81. pad-login:
  82. hedgedoc login --email
  83. pad-list:
  84. hedgedoc history
  85. pad-export-all: $(PAD_ARTICLES:%=pad-export-%)
  86. pad-export-worlding: ref.bib worlding/index.qmd \
  87. $(patsubst %,worlding/_%.qmd,baggrund teori_og_metode undersøgelser konklusion perspektivering kilder planer)
  88. ref.bib:
  89. hedgedoc export --md 8krqOrqnR0iAIExDTtTrxw $@
  90. perl -g -e 's/\s*\z/\n/' $@
  91. worlding/index.qmd:
  92. hedgedoc export --md MJei_2e-SjahCtmRT-xiPw $@
  93. perl -g -e 's/\s*\z/\n/' $@
  94. worlding/_baggrund.qmd:
  95. hedgedoc export --md mGHhKvXyQ5SVeTIU11isQQ $@
  96. perl -g -e 's/\s*\z/\n/' $@
  97. worlding/_teori_og_metode.qmd:
  98. hedgedoc export --md 5AbKoR-mTOij6TsCMFFDRw $@
  99. perl -g -e 's/\s*\z/\n/' $@
  100. worlding/_undersøgelser.qmd:
  101. hedgedoc export --md 5XR69V5rSEm9LwsLNtSXcQ $@
  102. perl -g -e 's/\s*\z/\n/' $@
  103. worlding/_konklusion.qmd:
  104. hedgedoc export --md ofRbx2f4QcWLR-o_kqTNCQ $@
  105. perl -g -e 's/\s*\z/\n/' $@
  106. worlding/_perspektivering.qmd:
  107. hedgedoc export --md lU8aUxCkR5GNrP-8frklFA $@
  108. perl -g -e 's/\s*\z/\n/' $@
  109. worlding/_kilder.qmd:
  110. hedgedoc export --md Jt6S4tAhQM-BUrAP-OllCg $@
  111. perl -g -e 's/\s*\z/\n/' $@
  112. worlding/_planer.qmd:
  113. hedgedoc export --md qfFl3xiaQWCbpoyNPbNsEA $@~
  114. bin/hedgedoc2quarto $@~ $@
  115. $(PAD_ARTICLES:%=pad-import-%): pad-import-%:
  116. hedgedoc import $*/index.qmd
  117. pad-import-ref:
  118. hedgedoc import ref.bib
  119. lint: lint-markdown lint-sdml
  120. lint-markdown:
  121. @mdl --ignore-front-matter --style .mdl.rb $(filter-out %/index.qmd,$(wildcard $(addsuffix /*.qmd,$(TIDY_MARKDOWN))))
  122. lint-sdml:
  123. sdml validate learn
  124. sdml validate learn10tac
  125. sdml validate learntrap
  126. sdml validate waste
  127. tidy: tidy-bibtex tidy-perl
  128. tidy-bibtex: ref.bib
  129. bin/biblatex-tidy $<
  130. tidy-perl:
  131. perltidy -b -bext='/' --profile=.perltidyrc $(PERL_FILES)
  132. $(ARTICLES:%=screening-of-%): screening-of-%:
  133. QUARTO_LOG_LEVEL=quiet \
  134. quarto render $*/index.qmd --to man --output - | man -l -
  135. $(ARTICLES:%=wordcount-of-%): wordcount-of-%:
  136. QUARTO_LOG_LEVEL=quiet \
  137. quarto render $*/index.qmd --to plain --columns=9999 --output - \
  138. | perl -nE 'next if /^-*$$/; $$bilag += $$_ =~ "^Bilag\\b"; $$chars += length unless $$bilag; END { say $$chars }'
  139. $(ARTICLES:%=turtle-from-%): turtle-from-%:
  140. @bin/xmp2rdfxml _site/$*/S*.pdf \
  141. | rapper -i rdfxml -o turtle - $(BASE_IRI)$*/
  142. $(ARTICLES:%=dotgraph-from-%): dotgraph-from-%:
  143. @bin/xmp2rdfxml _site/$*/S*.pdf \
  144. | rapper -i rdfxml -o dot - $(BASE_IRI)$*/
  145. diff-all: $(ARTICLES:%=diff-of-%)
  146. $(ARTICLES:%=diff-of-%): diff-of-%: %/changes.tex
  147. $(ARTICLES:%=%/changes.tex): %/changes.tex: %/a.tex %/b.tex
  148. latexdiff --type CULINECHBAR --subtype COLOR --replace-context2cmd '' $^ > $*/changes.tex
  149. perl -i -pe 's/\[pdftex\]{changebar}/[luatex]{changebar}/g' $*/changes.tex
  150. latexmk --gg --lualatex --cd --silent --Werror $*/changes.tex
  151. find $*/ -name 'changes.*' -not -name changes.pdf -delete
  152. rm -f $^
  153. $(ARTICLES:%=%/a.tex): %/a.tex:
  154. git switch --detach $(shell git describe --tags --abbrev=0)
  155. QUARTO_LOG_LEVEL=quiet \
  156. quarto render $*/index.qmd --to pdf -M keep-tex:true --output a.pdf
  157. mv --force $*/index.tex $@
  158. rm --force _site/a.pdf
  159. $(ARTICLES:%=%/b.tex): %/b.tex:
  160. git switch -
  161. QUARTO_LOG_LEVEL=quiet \
  162. quarto render $*/index.qmd --to pdf -M keep-tex:true --output b.pdf
  163. mv --force $*/index.tex $@
  164. rm --force _site/b.pdf
  165. %/concepts.svg: %/core.sdm
  166. sdml draw --diagram concepts -i $< -f svg -o $@
  167. %/er.svg: %/core.sdm
  168. sdml draw --diagram entity-relationship -i $< -f svg -o $@
  169. %/uml.svg: %/core.sdm
  170. sdml draw --diagram uml-class -i $< -f svg -o $@
  171. %.ttl: %.sdm
  172. sdml --no-color convert -i $< -f rdf -o $@
  173. # TODO: drop workaround when SDML renders syntactically correct datatype
  174. # <https://github.com/sdm-lang/rust-sdml/issues/9>
  175. perl -pi -e 's/\\"([^\\"]*)\\"(?="\^\^xsd:date\b)/$$1/g;' $@
  176. %/core.puml: %/core.ttl %/prefixes.ttl
  177. rdfpuml $<
  178. %/core.png: %/core.puml
  179. plantuml -tpng $<
  180. %/core.svg: %/core.puml
  181. plantuml -tsvg $<
  182. %/rdfs.svg: %/core.ttl
  183. rdfs2dot -f turtle $< | dot -Tsvg -o$@
  184. learn/%_rdfs.svg: learn/%.ttl
  185. rdfs2dot -f turtle $< | dot -Tsvg -o$@
  186. learn/all_rdfs.svg: learn/core.ttl $(ONTOLOGIES_LEARN:%=learn/%.ttl)
  187. rdfs2dot -f turtle $^ | dot -Tsvg -o$@
  188. %/rdfs.tex: %/core.ttl
  189. rdfs2dot -f turtle $< | dot2tex --figonly -o$@
  190. learn/%_rdfs.tex: learn/%.ttl
  191. rdfs2dot -f turtle $< | dot2tex --figonly -o$@
  192. learn/all_rdfs.tex: learn/core.ttl $(ONTOLOGIES_LEARN:%=learn/%.ttl)
  193. rdfs2dot -f turtle $^ | dot2tex --figonly -o$@
  194. ex/%.puml: ex/%.ttl ex/prefixes.ttl
  195. rdfpuml $<
  196. ex/%.png: ex/%.puml
  197. plantuml -tpng $<
  198. ex/%.svg: ex/%.puml
  199. plantuml -tsvg $<
  200. %/docs/index.html: %/core.ttl
  201. mkdir --parents $*/docs
  202. ontospy gendocs --type 2 -x -o $(CURDIR)/$*/docs $<
  203. $(ONTOLOGIES:%=view-%-concept-diagram): view-%-concept-diagram: %/concepts.svg
  204. inkview $<
  205. $(ONTOLOGIES:%=view-%-er-diagram): view-%-er-diagram: %/er.svg
  206. inkview $<
  207. $(ONTOLOGIES:%=view-%-uml-diagram): view-%-uml-diagram: %/uml.svg
  208. inkview $<
  209. $(ONTOLOGIES:%=view-%-rdfs-graf): view-%-rdfs-graf: %/core.ttl
  210. rdfs2dot -f turtle $< | xdot -
  211. $(ONTOLOGIES_LEARN:%=view-learn_%-rdfs-graf): view-learn_%-rdfs-graf: learn/%.ttl
  212. rdfs2dot -f turtle $< | xdot -
  213. view-learn_avoid-rdfs-graf: $(patsubst %,learn/%.ttl,bisected trap)
  214. rdfs2dot -f turtle $^ | xdot -
  215. view-learn_all-rdfs-graf: learn/core.ttl $(ONTOLOGIES_LEARN:%=learn/%.ttl)
  216. rdfs2dot -f turtle $^ | xdot -
  217. view-learn_worlding-rdfs-graf: $(ONTOLOGIES_LEARN:%=learn/%.ttl)
  218. rdfs2dot -f turtle $^ | xdot -
  219. #$(ONTOLOGIES:%=view-%-puml-diagram): view-%-puml-diagram: %/core.svg
  220. # inkview $<
  221. $(ONTOLOGIES:%=view-%-puml-diagram): view-%-puml-diagram: %/core.png
  222. imv-wayland $<
  223. $(GRAPHS:%=view-%-puml-diagram): view-%-puml-diagram: ex/%.png
  224. imv-wayland $<
  225. $(ONTOLOGIES:%=render-%-ontology): render-%-ontology: %/docs/index.html