diff options
author | Volpeon <git@volpeon.ink> | 2021-05-10 16:41:05 +0200 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2021-05-10 16:41:05 +0200 |
commit | a48d05d1d5fcff414359c8ba6cc8f38467aebdeb (patch) | |
tree | 3542bf116c910a1bb42b40d8531f60c2c2498b08 | |
parent | Update (diff) | |
download | volpeon.ink-a48d05d1d5fcff414359c8ba6cc8f38467aebdeb.tar.gz volpeon.ink-a48d05d1d5fcff414359c8ba6cc8f38467aebdeb.tar.bz2 volpeon.ink-a48d05d1d5fcff414359c8ba6cc8f38467aebdeb.zip |
Refactoring to fully take advantage of Make
33 files changed, 266 insertions, 623 deletions
@@ -1,4 +1,5 @@ | |||
1 | assets/favicon/*.png | 1 | assets/favicon/*.png |
2 | assets/favicon/*.ico | 2 | assets/favicon/*.ico |
3 | node_modules | 3 | node_modules |
4 | output | 4 | .cache |
5 | out | ||
diff --git a/.lua-format b/.lua-format new file mode 100644 index 0000000..64a9b5c --- /dev/null +++ b/.lua-format | |||
@@ -0,0 +1,5 @@ | |||
1 | column_limit: 100 | ||
2 | align_args: false | ||
3 | align_parameter: false | ||
4 | spaces_inside_table_braces: true | ||
5 | extra_sep_at_table_end: true | ||
@@ -1,55 +1,127 @@ | |||
1 | all: build | 1 | export DEPLOY_TARGET = "vulpes@94.130.78.123:/srv/http/volpeon.ink/" |
2 | |||
3 | -include Env.mk | ||
4 | |||
5 | # | ||
6 | # FILE GROUPS | ||
7 | # | ||
8 | |||
9 | PANDOC_FILTERS := $(patsubst %,--lua-filter %,$(wildcard filters/*.lua)) | ||
10 | GLOBAL_METADATA := $(patsubst %,--metadata-file %,$(wildcard metadata/*.yaml)) | ||
11 | |||
12 | CONTENT_SRC := $(shell find content -type f -name "*.md") | ||
13 | TEMPLATES_SRC := $(shell find templates -type f -name "*.html") | ||
14 | CSS_SRC := $(shell find assets/css -type f -name "*.scss") | ||
15 | |||
16 | CONTENT_META := $(patsubst content/%.md,.cache/meta/%.json,$(CONTENT_SRC)) | ||
17 | CONTENT_FILES := $(patsubst content/%.md,out/%.html,$(CONTENT_SRC)) | ||
18 | FONT_FILES := $(patsubst assets/fonts/%.ttf,out/%.woff2,$(wildcard assets/fonts/*.ttf)) | ||
19 | CSS_FILES := $(patsubst assets/css/%.scss,out/%.css,$(wildcard assets/css/style.scss)) | ||
20 | STATIC_FILES := $(patsubst content/%,out/%,$(shell find content -type f ! -name "*.md")) | ||
21 | |||
22 | # | ||
23 | # TARGETS | ||
24 | # | ||
25 | |||
26 | all: content_meta content_files static_files font_files css_files | ||
27 | |||
28 | content_meta: $(CONTENT_META) | ||
29 | content_files: $(CONTENT_FILES) | ||
30 | static_files: $(STATIC_FILES) | ||
31 | font_files: $(FONT_FILES) | ||
32 | css_files: $(CSS_FILES) | ||
33 | |||
34 | # | ||
35 | # RULES | ||
36 | # | ||
37 | |||
38 | .SECONDEXPANSION: | ||
39 | |||
40 | namespace = $(patsubst %/index,%,$(patsubst %.json,%,$(patsubst $(2)%,%,$(1)))) | ||
41 | |||
42 | subpages = $(patsubst content/%.md,.cache/meta/%.json, \ | ||
43 | $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -maxdepth 1 -type f -name "*.md" ! -name "index.md") \ | ||
44 | $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -mindepth 2 -maxdepth 2 -type f -name "index.md")) | ||
45 | |||
46 | .cache/meta/%.json: content/%.md $$(call subpages,$$(call namespace,$$@,)) scripts/subpages.jq | .cache/meta | ||
47 | $(info [META] $< -> $@) | ||
48 | |||
49 | mkdir -p $(@D) | ||
50 | $(eval PAGES_FILES = $(filter .cache/meta/%.json,$^)) | ||
51 | $(eval PAGES = $(shell mktemp)) | ||
52 | $(eval NAMESPACE = $(call namespace,$@,.cache/meta)) | ||
53 | $(file >$(PAGES),$(if $(PAGES_FILES),$(shell jq -s --arg namespace "$(NAMESPACE)" -f scripts/subpages.jq $(PAGES_FILES)),)) | ||
54 | pandoc \ | ||
55 | -f markdown-citations \ | ||
56 | -t plain \ | ||
57 | --no-highlight \ | ||
58 | --template scripts/metadata_tpl.json \ | ||
59 | --metadata namespace="$(NAMESPACE)" \ | ||
60 | --metadata file_out="$(patsubst .cache/meta/%.json,out/%.html,$@)" \ | ||
61 | --metadata-file "$(PAGES)" \ | ||
62 | -o "$@" "$<" | ||
63 | rm "$(PAGES)" | ||
64 | |||
65 | out/%.html: content/%.md .cache/meta/%.json $(TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata_filter.lua | out | ||
66 | $(info [MARK] $< -> $@) | ||
67 | |||
68 | mkdir -p $(@D) | ||
69 | pandoc \ | ||
70 | -f markdown-citations \ | ||
71 | -t html5 \ | ||
72 | --no-highlight \ | ||
73 | --template templates/base.html \ | ||
74 | --lua-filter scripts/metadata_filter.lua \ | ||
75 | $(GLOBAL_METADATA) \ | ||
76 | --metadata-file "$(filter .cache/meta/%.json,$^)" \ | ||
77 | $(PANDOC_FILTERS) \ | ||
78 | -o "$@" "$<" | ||
79 | |||
80 | out/%: content/% | out | ||
81 | $(info [COPY] $< -> $@) | ||
82 | |||
83 | mkdir -p $(@D) | ||
84 | cp "$<" "$@" | ||
85 | |||
86 | out/%.woff2: assets/fonts/%.ttf assets/fonts/glyphs.txt | out | ||
87 | $(info [FONT] $< -> $@) | ||
88 | |||
89 | pyftsubset "$<" \ | ||
90 | --text-file="assets/fonts/glyphs.txt" \ | ||
91 | --layout-features+=ss02,ss09,dlig \ | ||
92 | --flavor="woff2" \ | ||
93 | --output-file="$@" | ||
94 | |||
95 | out/%.css: assets/css/%.scss $(CSS_SRC) | out | ||
96 | $(info [SCSS] $< -> $@) | ||
97 | |||
98 | sassc -t compressed "$<" | ./node_modules/.bin/postcss --use autoprefixer --no-map > "$@" | ||
99 | |||
100 | .cache/meta: .cache | ||
101 | mkdir -p .cache/meta | ||
102 | |||
103 | .cache/pages: .cache | ||
104 | mkdir -p .cache/pages | ||
105 | |||
106 | .cache: | ||
107 | mkdir -p .cache | ||
108 | |||
109 | out: | ||
110 | mkdir -p out | ||
111 | |||
112 | # | ||
113 | # UTILITIES | ||
114 | # | ||
115 | |||
116 | compress: all | ||
117 | pigz -R -k -9 -- `find out -type f -iregex '.*\\.\\(css\\|js\\|json\\|html\\|xml\\|txt\\|svg\\|ico\\)'` | ||
118 | brotli -k -- `find out -type f -iregex '.*\\.\\(css\\|js\\|json\\|html\\|xml\\|txt\\|svg\\|ico\\|woff\\)'` | ||
119 | |||
120 | serve: all | ||
121 | python -m http.server --directory out 8000 | ||
122 | |||
123 | #deploy: compress | ||
124 | # rsync --progress --stats -rvz --delete out "$(DEPLOY_TARGET)" | ||
2 | 125 | ||
3 | clean: | 126 | clean: |
4 | @mkdir -p output | 127 | rm -rf out |
5 | @rm -rf output/* | ||
6 | |||
7 | build_fonts: clean | ||
8 | @scripts/build_fonts.sh | ||
9 | |||
10 | build_sass: clean | ||
11 | @scripts/build_sass.sh | ||
12 | |||
13 | build_content: clean | ||
14 | @scripts/build_content.sh | ||
15 | |||
16 | build_only: build_fonts build_sass build_content | ||
17 | |||
18 | compress_gz: build_only | ||
19 | @echo -e "\033[0;32m[COMPRESS]\033[0m Gzip" | ||
20 | @pigz -R -k -9 -- `find output -type f -iregex '.*\\.\\(css\\|js\\|json\\|html\\|xml\\|txt\\|svg\\|ico\\)'` | ||
21 | |||
22 | compress_br: build_only | ||
23 | @echo -e "\033[0;32m[COMPRESS]\033[0m Brotli" | ||
24 | @brotli -k -- `find output -type f -iregex '.*\\.\\(css\\|js\\|json\\|html\\|xml\\|txt\\|svg\\|ico\\|woff\\)'` | ||
25 | |||
26 | build: export LIVE=false | ||
27 | build: compress_gz compress_br | ||
28 | |||
29 | watch_sass: build_only | ||
30 | @scripts/watch_sass.sh | ||
31 | |||
32 | watch_content: build_only | ||
33 | @scripts/watch_content.sh | ||
34 | |||
35 | watch_templates: build_only | ||
36 | @scripts/watch_templates.sh | ||
37 | |||
38 | watch_metadata: build_only | ||
39 | @scripts/watch_metadata.sh | ||
40 | |||
41 | watch_filters: build_only | ||
42 | @scripts/watch_filters.sh | ||
43 | |||
44 | watch: export LIVE=true | ||
45 | watch: watch_sass watch_content watch_templates watch_metadata watch_filters | ||
46 | |||
47 | serve_only: build_only | ||
48 | @python -m http.server --bind 127.0.0.1 --directory output | ||
49 | |||
50 | serve: watch serve_only | ||
51 | |||
52 | deploy: build | ||
53 | @scripts/deploy.sh | ||
54 | |||
55 | .PHONY: all clean build watch serve deploy | ||
diff --git a/assets/css/_basics.scss b/assets/css/_basics.scss index b2a437b..573167c 100644 --- a/assets/css/_basics.scss +++ b/assets/css/_basics.scss | |||
@@ -138,13 +138,10 @@ h3, | |||
138 | h4, | 138 | h4, |
139 | h5, | 139 | h5, |
140 | h6 { | 140 | h6 { |
141 | margin: ($line-height * 2rem) 0 0; | 141 | margin: ($line-height * 2rem) 0 0; |
142 | color: var(--heading--fg); | 142 | color: var(--heading--fg); |
143 | font-family: $font-fam--large; | 143 | font-size: 1em; |
144 | font-size: 1em; | 144 | font-weight: 700; |
145 | font-weight: 600; | ||
146 | line-height: 1.4; | ||
147 | font-feature-settings: 'ss02' 1; | ||
148 | 145 | ||
149 | & + & { | 146 | & + & { |
150 | margin-top: $line-height * 1rem; | 147 | margin-top: $line-height * 1rem; |
diff --git a/assets/css/_vars.scss b/assets/css/_vars.scss index 3adce04..0df3a61 100644 --- a/assets/css/_vars.scss +++ b/assets/css/_vars.scss | |||
@@ -14,7 +14,7 @@ $unit-intervals: ( | |||
14 | 14 | ||
15 | $responsive-mod-scale: ( | 15 | $responsive-mod-scale: ( |
16 | xs: (.8rem, 1.35), | 16 | xs: (.8rem, 1.35), |
17 | md: (.8rem, 1.58) | 17 | md: (.8rem, 1.53) |
18 | ); | 18 | ); |
19 | 19 | ||
20 | $font-fam--text: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif; | 20 | $font-fam--text: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif; |
diff --git a/assets/css/components/_outer-button.scss b/assets/css/components/_outer-button.scss index 22fa251..e54c83d 100644 --- a/assets/css/components/_outer-button.scss +++ b/assets/css/components/_outer-button.scss | |||
@@ -24,7 +24,8 @@ | |||
24 | transition: background-color .2s, color .2s; | 24 | transition: background-color .2s, color .2s; |
25 | background-color: prop(--colors --bg); | 25 | background-color: prop(--colors --bg); |
26 | color: prop(--colors --fg); | 26 | color: prop(--colors --fg); |
27 | font-size: 1 / 16 * 15rem; | 27 | font-size: 1rem; |
28 | font-weight: 700; | ||
28 | letter-spacing: 1px; | 29 | letter-spacing: 1px; |
29 | text-decoration: none; | 30 | text-decoration: none; |
30 | text-transform: uppercase; | 31 | text-transform: uppercase; |
@@ -51,8 +52,8 @@ | |||
51 | 52 | ||
52 | @include element('icon-symbol') { | 53 | @include element('icon-symbol') { |
53 | display: block; | 54 | display: block; |
54 | width: 1.45em; | 55 | width: 1.5em; |
55 | height: 1.45em; | 56 | height: 1.5em; |
56 | } | 57 | } |
57 | 58 | ||
58 | @include element('content') { | 59 | @include element('content') { |
@@ -60,6 +61,7 @@ | |||
60 | padding-right: prop(--dims --pad-x); | 61 | padding-right: prop(--dims --pad-x); |
61 | padding-left: prop(--dims --pad-x); | 62 | padding-left: prop(--dims --pad-x); |
62 | transition: border-color .2s; | 63 | transition: border-color .2s; |
64 | font-size: 1 / 16 * 14em; | ||
63 | line-height: prop(--dims --outer, $global: true); | 65 | line-height: prop(--dims --outer, $global: true); |
64 | white-space: nowrap; | 66 | white-space: nowrap; |
65 | } | 67 | } |
diff --git a/assets/css/scopes/_body.scss b/assets/css/scopes/_body.scss index 8e5f876..96231ad 100644 --- a/assets/css/scopes/_body.scss +++ b/assets/css/scopes/_body.scss | |||
@@ -11,12 +11,11 @@ | |||
11 | font-size: 1 / 16 * 19em; | 11 | font-size: 1 / 16 * 19em; |
12 | 12 | ||
13 | @include element('meta') { | 13 | @include element('meta') { |
14 | margin-top: $line-height * 1rem; | 14 | color: prop(--colors --meta --fg); |
15 | color: prop(--colors --meta --fg); | 15 | font-size: 1 / 16 * 15rem; |
16 | font-size: 1 / 16 * 15rem; | ||
17 | 16 | ||
18 | + * { | 17 | + h1 { |
19 | margin-top: $line-height * 1.5rem; | 18 | margin-top: $line-height * .5rem; |
20 | } | 19 | } |
21 | } | 20 | } |
22 | 21 | ||
diff --git a/assets/css/scopes/_headlines.scss b/assets/css/scopes/_headlines.scss index 6b28e9c..8b75708 100644 --- a/assets/css/scopes/_headlines.scss +++ b/assets/css/scopes/_headlines.scss | |||
@@ -11,6 +11,18 @@ | |||
11 | h1, | 11 | h1, |
12 | h2, | 12 | h2, |
13 | h3, | 13 | h3, |
14 | h4, | ||
15 | h5, | ||
16 | h6 { | ||
17 | font-family: $font-fam--large; | ||
18 | font-weight: 600; | ||
19 | line-height: 1.4; | ||
20 | font-feature-settings: 'ss02' 1; | ||
21 | } | ||
22 | |||
23 | h1, | ||
24 | h2, | ||
25 | h3, | ||
14 | h4 { | 26 | h4 { |
15 | transform: translateX(-.06em); | 27 | transform: translateX(-.06em); |
16 | } | 28 | } |
diff --git a/content/personal/dre-infinite-skyscrapers/index.md b/content/9thPK7O3xn/dre-infinite-skyscrapers.md index ca30329..32f34ab 100644 --- a/content/personal/dre-infinite-skyscrapers/index.md +++ b/content/9thPK7O3xn/dre-infinite-skyscrapers.md | |||
@@ -1,7 +1,7 @@ | |||
1 | --- | 1 | --- |
2 | date: 2021-01-09 | 2 | date: 2021-01-09 |
3 | title: Infinite Skyscrapers | 3 | title: Infinite Skyscrapers |
4 | category: dre | 4 | category: dreams |
5 | --- | 5 | --- |
6 | 6 | ||
7 | I'm in some strange world that consist of huge buildings, looking a lot like very simple skyscrapers, except they were all interconnected. | 7 | I'm in some strange world that consist of huge buildings, looking a lot like very simple skyscrapers, except they were all interconnected. |
diff --git a/content/personal/index.md b/content/9thPK7O3xn/index.md index dd7423d..2545092 100644 --- a/content/personal/index.md +++ b/content/9thPK7O3xn/index.md | |||
@@ -1,7 +1,6 @@ | |||
1 | --- | 1 | --- |
2 | title: Personal | 2 | title: Personal |
3 | layout: categorized_list | 3 | layout: categorized_list |
4 | create_feed: true | ||
5 | --- | 4 | --- |
6 | 5 | ||
7 | Welcome to the personal section of my website! | 6 | Welcome to the personal section of my website! |
diff --git a/content/personal/mis-design-test/index.md b/content/9thPK7O3xn/mis-design-test.md index c31e42d..687d215 100644 --- a/content/personal/mis-design-test/index.md +++ b/content/9thPK7O3xn/mis-design-test.md | |||
@@ -1,6 +1,6 @@ | |||
1 | --- | 1 | --- |
2 | title: "Design Test: Markdown Syntax" | 2 | title: "Design Test: Markdown Syntax" |
3 | category: mis | 3 | category: misc |
4 | --- | 4 | --- |
5 | 5 | ||
6 | - [Overview](#overview) | 6 | - [Overview](#overview) |
diff --git a/content/index.js b/content/index.js deleted file mode 100644 index e03dec1..0000000 --- a/content/index.js +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | var headerEl = document.querySelector(".c-hero"); | ||
2 | var headerTemplateEl = document.getElementById("header-sm"); | ||
3 | var headerSmEl = headerTemplateEl.content.cloneNode("true"); | ||
4 | |||
5 | headerEl.classList.remove("u-dn@sm-down"); | ||
6 | headerEl.appendChild(headerSmEl); | ||
diff --git a/content/index.md b/content/index.md index e144d39..1d9b360 100644 --- a/content/index.md +++ b/content/index.md | |||
@@ -1,3 +1,4 @@ | |||
1 | --- | 1 | --- |
2 | title: Home | 2 | title: Home |
3 | --- | 3 | --- |
4 | \ No newline at end of file | ||
diff --git a/content/profiles/index.md b/content/profiles/index.md deleted file mode 100644 index 9a9d7fa..0000000 --- a/content/profiles/index.md +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | --- | ||
2 | title: Profiles | ||
3 | --- | ||
4 | |||
5 | - **Bandcamp:** [volpeon](https://bandcamp.com/volpeon) | ||
6 | - **Email:** me@volpeon.ink | ||
7 | - **Fediverse:** @volpeon@fedi.vulpes.one | ||
8 | - **GitHub:** [volpeon](https://github.com/volpeon) | ||
9 | - **IRC:** volpeon on [Furnet](irc://irc.furnet.org), [Freenode](ircs://chat.freenode.net), [irc.vulpes.one](ircs://irc.vulpes.one) | ||
10 | - **PeerTube:** @volpeon@pt.vulpes.one | ||
11 | - **Steam:** [volpeon](https://steamcommunity.com/id/volpeon/) | ||
12 | - **XMPP:** <available> | ||
13 | |||
14 | ## OMEMO Fingerprints | ||
15 | |||
16 | ```plain | ||
17 | CB07051B E223EF70 8EE8F665 BBFCEF00 83415C45 DCA31906 F2362543 F5543449 | ||
18 | C2C575EE 0236965C 4DBAA7EA 12F9EC90 AFD57B2C F75B3F32 70F3D393 2EDA3A08 | ||
19 | ``` | ||
diff --git a/content/projects/blobfox-emojis/index.md b/content/projects/blobfox-emojis/index.md index 44fd1e7..5a4fff1 100644 --- a/content/projects/blobfox-emojis/index.md +++ b/content/projects/blobfox-emojis/index.md | |||
@@ -1,7 +1,7 @@ | |||
1 | --- | 1 | --- |
2 | title: Blobfox | 2 | title: Blobfox |
3 | category: emj | 3 | category: emojis |
4 | preview: preview.jpg | 4 | preview: preview.jpg |
5 | --- | 5 | --- |
6 | 6 | ||
7 | ![](screenshot.png) | 7 | ![](screenshot.png) |
diff --git a/content/projects/bunhd-emojis/index.md b/content/projects/bunhd-emojis/index.md index 75d4b3f..94278c1 100644 --- a/content/projects/bunhd-emojis/index.md +++ b/content/projects/bunhd-emojis/index.md | |||
@@ -1,7 +1,7 @@ | |||
1 | --- | 1 | --- |
2 | title: BunHD | 2 | title: BunHD |
3 | category: emj | 3 | category: emojis |
4 | preview: preview.png | 4 | preview: preview.png |
5 | --- | 5 | --- |
6 | 6 | ||
7 | ![](screenshot.png) | 7 | ![](screenshot.png) |
diff --git a/content/projects/index.md b/content/projects/index.md index 7316d55..1a33149 100644 --- a/content/projects/index.md +++ b/content/projects/index.md | |||
@@ -1,12 +1,4 @@ | |||
1 | --- | 1 | --- |
2 | title: Projects | 2 | title: Projects |
3 | layout: categorized_list | 3 | layout: categorized_list |
4 | --- | 4 | --- |
5 | |||
6 | ## Web services | ||
7 | |||
8 | ::: {macro=refs} | ||
9 | - [Gopher + Gemini Proxy](//proxy.vulpes.one/) | ||
10 | - [IRC Web Client](//irc.vulpes.one/) | ||
11 | - [PeerTube Livestream Chat](//lsirc.vulpes.one/) | ||
12 | ::: | ||
diff --git a/metadata/metadata.yaml b/metadata/metadata.yaml index 86b5c66..78cb1e8 100644 --- a/metadata/metadata.yaml +++ b/metadata/metadata.yaml | |||
@@ -7,38 +7,28 @@ author: | |||
7 | 7 | ||
8 | menus: | 8 | menus: |
9 | main: | 9 | main: |
10 | - id: projects | 10 | - id: projects |
11 | label: Projects | 11 | label: Projects |
12 | url: /#projects | 12 | url: /#projects |
13 | 13 | ||
14 | - id: personal | 14 | - id: 9thPK7O3xn |
15 | label: Personal | 15 | label: Personal |
16 | label_long: Personal Notebook | 16 | url: /9thPK7O3xn/ |
17 | url: /personal/ | 17 | hidden: true |
18 | hidden: true | ||
19 | |||
20 | feeds: | ||
21 | - title: Notebook | ||
22 | url: /notebook/index.xml | ||
23 | 18 | ||
24 | categories: | 19 | categories: |
25 | personal: | 20 | 9thPK7O3xn: |
26 | dre: | 21 | dreams: |
27 | name: Dream Journal | 22 | name: Dream Journal |
28 | show_date: true | 23 | show_date: true |
29 | mis: | 24 | misc: |
30 | name: Sonstiges | 25 | name: Sonstiges |
31 | 26 | ||
32 | projects: | 27 | projects: |
33 | emj: | 28 | emojis: |
34 | name: Emojis | 29 | name: Emojis |
35 | icon: smile | 30 | icon: smile |
36 | 31 | ||
37 | rewrites: | ||
38 | path: | ||
39 | - from: ^/personal | ||
40 | to: /9thPK7O3xn | ||
41 | |||
42 | profiles: | 32 | profiles: |
43 | - platform: Bandcamp | 33 | - platform: Bandcamp |
44 | icon: parallelogram | 34 | icon: parallelogram |
diff --git a/scripts/build_content.sh b/scripts/build_content.sh deleted file mode 100755 index 3dea44f..0000000 --- a/scripts/build_content.sh +++ /dev/null | |||
@@ -1,222 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | source "site.defaults.conf" | ||
4 | |||
5 | get_filters() { | ||
6 | local filters_args="" | ||
7 | |||
8 | mapfile -d $'\0' filters < <(find $FILTERS_DIR \ | ||
9 | -type f \ | ||
10 | -name "*.lua" ! -name ".*" \ | ||
11 | -print0) | ||
12 | |||
13 | for file in "${filters[@]}"; do | ||
14 | filters_args="$filters_args --lua-filter $file" | ||
15 | done | ||
16 | |||
17 | echo "$filters_args" | ||
18 | } | ||
19 | |||
20 | FILTERS=$(get_filters) | ||
21 | |||
22 | get_filename_out() { | ||
23 | local filename=$1 | ||
24 | filename=${filename#"$CONTENT_DIR"} | ||
25 | echo "$OUTPUT_DIR$filename" | ||
26 | } | ||
27 | |||
28 | get_metadata() { | ||
29 | pandoc "$1" \ | ||
30 | -f markdown-citations \ | ||
31 | -t plain \ | ||
32 | --metadata content_dir="$CONTENT_DIR" \ | ||
33 | --metadata file_in="$1" \ | ||
34 | --metadata relative_to="$2" \ | ||
35 | --metadata-file metadata/metadata.yaml \ | ||
36 | --no-highlight \ | ||
37 | --template scripts/metadata_tpl.json \ | ||
38 | --lua-filter scripts/metadata_filter.lua | ||
39 | } | ||
40 | |||
41 | get_content() { | ||
42 | pandoc "$1" \ | ||
43 | -f markdown-citations \ | ||
44 | -t markdown \ | ||
45 | --metadata content_dir="$CONTENT_DIR" \ | ||
46 | --metadata file_in="$1" \ | ||
47 | --metadata-file metadata/metadata.yaml \ | ||
48 | --no-highlight \ | ||
49 | --lua-filter scripts/metadata_filter.lua | ||
50 | } | ||
51 | |||
52 | get_subpages_metadata() { | ||
53 | local base_dir_in=${1%/index.md} | ||
54 | local relative_to="$2" | ||
55 | if [ -z "$2" ]; then | ||
56 | relative_to="$1" | ||
57 | fi | ||
58 | local child_pages=() | ||
59 | |||
60 | if [ -d "$base_dir_in" ]; then | ||
61 | mapfile -d $'\0' child_pages < <(find "$base_dir_in" \ | ||
62 | -maxdepth 2 \ | ||
63 | -type f \ | ||
64 | -wholename "$base_dir_in/*/index.md" \ | ||
65 | ! -name "_*.md" \ | ||
66 | -print0) | ||
67 | fi | ||
68 | |||
69 | local pages="[]" | ||
70 | local subsections="{}" | ||
71 | |||
72 | for file_in in "${child_pages[@]}"; do | ||
73 | local subsection=$(basename "${file_in%/index.md}") | ||
74 | local content=$(get_content "$file_in" | sed -z 's/\\/\\\\/g;s/\n/\\n/g;s/"/\\"/g') | ||
75 | local metadata=$(get_metadata "$file_in" | jq "{ \ | ||
76 | file_out: .file_out, \ | ||
77 | url: .url, \ | ||
78 | author: .author, \ | ||
79 | title: .title, \ | ||
80 | date: .date, \ | ||
81 | last_update: .last_update, \ | ||
82 | category: .category, \ | ||
83 | preview: .preview, \ | ||
84 | content: \"$content\" \ | ||
85 | } | del(.[] | nulls)") | ||
86 | local title=$(echo "$metadata" | jq ".title") | ||
87 | local subpages="[]" | ||
88 | |||
89 | if [ -z "$2" ]; then | ||
90 | subpages=$(get_subpages_metadata "$file_in" "$1" | jq ".pages") | ||
91 | fi | ||
92 | |||
93 | pages=$(echo "$pages" | jq ". += [ $metadata ]") | ||
94 | subsections=$(echo "$subsections" | jq ". += { \"$subsection\": { title: $title, pages: $subpages } }") | ||
95 | done | ||
96 | |||
97 | echo "{ \"pages\": $pages, \"subsections\": $subsections }" | ||
98 | } | ||
99 | |||
100 | handle () { | ||
101 | if [ "${1#*.}" = "md" ]; then | ||
102 | local included_metadata=$(get_metadata "$1") | ||
103 | local file_out=$(echo "$included_metadata" | jq -r .file_out) | ||
104 | file_out="$OUTPUT_DIR${file_out#/}" | ||
105 | local create_feed=$(echo "$included_metadata" | jq -r .create_feed) | ||
106 | |||
107 | mkdir -p $(dirname "$file_out") | ||
108 | |||
109 | echo -e "\033[0;32m[COMPILE ]\033[0m $1 -> $file_out" | ||
110 | |||
111 | echo -e "\033[0;90m[COMPILE ]\033[0m Getting subpages" | ||
112 | |||
113 | local added_metadata=$(get_subpages_metadata "$1") | ||
114 | |||
115 | local meta_file=$(mktemp) | ||
116 | |||
117 | echo "$added_metadata" > "$meta_file" | ||
118 | |||
119 | if [ "$create_feed" = "true" ]; then | ||
120 | echo -e "\033[0;90m[COMPILE ]\033[0m Creating feed" | ||
121 | |||
122 | pandoc "$1" \ | ||
123 | -f markdown-citations \ | ||
124 | -t html5 \ | ||
125 | --no-highlight \ | ||
126 | --template "${TEMPLATES_DIR}feed.xml" \ | ||
127 | -o "${file_out%.html}.xml" \ | ||
128 | --metadata content_dir="$CONTENT_DIR" \ | ||
129 | --metadata file_in="$1" \ | ||
130 | --metadata page_type=feed \ | ||
131 | --metadata-file metadata/metadata.yaml \ | ||
132 | --metadata-file "$meta_file" \ | ||
133 | --lua-filter scripts/metadata_filter.lua | ||
134 | fi | ||
135 | |||
136 | echo -e "\033[0;90m[COMPILE ]\033[0m Creating page" | ||
137 | |||
138 | pandoc "$1" \ | ||
139 | -f markdown-citations \ | ||
140 | -t html5 \ | ||
141 | --no-highlight \ | ||
142 | --template "${TEMPLATES_DIR}base.html" \ | ||
143 | -o "$file_out" \ | ||
144 | --metadata content_dir="$CONTENT_DIR" \ | ||
145 | --metadata file_in="$1" \ | ||
146 | --metadata-file metadata/metadata.yaml \ | ||
147 | --metadata-file "$meta_file" \ | ||
148 | --lua-filter scripts/metadata_filter.lua \ | ||
149 | $FILTERS | ||
150 | |||
151 | # echo "$(pandoc "$1" \ | ||
152 | # -f markdown-citations \ | ||
153 | # -t plain \ | ||
154 | # --no-highlight \ | ||
155 | # --template scripts/metadata_tpl.json \ | ||
156 | # --metadata content_dir="$CONTENT_DIR" \ | ||
157 | # --metadata file_in="$1" \ | ||
158 | # --metadata-file metadata/metadata.yaml \ | ||
159 | # --metadata-file "$meta_file" \ | ||
160 | # --lua-filter scripts/metadata_filter.lua \ | ||
161 | # $FILTERS)" | ||
162 | |||
163 | rm "$meta_file" | ||
164 | |||
165 | echo -e "\033[0;90m[COMPILE ]\033[0m Done" | ||
166 | else | ||
167 | local file_out=$(get_filename_out "$1") | ||
168 | |||
169 | mkdir -p $(dirname "$file_out") | ||
170 | |||
171 | echo -e "\033[0;32m[COPY ]\033[0m $1 -> $file_out" | ||
172 | |||
173 | cp "$1" "$file_out" | ||
174 | fi | ||
175 | } | ||
176 | |||
177 | mdfilter="" | ||
178 | if [ "$LIVE" != true ]; then | ||
179 | mdfilter="! -name _*.md" | ||
180 | fi | ||
181 | |||
182 | if [ -z "$1" ]; then | ||
183 | find "$CONTENT_DIR" \ | ||
184 | -type f \ | ||
185 | ! -name ".*" \ | ||
186 | $mdfilter \ | ||
187 | | while read file_in | ||
188 | do | ||
189 | handle "$file_in" | ||
190 | done | ||
191 | elif [ "$1" = "all_md" ]; then | ||
192 | find "$CONTENT_DIR" \ | ||
193 | -type f \ | ||
194 | -name "*.md" \ | ||
195 | ! -name ".*" \ | ||
196 | $mdfilter \ | ||
197 | | while read file_in | ||
198 | do | ||
199 | handle "$file_in" | ||
200 | done | ||
201 | elif [ "$1" = "single" ]; then | ||
202 | if [ -z "$2" ]; then | ||
203 | echo -e "\033[0;31m[ERROR ]\033[0m \"single\" operation requires file argument" | ||
204 | else | ||
205 | filename=$(basename "$2") | ||
206 | if [ "${filename:0:1}" != "_" ]; then | ||
207 | handle "$2" | ||
208 | fi | ||
209 | fi | ||
210 | elif [ "$1" = "delete" ]; then | ||
211 | if [ -z "$2" ]; then | ||
212 | echo -e "\033[0;31m[ERROR ]\033[0m \"delete\" operation requires file argument" | ||
213 | else | ||
214 | file_out=$(get_filename_out "$2") | ||
215 | if [ -f "$file_out" ] || [ -d "$file_out" ]; then | ||
216 | echo -e "\033[0;32m[DELETE ]\033[0m $2 -> $file_out" | ||
217 | rm -rf $file_out | ||
218 | fi | ||
219 | fi | ||
220 | else | ||
221 | echo -e "\033[0;31m[ERROR ]\033[0m Unknown operation: \"$1\"" | ||
222 | fi | ||
diff --git a/scripts/build_fonts.sh b/scripts/build_fonts.sh deleted file mode 100755 index 7d368e7..0000000 --- a/scripts/build_fonts.sh +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | source "site.defaults.conf" | ||
4 | |||
5 | find "${ASSETS_DIR}fonts" \ | ||
6 | -type f \ | ||
7 | -name "*.ttf" \ | ||
8 | | while read file | ||
9 | do | ||
10 | target_file=$(basename "${file%.ttf}.woff2") | ||
11 | |||
12 | echo -e "\033[0;32m[MINIFY ]\033[0m $file -> $OUTPUT_DIR$target_file" | ||
13 | |||
14 | pyftsubset "$file" \ | ||
15 | --text-file="${ASSETS_DIR}fonts/glyphs.txt" \ | ||
16 | --layout-features+=ss02,ss09,dlig \ | ||
17 | --flavor="woff2" \ | ||
18 | --output-file="$OUTPUT_DIR$target_file" | ||
19 | done | ||
diff --git a/scripts/build_sass.sh b/scripts/build_sass.sh deleted file mode 100755 index 3f5f768..0000000 --- a/scripts/build_sass.sh +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | source "site.defaults.conf" | ||
4 | |||
5 | echo -e "\033[0;32m[COMPILE ]\033[0m ${ASSETS_DIR}css/style.scss -> ${OUTPUT_DIR}style.css" | ||
6 | sassc -t compressed ${ASSETS_DIR}css/style.scss | ./node_modules/.bin/postcss --use autoprefixer --no-map > "${OUTPUT_DIR}style.css" | ||
diff --git a/scripts/deploy.sh b/scripts/deploy.sh deleted file mode 100755 index a810b74..0000000 --- a/scripts/deploy.sh +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | source "site.defaults.conf" | ||
4 | |||
5 | echo -e "\033[0;32m[DEPLOY ]\033[0m $DEPLOY_TARGET" | ||
6 | rsync --progress --stats -rvz --delete "$OUTPUT_DIR" "$DEPLOY_TARGET" | ||
diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua index 90ca465..21f7759 100644 --- a/scripts/metadata_filter.lua +++ b/scripts/metadata_filter.lua | |||
@@ -5,27 +5,21 @@ function format_date(date) | |||
5 | local year, month, day = date:match("(%d%d%d%d)-(%d%d)-(%d%d)") | 5 | local year, month, day = date:match("(%d%d%d%d)-(%d%d)-(%d%d)") |
6 | if year == nil then return nil end | 6 | if year == nil then return nil end |
7 | 7 | ||
8 | local time = os.time({ | 8 | local time = os.time({year = tonumber(year), month = tonumber(month), day = tonumber(day)}) |
9 | year = tonumber(year), | ||
10 | month = tonumber(month), | ||
11 | day = tonumber(day) | ||
12 | }) | ||
13 | return pandoc.MetaMap({ | 9 | return pandoc.MetaMap({ |
14 | yyyy_mm_dd = pandoc.MetaString(os.date("%F", time)), | 10 | yyyy_mm_dd = os.date("%F", time), |
15 | yyyy = pandoc.MetaString(os.date("%Y", time)), | 11 | yyyy = os.date("%Y", time), |
16 | mm = pandoc.MetaString(os.date("%m", time)), | 12 | mm = os.date("%m", time), |
17 | dd = pandoc.MetaString(os.date("%d", time)), | 13 | dd = os.date("%d", time), |
18 | rfc3339 = pandoc.MetaString(os.date("%FT%T+00:00", time)), | 14 | rfc3339 = os.date("%FT%T+00:00", time), |
19 | long = pandoc.MetaString(os.date("%B %d, %Y", time)), | 15 | long = os.date("%B %d, %Y", time), |
20 | }) | 16 | }) |
21 | end | 17 | end |
22 | 18 | ||
23 | function table_to_list(t, cmp) | 19 | function table_to_list(t, cmp) |
24 | local l = pandoc.List() | 20 | local l = pandoc.List() |
25 | 21 | ||
26 | for key, value in pairs(t) do | 22 | for key, value in pairs(t) do l:insert(pandoc.MetaMap({key = key, value = value})) end |
27 | l:insert(pandoc.MetaMap({key = key, value = value})) | ||
28 | end | ||
29 | 23 | ||
30 | l:sort(cmp or function(i1, i2) return i1.key < i2.key end) | 24 | l:sort(cmp or function(i1, i2) return i1.key < i2.key end) |
31 | 25 | ||
@@ -83,9 +77,7 @@ function relative_to(dir, target) | |||
83 | end | 77 | end |
84 | 78 | ||
85 | if #dir < #target then | 79 | if #dir < #target then |
86 | for i = #dir + 1, #target do | 80 | for i = #dir + 1, #target do path = path .. (path == "" and "" or "/") .. target[i] end |
87 | path = path .. (path == "" and "" or "/") .. target[i] | ||
88 | end | ||
89 | elseif #dir > #target then | 81 | elseif #dir > #target then |
90 | for _ = #target + 1, #dir do path = "../" .. path end | 82 | for _ = #target + 1, #dir do path = "../" .. path end |
91 | end | 83 | end |
@@ -93,31 +85,8 @@ function relative_to(dir, target) | |||
93 | return path | 85 | return path |
94 | end | 86 | end |
95 | 87 | ||
96 | function apply_path_rewrites(rewrites, str) | ||
97 | for i = 1, #rewrites.path do | ||
98 | local r = rewrites.path[i] | ||
99 | str = str:gsub(pandoc.utils.stringify(r.from), | ||
100 | pandoc.utils.stringify(r.to)) | ||
101 | end | ||
102 | return str | ||
103 | end | ||
104 | |||
105 | function get_file_out(rewrites, content_dir, file_in) | ||
106 | local file_out = file_in:gsub("^" .. content_dir, ""):gsub("%.md$", ".html") | ||
107 | |||
108 | if file_out:match(".html$") and not file_out:match("/index%.html$") then | ||
109 | file_out = file_out:gsub("/(.*)%.html$", "/%1/index.html") | ||
110 | end | ||
111 | |||
112 | file_out = apply_path_rewrites(rewrites, file_out) | ||
113 | |||
114 | return pandoc.MetaString(file_out) | ||
115 | end | ||
116 | |||
117 | function make_absolute(rel, base) | 88 | function make_absolute(rel, base) |
118 | return | 89 | return rel:find("^/") ~= nil and rel or base:gsub("^(.*)/.-$", "%1") .. "/" .. rel |
119 | rel:find("^/") ~= nil and rel or base:gsub("^(.*)/.-$", "%1") .. "/" .. | ||
120 | rel | ||
121 | end | 90 | end |
122 | 91 | ||
123 | function resolve_url(site_url, ref_file, target_file) | 92 | function resolve_url(site_url, ref_file, target_file) |
@@ -127,119 +96,82 @@ function resolve_url(site_url, ref_file, target_file) | |||
127 | local abs = target_file | 96 | local abs = target_file |
128 | local rel = relative_to(ref_base_dir, abs):gsub("/index%.html$", "/") | 97 | local rel = relative_to(ref_base_dir, abs):gsub("/index%.html$", "/") |
129 | 98 | ||
130 | return pandoc.MetaMap({ | 99 | return pandoc.MetaMap({abs = abs, rel = rel, full = (site_url .. abs)}) |
131 | abs = pandoc.MetaString(abs), | ||
132 | rel = pandoc.MetaString(rel), | ||
133 | full = pandoc.MetaString(site_url .. abs) | ||
134 | }) | ||
135 | end | 100 | end |
136 | 101 | ||
137 | function resolve_layout(layout) | 102 | function resolve_layout(layout) |
138 | if layout then | 103 | if layout ~= nil then |
139 | layout = pandoc.utils.stringify(layout) | 104 | layout = pandoc.utils.stringify(layout) |
140 | return pandoc.MetaMap({ | 105 | return pandoc.MetaMap({id = layout, ["is_" .. layout] = pandoc.MetaBool(true)}) |
141 | id = pandoc.MetaString(layout), | ||
142 | ["is_" .. layout] = pandoc.MetaBool(true) | ||
143 | }) | ||
144 | end | 106 | end |
145 | end | 107 | end |
146 | 108 | ||
147 | function resolve_section(content_dir, file_in) | 109 | function resolve_namespace(namespace) |
148 | local section = file_in:gsub("^" .. content_dir, ""):match("^/(.-)[/.]") or | 110 | namespace = pandoc.utils.stringify(namespace) |
149 | "index" | 111 | |
112 | local root = "index" | ||
113 | if namespace ~= "" then root = namespace:gsub("^/([^/]*).*$", "%1") end | ||
114 | |||
150 | return pandoc.MetaMap({ | 115 | return pandoc.MetaMap({ |
151 | id = pandoc.MetaString(section), | 116 | root = pandoc.MetaMap({id = root, ["is_" .. root] = pandoc.MetaBool(true)}), |
152 | ["is_" .. section] = pandoc.MetaBool(true) | 117 | full = namespace, |
153 | }) | 118 | }) |
154 | end | 119 | end |
155 | 120 | ||
156 | function resolve_category(categories, category) | 121 | function resolve_category(categories, category) |
157 | if categories and category then | 122 | if categories ~= nil and category ~= nil then |
158 | category = pandoc.utils.stringify(category) | 123 | category = pandoc.utils.stringify(category) |
159 | data = pandoc.MetaMap(categories[category]) | 124 | data = pandoc.MetaMap(categories[category]) |
160 | data.id = pandoc.MetaString(category) | 125 | data.id = category |
161 | return data | 126 | return data |
162 | end | 127 | end |
163 | end | 128 | end |
164 | 129 | ||
165 | function prep_main_menu(rewrites, section, main_menu) | 130 | function prep_menu(active_id, main_menu) |
166 | local active_item = nil | 131 | local active_item = nil |
167 | 132 | ||
168 | for i = 1, #main_menu do | 133 | for i = 1, #main_menu do |
169 | local item = main_menu[i] | 134 | local item = main_menu[i] |
170 | local active = pandoc.utils.stringify(item.id) == section.id | 135 | local active = pandoc.utils.stringify(item.id) == active_id |
171 | item.active = pandoc.MetaBool(active) | 136 | item.active = pandoc.MetaBool(active) |
172 | item.url = apply_path_rewrites(rewrites, | ||
173 | pandoc.utils.stringify(item.url)) | ||
174 | if active then active_item = item end | 137 | if active then active_item = item end |
175 | end | 138 | end |
176 | 139 | ||
177 | return pandoc.MetaMap({ | 140 | return pandoc.MetaMap({ |
178 | items = main_menu:filter(function(item) | 141 | items = main_menu:filter(function(item) return not item.hidden or item.active end), |
179 | return not item.hidden or item.active | 142 | active = active_item, |
180 | end), | ||
181 | active = active_item | ||
182 | }) | 143 | }) |
183 | end | 144 | end |
184 | 145 | ||
185 | function organize_subpages(site_url, ref_file, pages) | 146 | function process_pages(global, pages_by_id) |
186 | for i = 1, #pages do | 147 | if pages_by_id == nil then pages_by_id = {} end |
187 | local page = pages[i] | ||
188 | page.url = resolve_url(site_url, ref_file, | ||
189 | pandoc.utils.stringify(page.file_out)) | ||
190 | end | ||
191 | |||
192 | local pages_grouped_date = | ||
193 | group_by(pages, function(p) return not p.date end) | ||
194 | |||
195 | local pages_undated = pages_grouped_date[true] or pandoc.MetaList({}) | ||
196 | pages_undated:sort(function(p1, p2) | ||
197 | return pandoc.utils.stringify(p1.title) < | ||
198 | pandoc.utils.stringify(p2.title) | ||
199 | end) | ||
200 | 148 | ||
201 | local pages_dated = pages_grouped_date[false] or pandoc.MetaList({}) | 149 | local pages_list = pandoc.List() |
202 | pages_dated:sort(function(p1, p2) | ||
203 | return pandoc.utils.stringify(p1.date.yyyy_mm_dd) > | ||
204 | pandoc.utils.stringify(p2.date.yyyy_mm_dd) | ||
205 | end) | ||
206 | 150 | ||
207 | local pages_categorized = pages:filter( | 151 | for _, page in pairs(pages_by_id) do |
208 | function(p) return p.category ~= nil end) | 152 | page = process(global, page) |
209 | pages_categorized:sort(function(p1, p2) | 153 | pages_list:insert(page) |
210 | return pandoc.utils.stringify(p1.title) < | 154 | end |
211 | pandoc.utils.stringify(p2.title) | ||
212 | end) | ||
213 | 155 | ||
214 | local pages_by_year = group_by(pages_dated, function(p) | 156 | local pages_categorized = pages_list:filter(function(p) return p.category ~= nil end) |
215 | return pandoc.utils.stringify(p.date.yyyy) | 157 | pages_categorized:sort(function(p1, p2) return p1.title < p2.title end) |
216 | end) | ||
217 | pages_by_year = pandoc.MetaList(table_to_list(pages_by_year, | ||
218 | function(i1, i2) | ||
219 | return i1.key > i2.key | ||
220 | end)) | ||
221 | 158 | ||
222 | local pages_by_category = group_by(pages_categorized, function(p) | 159 | local pages_by_category = group_by(pages_categorized, |
223 | return pandoc.utils.stringify(p.category.id) | 160 | function(p) return pandoc.utils.stringify(p.category.id) end) |
224 | end) | ||
225 | pages_by_category = pandoc.MetaList(table_to_list(pages_by_category, | 161 | pages_by_category = pandoc.MetaList(table_to_list(pages_by_category, |
226 | function(i1, i2) | 162 | function(i1, i2) return i1.key < i2.key end)) |
227 | return i1.key < i2.key | ||
228 | end)) | ||
229 | 163 | ||
230 | local pages_data = pandoc.MetaMap({ | 164 | local pages_data = pandoc.MetaMap({ |
231 | all_dated = pages_dated, | 165 | all = pages_list, |
232 | all_undated = pages_undated, | 166 | by_id = pages_by_id, |
233 | by_year = pages_by_year, | ||
234 | by_category = pages_by_category, | 167 | by_category = pages_by_category, |
235 | last_update = #pages_dated ~= 0 and pages_dated[1].last_update | ||
236 | }) | 168 | }) |
237 | 169 | ||
238 | local categories_data = group_by(pages_categorized, function(p) | 170 | local categories_data = group_by(pages_categorized, function(p) |
239 | return p.category and pandoc.utils.stringify(p.category.id) | 171 | return p.category and pandoc.utils.stringify(p.category.id) |
240 | end, function(stats, _, p) | 172 | end, function(stats, _, p) |
241 | if not stats then | 173 | if not stats then |
242 | return {name = pandoc.MetaString(p.category.name), count = 1} | 174 | return {name = p.category.name, count = 1} |
243 | else | 175 | else |
244 | stats.count = stats.count + 1 | 176 | stats.count = stats.count + 1 |
245 | end | 177 | end |
@@ -247,72 +179,52 @@ function organize_subpages(site_url, ref_file, pages) | |||
247 | categories_data = pandoc.MetaList(table_to_list(categories_data)) | 179 | categories_data = pandoc.MetaList(table_to_list(categories_data)) |
248 | 180 | ||
249 | for i = 1, #categories_data do | 181 | for i = 1, #categories_data do |
250 | categories_data[i].value.count = | 182 | categories_data[i].value.count = ("%d"):format(categories_data[i].value.count) |
251 | pandoc.MetaString(("%d"):format(categories_data[i].value.count)) | ||
252 | end | 183 | end |
253 | 184 | ||
254 | return pages_data, categories_data | 185 | return pages_data, categories_data |
255 | end | 186 | end |
256 | 187 | ||
257 | function Meta(meta) | 188 | function process(global, meta) |
258 | meta.content_dir = meta.content_dir:gsub("/$", "") | 189 | meta.namespace = resolve_namespace(meta.namespace) |
259 | meta.site.url = pandoc.utils.stringify(meta.site.url):gsub("/$", "") | 190 | meta.file_out = pandoc.utils.stringify(meta.file_out):gsub("^out", "") |
260 | meta.rewrites = meta.rewrites or | ||
261 | pandoc.MetaMap({path = pandoc.MetaList({})}) | ||
262 | meta.page_type = meta.page_type or "page" | ||
263 | meta.layout = resolve_layout(meta.layout) | 191 | meta.layout = resolve_layout(meta.layout) |
264 | meta.section = resolve_section(meta.content_dir, meta.file_in) | 192 | meta.url = resolve_url(global.site.url, global.file_out, meta.file_out) |
265 | 193 | ||
266 | meta.file_out = get_file_out(meta.rewrites, meta.content_dir, meta.file_in) | 194 | if meta.title ~= nil then |
267 | if meta.relative_to == nil then meta.relative_to = meta.file_in end | 195 | meta.title = pandoc.utils.stringify(meta.title) |
268 | meta.relative_to_out = get_file_out(meta.rewrites, meta.content_dir, | 196 | else |
269 | meta.relative_to) | 197 | meta.title = "" |
198 | end | ||
270 | 199 | ||
271 | meta.url = resolve_url(meta.site.url, meta.relative_to_out, meta.file_out) | ||
272 | if meta.preview ~= nil then | 200 | if meta.preview ~= nil then |
273 | meta.preview = resolve_url(meta.site.url, meta.relative_to_out, | 201 | meta.preview = make_absolute(pandoc.utils.stringify(meta.preview), meta.file_out) |
274 | make_absolute( | 202 | meta.preview = resolve_url(global.site.url, global.file_out, meta.preview) |
275 | pandoc.utils.stringify(meta.preview), | ||
276 | meta.file_out)) | ||
277 | end | 203 | end |
278 | 204 | ||
279 | meta.date = format_date(meta.date) | 205 | if meta.date ~= nil then meta.date = format_date(meta.date) end |
206 | |||
280 | if meta.last_update ~= nil then | 207 | if meta.last_update ~= nil then |
281 | meta.last_update = format_date(meta.last_update) | 208 | meta.last_update = format_date(meta.last_update) |
282 | else | 209 | else |
283 | meta.last_update = meta.date | 210 | meta.last_update = meta.date |
284 | end | 211 | end |
285 | 212 | ||
286 | meta.category = resolve_category(meta.categories[meta.section.id], | 213 | meta.category = resolve_category(global.categories[meta.namespace.root.id], meta.category) |
287 | meta.category) | ||
288 | meta.categories = nil | ||
289 | 214 | ||
290 | if meta.page_type == "feed" then | 215 | if meta.menus ~= nil and meta.menus.main ~= nil then |
291 | meta.page = pandoc.MetaMap({ | 216 | meta.menus.main = prep_menu(meta.namespace.root.id, meta.menus.main) |
292 | url = resolve_url(meta.site.url, meta.relative_to_out, | ||
293 | meta.file_out:gsub("%.xml$", ".html")) | ||
294 | }) | ||
295 | end | 217 | end |
296 | 218 | ||
297 | if meta.create_feed then | 219 | local pages, local_categories = process_pages(global, meta.pages) |
298 | meta.feed = pandoc.MetaMap({ | 220 | meta.pages = pages |
299 | url = resolve_url(meta.site.url, meta.relative_to_out, | 221 | meta.local_categories = local_categories |
300 | meta.file_out:gsub("%.html$", ".xml")) | ||
301 | }) | ||
302 | end | ||
303 | 222 | ||
304 | if meta.menus and meta.menus.main then | 223 | return meta |
305 | meta.menus.main = prep_main_menu(meta.rewrites, meta.section, | 224 | end |
306 | meta.menus.main) | ||
307 | end | ||
308 | 225 | ||
309 | if meta.pages then | 226 | function Meta(meta) |
310 | local pages, categories = organize_subpages(meta.site.url, | 227 | meta.site.url = pandoc.utils.stringify(meta.site.url):gsub("/$", "") |
311 | meta.relative_to_out, | ||
312 | meta.pages) | ||
313 | meta.pages = pages | ||
314 | meta.categories = categories | ||
315 | end | ||
316 | 228 | ||
317 | return meta | 229 | return process(meta, meta) |
318 | end | 230 | end |
diff --git a/scripts/subpages.jq b/scripts/subpages.jq new file mode 100644 index 0000000..4850703 --- /dev/null +++ b/scripts/subpages.jq | |||
@@ -0,0 +1,8 @@ | |||
1 | [ | ||
2 | .[] | ||
3 | | . as $page | ||
4 | | (.namespace | ltrimstr($namespace + "/") | split("/") | (.[] |= ["pages",.]) | flatten) as $path | ||
5 | | null | ||
6 | | setpath($path; $page) | ||
7 | ] | ||
8 | | reduce .[] as $item ({}; . * $item) | ||
diff --git a/scripts/watch_content.sh b/scripts/watch_content.sh deleted file mode 100755 index 30f8a6c..0000000 --- a/scripts/watch_content.sh +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | source "site.defaults.conf" | ||
4 | |||
5 | inotifywait -qrme close_write,delete,move --format "%w%f" "${CONTENT_DIR%/}" \ | ||
6 | | while read file | ||
7 | do | ||
8 | if [ -f "$file" ]; then | ||
9 | # scripts/build_content.sh "single" "$file" | ||
10 | scripts/build_content.sh | ||
11 | elif [ ! -d "$file" ]; then | ||
12 | scripts/build_content.sh "delete" "$file" | ||
13 | fi | ||
14 | done | ||
diff --git a/scripts/watch_filters.sh b/scripts/watch_filters.sh deleted file mode 100755 index 5dd6ad5..0000000 --- a/scripts/watch_filters.sh +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | source "site.defaults.conf" | ||
4 | |||
5 | inotifywait -qrme close_write,delete,move --format "%w%f" "${FILTERS_DIR%/}" \ | ||
6 | | while read file | ||
7 | do | ||
8 | scripts/build_content.sh "all_md" | ||
9 | done | ||
diff --git a/scripts/watch_metadata.sh b/scripts/watch_metadata.sh deleted file mode 100755 index 2f6efde..0000000 --- a/scripts/watch_metadata.sh +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | source "site.defaults.conf" | ||
4 | |||
5 | inotifywait -qrme close_write,delete,move --format "%w%f" "${METADATA_DIR%/}" \ | ||
6 | | while read file | ||
7 | do | ||
8 | scripts/build_content.sh "all_md" | ||
9 | done | ||
diff --git a/scripts/watch_sass.sh b/scripts/watch_sass.sh deleted file mode 100755 index 7345eb3..0000000 --- a/scripts/watch_sass.sh +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | source "site.defaults.conf" | ||
4 | |||
5 | inotifywait -qrme close_write,delete,move --format "%w%f" "${ASSETS_DIR}css" \ | ||
6 | | while read file | ||
7 | do | ||
8 | scripts/build_sass.sh | ||
9 | done | ||
diff --git a/scripts/watch_templates.sh b/scripts/watch_templates.sh deleted file mode 100755 index 70ae4c3..0000000 --- a/scripts/watch_templates.sh +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | source "site.defaults.conf" | ||
4 | |||
5 | inotifywait -qrme close_write,delete,move --format "%w%f" "${TEMPLATES_DIR%/}" \ | ||
6 | | while read file | ||
7 | do | ||
8 | scripts/build_content.sh "all_md" | ||
9 | done | ||
diff --git a/site.defaults.conf b/site.defaults.conf deleted file mode 100644 index de4ac4c..0000000 --- a/site.defaults.conf +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | DEPLOY_TARGET="vulpes@94.130.78.123:/srv/http/volpeon.ink/" | ||
2 | |||
3 | CONTENT_DIR="content/" | ||
4 | ASSETS_DIR="assets/" | ||
5 | FILTERS_DIR="filters/" | ||
6 | METADATA_DIR="metadata/" | ||
7 | TEMPLATES_DIR="templates/" | ||
8 | OUTPUT_DIR="output/" | ||
9 | |||
10 | if [ -f "site.conf" ]; then | ||
11 | source "site.conf" | ||
12 | fi | ||
diff --git a/templates/base.html b/templates/base.html index cd1e869..a5d29b5 100644 --- a/templates/base.html +++ b/templates/base.html | |||
@@ -19,14 +19,7 @@ | |||
19 | <meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" /> | 19 | <meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" /> |
20 | $endif$ | 20 | $endif$ |
21 | 21 | ||
22 | $for(feeds)$ | 22 | <title>$if(namespace.root.is_index)$$else$$title$ – $endif$$site.title$</title> |
23 | <link href="$it.url$" type="application/atom+xml" rel="alternate" title="$it.title$ – $site.title$" /> | ||
24 | $endfor$ | ||
25 | $if(feed)$ | ||
26 | <link href="$feed.url.rel$" type="application/atom+xml" rel="alternate" title="$if(section.is_index)$$else$$title$ – $endif$$site.title$" /> | ||
27 | $endif$ | ||
28 | |||
29 | <title>$if(section.is_index)$$else$$title$ – $endif$$site.title$</title> | ||
30 | 23 | ||
31 | <link rel="preload" href="/style.css" as="style" /> | 24 | <link rel="preload" href="/style.css" as="style" /> |
32 | <link rel="preload" href="/symbols.svg" as="image" type="image/svg+xml" /> | 25 | <link rel="preload" href="/symbols.svg" as="image" type="image/svg+xml" /> |
@@ -46,7 +39,7 @@ | |||
46 | </svg> | 39 | </svg> |
47 | </span> | 40 | </span> |
48 | </a> | 41 | </a> |
49 | $if(section.is_index)$ | 42 | $if(namespace.root.is_index)$ |
50 | $else$ | 43 | $else$ |
51 | $for(menus.main.items)$ | 44 | $for(menus.main.items)$ |
52 | $if(it.active)$ | 45 | $if(it.active)$ |
@@ -61,7 +54,7 @@ | |||
61 | </nav> | 54 | </nav> |
62 | 55 | ||
63 | <main> | 56 | <main> |
64 | $if(section.is_index)$ | 57 | $if(namespace.root.is_index)$ |
65 | ${layouts/index()} | 58 | ${layouts/index()} |
66 | $elseif(layout.is_categorized_list)$ | 59 | $elseif(layout.is_categorized_list)$ |
67 | ${layouts/categorized_list()} | 60 | ${layouts/categorized_list()} |
diff --git a/templates/layouts/index.html b/templates/layouts/index.html index 6d4c776..45ac82e 100644 --- a/templates/layouts/index.html +++ b/templates/layouts/index.html | |||
@@ -59,13 +59,13 @@ $body$ | |||
59 | </svg> | 59 | </svg> |
60 | </span> | 60 | </span> |
61 | <span class="c-outer-button__content"> | 61 | <span class="c-outer-button__content"> |
62 | $subsections.projects.title$ | 62 | $pages.by_id.projects.title$ |
63 | </span> | 63 | </span> |
64 | </a> | 64 | </a> |
65 | </header> | 65 | </header> |
66 | 66 | ||
67 | <div class="l-container l-container--pad-x l-container--pad-y l-project-grid"> | 67 | <div class="l-container l-container--pad-x l-container--pad-y l-project-grid"> |
68 | $for(subsections.projects.pages)$ | 68 | $for(pages.by_id.projects.pages.all)$ |
69 | <a class="c-project" href="$it.url.rel$"> | 69 | <a class="c-project" href="$it.url.rel$"> |
70 | $if(it.preview)$ | 70 | $if(it.preview)$ |
71 | <img class="c-project__picture" src="$it.preview.rel$" /> | 71 | <img class="c-project__picture" src="$it.preview.rel$" /> |
diff --git a/templates/layouts/page.html b/templates/layouts/page.html index 2093f8c..f89a692 100644 --- a/templates/layouts/page.html +++ b/templates/layouts/page.html | |||
@@ -1,12 +1,12 @@ | |||
1 | <section class="l-section l-section--fullscreen l-section--no-head"> | 1 | <section class="l-section l-section--fullscreen l-section--no-head"> |
2 | <div class="l-container l-container--pad-x l-container--pad-y l-container--content s-colored-links s-headlines s-body"> | 2 | <div class="l-container l-container--pad-x l-container--pad-y l-container--content s-colored-links s-headlines s-body"> |
3 | <h1 class="u-mt0"><span class="s-headlines__title-inner">$title$</span></h1> | 3 | $if(category.show_date)$ |
4 | 4 | <div class="s-body__meta"> | |
5 | <div class="s-body__meta"> | ||
6 | $if(category.show_date)$ | ||
7 | $date.long$ | 5 | $date.long$ |
8 | $endif$ | 6 | </div> |
9 | </div> | 7 | $endif$ |
8 | |||
9 | <h1 class="u-mt0"><span class="s-headlines__title-inner">$title$</span></h1> | ||
10 | 10 | ||
11 | $body$ | 11 | $body$ |
12 | </div> | 12 | </div> |