aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 6b033a9bbe4e0c460772d89967c58cfef3046fe2 (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.2
  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\h+owl:imports <[^>]+> ;//g;' \
  47. -e 's/(?:\G|^)\s{4}/\t/gm;' \
  48. -e 's/^\S+\K\s+rdf:type\s+/ a /gm;' \
  49. -e 's/^\t\Krdf:type /a /gm;' \
  50. -e 's/\s+$$/\n/;' \
  51. < $< > $@
  52. learn/%_sdm.qmd: learn/$(ONTOLOGIES_VERSION)/%.ttl
  53. sdml highlight --output-format html -i learn/$*.sdm -o learn/_$*_sdm.html
  54. $(eval title = $(call get_title,$<))
  55. $(eval desc = $(call get_desc,$<))
  56. @echo '---' > $@
  57. @echo 'title: $(title)' >> $@
  58. @echo 'subtitle: SDML source' >> $@
  59. @echo '---' >> $@
  60. @echo '$(desc)' >> $@
  61. @echo >> $@
  62. @echo '{{< include _$*_sdm.html >}}' >> $@
  63. learn/%_ttl.qmd: learn/%.sdm
  64. # sdml convert -f rdf -i learn/$*.sdm | ansifilter --html --fragment --ignore-csi -o learn/_$*_ttl.html
  65. sdml convert -f rdf -i learn/$*.sdm | ansifilter --html --fragment -o learn/_$*_ttl.html
  66. $(eval title = $(call get_title,learn/$(ONTOLOGIES_VERSION)/$*.ttl))
  67. $(eval desc = $(call get_desc,learn/$(ONTOLOGIES_VERSION)/$*.ttl))
  68. @echo '---' > $@
  69. @echo 'title: $(title)' >> $@
  70. @echo 'subtitle: Turtle format' >> $@
  71. @echo '---' >> $@
  72. @echo '$(desc)' >> $@
  73. @echo >> $@
  74. @echo '<pre><code class="turtle">' >> $@
  75. @echo '{{< include _$*_ttl.html >}}' >> $@
  76. @echo '</code></pre>' >> $@
  77. cal-all: cal-fetch cal-render cal-publish
  78. cal-fetch:
  79. bin/cal-fetch.sh
  80. cal-render:
  81. bin/cal-publish.sh
  82. cal-publish:
  83. ssh $(SSH_HOST) mkdir -p $(SSH_BASE_PATH)events/
  84. rsync -avH --delete-after $(patsubst %,events/%,$(ARTICLES) superteam) $(BASE_SSH)events/
  85. pad-login:
  86. hedgedoc login --email
  87. pad-list:
  88. hedgedoc history
  89. pad-export-all: $(PAD_ARTICLES:%=pad-export-%)
  90. pad-export-worlding: ref.bib worlding/index.qmd \
  91. $(patsubst %,worlding/_%.qmd,baggrund teori_og_metode undersøgelser konklusion perspektivering kilder planer)
  92. ref.bib:
  93. hedgedoc export --md 8krqOrqnR0iAIExDTtTrxw $@
  94. perl -g -e 's/\s*\z/\n/' $@
  95. worlding/index.qmd:
  96. hedgedoc export --md MJei_2e-SjahCtmRT-xiPw $@
  97. perl -g -e 's/\s*\z/\n/' $@
  98. worlding/_baggrund.qmd:
  99. hedgedoc export --md mGHhKvXyQ5SVeTIU11isQQ $@
  100. perl -g -e 's/\s*\z/\n/' $@
  101. worlding/_teori_og_metode.qmd:
  102. hedgedoc export --md 5AbKoR-mTOij6TsCMFFDRw $@
  103. perl -g -e 's/\s*\z/\n/' $@
  104. worlding/_undersøgelser.qmd:
  105. hedgedoc export --md 5XR69V5rSEm9LwsLNtSXcQ $@
  106. perl -g -e 's/\s*\z/\n/' $@
  107. worlding/_konklusion.qmd:
  108. hedgedoc export --md ofRbx2f4QcWLR-o_kqTNCQ $@
  109. perl -g -e 's/\s*\z/\n/' $@
  110. worlding/_perspektivering.qmd:
  111. hedgedoc export --md lU8aUxCkR5GNrP-8frklFA $@
  112. perl -g -e 's/\s*\z/\n/' $@
  113. worlding/_kilder.qmd:
  114. hedgedoc export --md Jt6S4tAhQM-BUrAP-OllCg $@
  115. perl -g -e 's/\s*\z/\n/' $@
  116. worlding/_planer.qmd:
  117. hedgedoc export --md qfFl3xiaQWCbpoyNPbNsEA $@~
  118. bin/hedgedoc2quarto $@~ $@
  119. $(PAD_ARTICLES:%=pad-import-%): pad-import-%:
  120. hedgedoc import $*/index.qmd
  121. pad-import-ref:
  122. hedgedoc import ref.bib
  123. lint: lint-markdown lint-sdml
  124. lint-markdown:
  125. @mdl --ignore-front-matter --style .mdl.rb $(filter-out %/index.qmd,$(wildcard $(addsuffix /*.qmd,$(TIDY_MARKDOWN))))
  126. lint-sdml:
  127. sdml validate learn
  128. sdml validate learn10tac
  129. sdml validate learntrap
  130. sdml validate waste
  131. tidy: tidy-bibtex tidy-perl
  132. tidy-bibtex: ref.bib
  133. bin/biblatex-tidy $<
  134. tidy-perl:
  135. perltidy -b -bext='/' --profile=.perltidyrc $(PERL_FILES)
  136. $(ARTICLES:%=screening-of-%): screening-of-%:
  137. QUARTO_LOG_LEVEL=quiet \
  138. quarto render $*/index.qmd --to markdown --output - | batcat --file-name index.qmd --language markdown
  139. $(ARTICLES:%=wordcount-of-%): wordcount-of-%:
  140. QUARTO_LOG_LEVEL=quiet \
  141. quarto render $*/index.qmd --to plain --columns=9999 --output - \
  142. | perl -nE 'next if /^-*$$/; $$bilag += $$_ =~ "^Bilag\\b"; $$chars += length unless $$bilag; END { say $$chars }'
  143. $(ARTICLES:%=turtle-from-%): turtle-from-%:
  144. @bin/xmp2rdfxml _site/$*/S*.pdf \
  145. | rapper -i rdfxml -o turtle - $(BASE_IRI)$*/
  146. $(ARTICLES:%=dotgraph-from-%): dotgraph-from-%:
  147. @bin/xmp2rdfxml _site/$*/S*.pdf \
  148. | rapper -i rdfxml -o dot - $(BASE_IRI)$*/
  149. diff-all: $(ARTICLES:%=diff-of-%)
  150. $(ARTICLES:%=diff-of-%): diff-of-%: %/changes.tex
  151. $(ARTICLES:%=%/changes.tex): %/changes.tex: %/a.tex %/b.tex
  152. latexdiff --type CULINECHBAR --subtype COLOR --replace-context2cmd '' $^ > $*/changes.tex
  153. perl -i -pe 's/\[pdftex\]{changebar}/[luatex]{changebar}/g' $*/changes.tex
  154. latexmk --gg --lualatex --cd --silent --Werror $*/changes.tex
  155. find $*/ -name 'changes.*' -not -name changes.pdf -delete
  156. rm -f $^
  157. $(ARTICLES:%=%/a.tex): %/a.tex:
  158. git switch --detach $(shell git describe --tags --abbrev=0)
  159. QUARTO_LOG_LEVEL=quiet \
  160. quarto render $*/index.qmd --to pdf -M keep-tex:true --output a.pdf
  161. mv --force $*/index.tex $@
  162. rm --force _site/a.pdf
  163. $(ARTICLES:%=%/b.tex): %/b.tex:
  164. git switch -
  165. QUARTO_LOG_LEVEL=quiet \
  166. quarto render $*/index.qmd --to pdf -M keep-tex:true --output b.pdf
  167. mv --force $*/index.tex $@
  168. rm --force _site/b.pdf
  169. %/concepts.svg: %/core.sdm
  170. sdml draw --diagram concepts -i $< -f svg -o $@
  171. %/er.svg: %/core.sdm
  172. sdml draw --diagram entity-relationship -i $< -f svg -o $@
  173. %/uml.svg: %/core.sdm
  174. sdml draw --diagram uml-class -i $< -f svg -o $@
  175. %.ttl: %.sdm
  176. sdml --no-color convert -i $< -f rdf -o $@
  177. %/core.puml: %/core.ttl %/prefixes.ttl
  178. rdfpuml $<
  179. %/core.png: %/core.puml
  180. plantuml -tpng $<
  181. %/core.svg: %/core.puml
  182. plantuml -tsvg $<
  183. %/rdfs.svg: %/core.ttl
  184. rdfs2dot -f turtle $< | dot -Tsvg -o$@
  185. learn/%_rdfs.svg: learn/%.ttl
  186. rdfs2dot -f turtle $< | dot -Tsvg -o$@
  187. learn/all_rdfs.svg: learn/core.ttl $(ONTOLOGIES_LEARN:%=learn/%.ttl)
  188. rdfs2dot -f turtle $^ | dot -Tsvg -o$@
  189. %/rdfs.tex: %/core.ttl
  190. rdfs2dot -f turtle $< | dot2tex --figonly -o$@
  191. learn/%_rdfs.tex: learn/%.ttl
  192. rdfs2dot -f turtle $< | dot2tex --figonly -o$@
  193. learn/all_rdfs.tex: learn/core.ttl $(ONTOLOGIES_LEARN:%=learn/%.ttl)
  194. rdfs2dot -f turtle $^ | dot2tex --figonly -o$@
  195. ex/%.puml: ex/%.ttl ex/prefixes.ttl
  196. rdfpuml $<
  197. ex/%.png: ex/%.puml
  198. plantuml -tpng $<
  199. ex/%.svg: ex/%.puml
  200. plantuml -tsvg $<
  201. %/docs/index.html: %/core.ttl
  202. mkdir --parents $*/docs
  203. ontospy gendocs --type 2 -x -o $(CURDIR)/$*/docs $<
  204. $(ONTOLOGIES:%=view-%-concept-diagram): view-%-concept-diagram: %/concepts.svg
  205. inkview $<
  206. $(ONTOLOGIES:%=view-%-er-diagram): view-%-er-diagram: %/er.svg
  207. inkview $<
  208. $(ONTOLOGIES:%=view-%-uml-diagram): view-%-uml-diagram: %/uml.svg
  209. inkview $<
  210. $(ONTOLOGIES:%=view-%-rdfs-graf): view-%-rdfs-graf: %/core.ttl
  211. rdfs2dot -f turtle $< | xdot -
  212. $(ONTOLOGIES_LEARN:%=view-learn_%-rdfs-graf): view-learn_%-rdfs-graf: learn/%.ttl
  213. rdfs2dot -f turtle $< | xdot -
  214. view-learn_avoid-rdfs-graf: $(patsubst %,learn/%.ttl,bisected trap)
  215. rdfs2dot -f turtle $^ | xdot -
  216. view-learn_all-rdfs-graf: learn/core.ttl $(ONTOLOGIES_LEARN:%=learn/%.ttl)
  217. rdfs2dot -f turtle $^ | xdot -
  218. view-learn_worlding-rdfs-graf: $(ONTOLOGIES_LEARN:%=learn/%.ttl)
  219. rdfs2dot -f turtle $^ | xdot -
  220. #$(ONTOLOGIES:%=view-%-puml-diagram): view-%-puml-diagram: %/core.svg
  221. # inkview $<
  222. $(ONTOLOGIES:%=view-%-puml-diagram): view-%-puml-diagram: %/core.png
  223. imv-wayland $<
  224. $(GRAPHS:%=view-%-puml-diagram): view-%-puml-diagram: ex/%.png
  225. imv-wayland $<
  226. $(ONTOLOGIES:%=render-%-ontology): render-%-ontology: %/docs/index.html