Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Commit aebba03

Browse files
committed
build: Port to Deliverance
1 parent 4e84e98 commit aebba03

File tree

7 files changed

+188
-62
lines changed

7 files changed

+188
-62
lines changed

.github/workflows/deliverance.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Deliverance CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: "0 0 * * 0"
8+
9+
jobs:
10+
build-linux:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout, build and publish with Deliverance
14+
uses: pojntfx/deliverance@latest
15+
with:
16+
github_token: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/pandoc.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
out
2+
Makefile
23
target

Makefile

Lines changed: 138 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,144 @@
1+
# Public variables
2+
OUTPUT_DIR ?= out
3+
4+
# Private variables
5+
obj = $(shell ls docs/*.md | sed -r 's@docs/(.*).md@\1@g')
6+
mta = $(wildcard *.md)
7+
changelog_exists = $(wildcard CHANGELOG.txt)
8+
origin_exists = $(wildcard ORIGIN.txt)
9+
is_git_repo = $(wildcard .git)
10+
current_dir = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
11+
formats = pdf slides.pdf html slides.html epub odt txt
112
all: build
213

3-
qr:
4-
docker run -v "$(PWD):/qr:z" -e QR_TEXT="$$(sed -n '4 p' docs/metadata.txt)" -e QR_FILE=docs/static/qr.png valien/docker-qr-generator
5-
6-
.PHONY: docs
7-
docs: qr
8-
mkdir -p out/docs
9-
if [ -d "docs/static" ]; then cp -r docs/static out/docs; fi
10-
echo "<!DOCTYPE html><meta charset="utf-8"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><meta name=\"description\" content=\"$$(sed -n '2 p' docs/metadata.txt)\"><link rel=\"stylesheet\" href=\"https://unpkg.com/marx-css/css/marx.min.css\"><title>$$(sed -n '1 p' docs/metadata.txt)</title><main><h1>$$(sed -n '1 p' docs/metadata.txt)</h1><p>$$(sed -n '2 p' docs/metadata.txt)</p><hr><a href=\"$$(sed -n '4 p' docs/metadata.txt)\" target=\"_blank\">📃 View source (✍️ $$(sed -n '3 p' docs/metadata.txt))</a><br><a href=\"$$(sed -n '5 p' docs/metadata.txt)\" download=\"$$(sed -n '1 p' docs/metadata.txt).zip\">📥 Download all as ZIP</a><hr><div>You may do the following:</div><ul>" > "out/docs/index.html"
11-
for document in docs/*.md; do\
12-
echo "Compiling $${document} ..." ;\
13-
docker run -v "$(PWD):/data:z" pandoc/latex "$${document}" --variable urlcolor=blue --shift-heading-level-by=-1 --number-sections --resource-path=docs --pdf-engine=xelatex -o "out/$${document}.pdf" & docker run -v "$(PWD):/data:z" pandoc/latex "$${document}" --number-sections --resource-path=docs --toc --toc-depth=6 --katex --self-contained -t html5 -o "out/$${document}.html" & docker run -v "$(PWD):/data:z" pandoc/latex "$${document}" --number-sections --resource-path=docs --katex --self-contained -t slidy --slide-level 3 -o "out/$${document}.slides.html" & docker run -v "$(PWD):/data:z" pandoc/latex "$${document}" --variable urlcolor=blue --shift-heading-level-by=-1 --number-sections --resource-path=docs -t beamer --slide-level 3 --pdf-engine=xelatex -o "out/$${document}.slides.pdf";\
14-
echo "<li><a href=\"$${document#docs/}.html\" target=\"_blank\">🌐 View $${document#docs/} in your browser</a> (also available as <a href=\"$${document#docs/}.slides.html\" target=\"_blank\">slides</a>) or <a href=\"$${document#docs/}.pdf\" target=\"_blank\">📜 open $${document#docs/} as PDF</a> (also available as <a href=\"$${document#docs/}.slides.pdf\" target=\"_blank\">slides</a>)" >> "out/docs/index.html";\
15-
done
16-
echo "</ul><div><strong><em>$$(sed -n '6 p' docs/metadata.txt)</em></strong></div></main>" >> "out/docs/index.html"
17-
mkdir -p "out/release"
18-
zip -j -r "out/release/all.zip" "out/docs"
19-
20-
build: docs
21-
22-
dev:
23-
while [ -z "$${MAKE_PID}" ] || [ -n "$$(inotifywait -q -r -e modify docs/*.md)" ]; do\
24-
$(MAKE) PWD=$(PWD) & export MAKE_PID="$$!";\
25-
done
14+
# Build
15+
build: build/archive
16+
$(addprefix build/,$(obj)):
17+
$(MAKE) build-pdf/$(subst build/,,$@) build-slides.pdf/$(subst build/,,$@) build-html/$(subst build/,,$@) build-slides.html/$(subst build/,,$@) build-epub/$(subst build/,,$@) build-odt/$(subst build/,,$@) build-gmi/$(subst build/,,$@) build-txt/$(subst build/,,$@)
18+
19+
# Build PDF
20+
$(addprefix build-pdf/,$(obj)): build/qr
21+
mkdir -p "$(OUTPUT_DIR)"
22+
pandoc --template eisvogel --citeproc --listings --shift-heading-level-by=-1 --number-sections --resource-path=docs -M titlepage=true -M toc=true -M toc-own-page=true -M linkcolor=midnightblue --pdf-engine=xelatex -o "$(OUTPUT_DIR)/$(subst build-pdf/,,$@).pdf" "docs/$(subst build-pdf/,,$@).md"
23+
24+
# Build PDF slides
25+
$(addprefix build-slides.pdf/,$(obj)): build/qr
26+
ifeq ($(DISABLE_PDF_SLIDES),true)
27+
exit 0
28+
else
29+
mkdir -p "$(OUTPUT_DIR)"
30+
pandoc --to beamer --citeproc --listings --shift-heading-level-by=-1 --number-sections --resource-path=docs --slide-level=3 --variable theme=metropolis --pdf-engine=xelatex -o "$(OUTPUT_DIR)/$(subst build-slides.pdf/,,$@).slides.pdf" "docs/$(subst build-slides.pdf/,,$@).md"
31+
endif
32+
33+
# Build HTML
34+
$(addprefix build-html/,$(obj)): build/qr
35+
mkdir -p "$(OUTPUT_DIR)"
36+
pandoc --to markdown --shift-heading-level-by=-1 --resource-path=docs --standalone "docs/$(subst build-html/,,$@).md" | pandoc --to html5 --citeproc --listings --shift-heading-level-by=1 --number-sections --resource-path=docs --toc --katex --self-contained --number-offset=1 -o "$(OUTPUT_DIR)/$(subst build-html/,,$@).html"
37+
38+
# Build HTML slides
39+
$(addprefix build-slides.html/,$(obj)): build/qr
40+
mkdir -p "$(OUTPUT_DIR)"
41+
pandoc --to slidy --citeproc --listings --shift-heading-level-by=-1 --number-sections --resource-path=docs --toc --katex --self-contained -o "$(OUTPUT_DIR)/$(subst build-slides.html/,,$@).slides.html" "docs/$(subst build-slides.html/,,$@).md"
42+
43+
# Build EPUB
44+
$(addprefix build-epub/,$(obj)): build/qr
45+
mkdir -p "$(OUTPUT_DIR)"
46+
pandoc --to epub --citeproc --listings --shift-heading-level-by=-1 --number-sections --resource-path=docs -M titlepage=true -M toc=true -M toc-own-page=true -M linkcolor=midnightblue -o "$(OUTPUT_DIR)/$(subst build-epub/,,$@).epub" "docs/$(subst build-epub/,,$@).md"
47+
48+
# Build ODT
49+
$(addprefix build-odt/,$(obj)): build/qr
50+
mkdir -p "$(OUTPUT_DIR)"
51+
pandoc --to odt --citeproc --listings --shift-heading-level-by=-1 --number-sections --resource-path=docs -M titlepage=true -M toc=true -M toc-own-page=true -M linkcolor=midnightblue -o "$(OUTPUT_DIR)/$(subst build-odt/,,$@).odt" "docs/$(subst build-odt/,,$@).md"
52+
53+
# Build Gemtext
54+
$(addprefix build-gmi/,$(obj)): build/qr
55+
rm -rf "$(OUTPUT_DIR)/$(subst build-gmi/,,$@).gmi"
56+
mkdir -p "$(OUTPUT_DIR)/$(subst build-gmi/,,$@).gmi"
57+
cd "$(OUTPUT_DIR)/$(subst build-gmi/,,$@).gmi" && pandoc --to html --citeproc --extract-media static --metadata title="intermediate" --resource-path="../../docs" "../../docs/$(subst build-gmi/,,$@).md" | pandoc --read html --to gfm-raw_html | md2gemini -a -p -s | sed -e 's@^=> static/static/@=>static/@g' > "$(subst build-gmi/,,$@).gmi" && [ -d static/static ] && mv -f static/static/* static/; rm -rf static/static
58+
tar -I 'gzip -9' -cvf "$(OUTPUT_DIR)/$(subst build-gmi/,,$@).gmi.gz" -C "$(OUTPUT_DIR)/$(subst build-gmi/,,$@).gmi" .
59+
rm -rf "$(OUTPUT_DIR)/$(subst build-gmi/,,$@).gmi"
60+
61+
# Build txt
62+
$(addprefix build-txt/,$(obj)): build/qr
63+
mkdir -p "$(OUTPUT_DIR)"
64+
pandoc --to plain --citeproc --listings --shift-heading-level-by=-1 --number-sections --resource-path=docs --toc --self-contained -o "$(OUTPUT_DIR)/$(subst build-txt/,,$@).txt" "docs/$(subst build-txt/,,$@).md"
65+
66+
# Build metadata
67+
build/metadata:
68+
mkdir -p "$(OUTPUT_DIR)"
69+
ifneq ("$(origin_exists)", "")
70+
cp ORIGIN.txt "$(OUTPUT_DIR)"/ORIGIN.txt
71+
else ifneq ("$(is_git_repo)", "")
72+
git remote get-url origin > "$(OUTPUT_DIR)"/ORIGIN.txt
73+
else
74+
echo "file://$(current_dir)" > "$(OUTPUT_DIR)"/ORIGIN.txt
75+
endif
76+
ifneq ("$(changelog_exists)", "")
77+
cp CHANGELOG.txt "$(OUTPUT_DIR)"/CHANGELOG.txt
78+
else ifneq ("$(is_git_repo)", "")
79+
git log > "$(OUTPUT_DIR)"/CHANGELOG.txt
80+
else
81+
touch "$(OUTPUT_DIR)"/CHANGELOG.txt
82+
endif
83+
cp LICENSE "$(OUTPUT_DIR)"/LICENSE.txt
84+
$(foreach mt,$(mta),pandoc --to markdown --shift-heading-level-by=-1 --standalone "$(mt)" | pandoc --to html5 --citeproc --listings --shift-heading-level-by=1 --number-sections --resource-path=docs --toc --katex --self-contained --number-offset=1 -o "$(OUTPUT_DIR)/$(subst .md,.html,$(mt))";)
85+
86+
# Build QR code
87+
build/qr:
88+
mkdir -p docs/static
89+
ifneq ("$(origin_exists)", "")
90+
qr "$(shell cat ORIGIN.txt)" > docs/static/qr.png
91+
else ifneq ("$(is_git_repo)", "")
92+
qr "https://$(shell git remote get-url origin | sed -r 's|^.*@(.*):|\1/|g' | sed 's@.*://@@g' | sed 's/.git$$//g')" > docs/static/qr.png
93+
else
94+
qr "file://$(current_dir)" > docs/static/qr.png
95+
endif
96+
97+
# Build tarball
98+
build/tarball: build/qr build/metadata
99+
mkdir -p "$(OUTPUT_DIR)"
100+
tar cvf "$(OUTPUT_DIR)"/source.tar --exclude-from=.gitignore --exclude=.git --exclude="$(OUTPUT_DIR)" .
101+
tar uvf "$(OUTPUT_DIR)"/source.tar ./Makefile
102+
tar uvf "$(OUTPUT_DIR)"/source.tar -C "$(OUTPUT_DIR)" ./CHANGELOG.txt ./ORIGIN.txt
103+
gzip -9 < "$(OUTPUT_DIR)"/source.tar > "$(OUTPUT_DIR)"/source.tar.gz
104+
rm "$(OUTPUT_DIR)"/source.tar
105+
106+
# Build tree
107+
build/tree: $(addprefix build/,$(obj)) build/tarball
108+
mkdir -p "$(OUTPUT_DIR)"
109+
ifneq ("$(origin_exists)", "")
110+
cd "$(OUTPUT_DIR)" && tree -T "$(shell cat ORIGIN.txt | sed -r 's|^.*@(.*):|\1/|g' | sed 's@.*://@@g' | sed 's/.git$$//g')" --du -h -D -H . -I 'index.html|release.tar.gz|release.zip' -o "index.html"
111+
else ifneq ("$(is_git_repo)", "")
112+
cd "$(OUTPUT_DIR)" && tree -T "$(shell git remote get-url origin | sed -r 's|^.*@(.*):|\1/|g' | sed 's@.*://@@g' | sed 's/.git$$//g')" --du -h -D -H . -I 'index.html|release.tar.gz|release.zip' -o "index.html"
113+
else
114+
cd "$(OUTPUT_DIR)" && tree -T "$(notdir $(patsubst %/,%,$(current_dir)))" --du -h -D -H . -I 'index.html|release.tar.gz|release.zip' -o "index.html"
115+
endif
116+
117+
# Build archive
118+
build/archive: build/tree
119+
mkdir -p "$(OUTPUT_DIR)"
120+
tar -I 'gzip -9' -cvf "$(OUTPUT_DIR)"/release.tar.gz -C "$(OUTPUT_DIR)" --exclude="release.tar.gz" --exclude="release.zip" $(shell ls $(OUTPUT_DIR))
121+
rm -f "$(OUTPUT_DIR)"/release.zip
122+
zip -9 -j -x 'release.tar.gz' -x 'release.zip' -FSr "$(OUTPUT_DIR)"/release.zip "$(OUTPUT_DIR)"/*
123+
124+
# Open
125+
$(foreach o,$(obj),$(foreach f,$(formats),open-$(f)/$(o))):
126+
xdg-open "$(OUTPUT_DIR)/$(notdir $(subst open-,,$@)).$(subst /,,$(dir $(subst open-,,$@)))"
127+
128+
# Develop
129+
dev: build
130+
while inotifywait -r -e close_write --exclude 'out' .; do $(MAKE); done
131+
$(foreach o,$(obj),$(foreach f,$(formats),dev-$(f)/$(o))):
132+
$(MAKE) $(subst dev-,build-,$@)
133+
while inotifywait -r -e close_write --exclude 'out' .; do $(MAKE) $(subst dev-,build-,$@); done
26134

135+
# Clean
27136
clean:
28-
rm -rf out
137+
rm -rf "$(OUTPUT_DIR)" docs/static/qr.png
29138

139+
# Dependencies
30140
depend:
31-
docker pull pandoc/latex
141+
pip install pillow qrcode md2gemini
142+
curl -L -o /tmp/Eisvogel.zip 'https://github.com/Wandmalfarbe/pandoc-latex-template/releases/latest/download/Eisvogel.zip'
143+
mkdir -p "$${HOME}/.local/share/pandoc/templates"
144+
unzip -p /tmp/Eisvogel.zip eisvogel.latex > "$${HOME}/.local/share/pandoc/templates/eisvogel.latex"

README.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
11
# Uni Algodat Notes
22

3-
Personal notes and snippets for the Algorithms and Data Structures course at HdM Stuttgart.
3+
Notes for the Anwendungssicherheit (app security) course at HdM Stuttgart.
44

5-
[![pandoc CI](https://github.com/pojntfx/uni-algodat-notes/actions/workflows/pandoc.yaml/badge.svg)](https://github.com/pojntfx/uni-algodat-notes/actions/workflows/pandoc.yaml)
5+
[![Deliverance CI](https://github.com/pojntfx/uni-algodat-notes/actions/workflows/deliverance.yaml/badge.svg)](https://github.com/pojntfx/uni-algodat-notes/actions/workflows/deliverance.yaml)
66

77
## Overview
88

9-
In addition to the code example in this repo, you can also [view and download the notes from GitHub pages](https://pojntfx.github.io/uni-algodat-notes/). They can also be downloaded as a Zip archive from [GitHub releases](https://github.com/pojntfx/uni-algodat-notes/releases).
9+
You can [view the notes on GitHub pages](https://pojntfx.github.io/uni-algodat-notes/), [download them from GitHub releases](https://github.com/pojntfx/uni-algodat-notes/releases/latest) or [check out the source on GitHub](https://github.com/pojntfx/uni-algodat-notes). There are also quite a few code examples in this repo.
10+
11+
## Contributing
12+
13+
To contribute, please use the [GitHub flow](https://guides.github.com/introduction/flow/) and follow our [Code of Conduct](./CODE_OF_CONDUCT.md).
14+
15+
To build and open a note locally, run the following:
16+
17+
```shell
18+
$ git clone https://github.com/pojntfx/uni-algodat-notes.git
19+
$ cd uni-algodat-notes
20+
$ ./configure
21+
$ make depend
22+
$ make dev-pdf/your-note # Use Bash completion to list available targets
23+
# In another terminal
24+
$ make open-pdf/your-note # Use Bash completion to list available targets
25+
```
26+
27+
The note should now be opened. Whenever you change a source file, it will automatically be re-compiled.
1028

1129
## License
1230

13-
Uni Algodat Notes (c) 2021 Felicitas Pojtinger and contributors
31+
Uni Algodat Notes (c) 2022 Felicitas Pojtinger and contributors
1432

1533
SPDX-License-Identifier: AGPL-3.0

configure

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
curl -LO https://github.com/pojntfx/deliverance/releases/latest/download/Makefile

docs/main.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
% Uni Algodat Notes
2-
% Felicitas Pojtinger
3-
% \today
4-
\tableofcontents
1+
---
2+
author: [Felicitas Pojtinger]
3+
date: "2022-02-01"
4+
subject: "Uni Algodat Notes"
5+
keywords: [algorithms, time-complexity, hdm-stuttgart]
6+
subtitle: "Notes for the Algodat (algorithms and data structures) course at HdM Stuttgart"
7+
lang: "de"
8+
---
59

610
# Uni Algodat Notes
711

0 commit comments

Comments
 (0)