summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2022-06-18 15:51:18 +0200
committerVolpeon <git@volpeon.ink>2022-06-18 15:51:18 +0200
commita43ca52aa2d102c7499c7fd8478304a26ea2cd0a (patch)
treed44afb4720ffdb088a3c8f05f27befb446b195ae
parentImproved exhibit (diff)
downloadvolpeon.ink-a43ca52aa2d102c7499c7fd8478304a26ea2cd0a.tar.gz
volpeon.ink-a43ca52aa2d102c7499c7fd8478304a26ea2cd0a.tar.bz2
volpeon.ink-a43ca52aa2d102c7499c7fd8478304a26ea2cd0a.zip
Improved Lua filters, improved exhibit pages
-rw-r--r--content/art/doodles/2021-lazy-firefox/index.md12
-rw-r--r--content/art/drawings/2021-cute-ava/index.md7
-rw-r--r--content/art/drawings/2021-eeveelutions/index.md20
-rw-r--r--content/art/drawings/2021-lycanroc-ava/index.md7
-rw-r--r--content/art/drawings/2021-refsheet/index.md20
-rw-r--r--content/art/drawings/2021-spooky-ava-1/index.md7
-rw-r--r--content/art/drawings/2021-spooky-ava-2/index.md7
-rw-r--r--content/art/drawings/2022-autumn-fox/index.md7
-rw-r--r--content/lightbox.js36
-rw-r--r--filters/code.lua15
-rw-r--r--filters/headers.lua9
-rw-r--r--filters/icons.lua12
-rw-r--r--filters/lib/common.lua30
-rw-r--r--filters/macros.lua72
-rw-r--r--filters/tables.lua5
-rw-r--r--scripts/metadata_filter.lua8
-rw-r--r--templates/feed_entry.xml13
-rw-r--r--templates/layouts/exhibit.html9
-rw-r--r--templates/layouts/page.html2
-rw-r--r--yarn.lock2
20 files changed, 155 insertions, 145 deletions
diff --git a/content/art/doodles/2021-lazy-firefox/index.md b/content/art/doodles/2021-lazy-firefox/index.md
index d7d47e1..f57f184 100644
--- a/content/art/doodles/2021-lazy-firefox/index.md
+++ b/content/art/doodles/2021-lazy-firefox/index.md
@@ -4,8 +4,12 @@ title: Lazy Firefox
4date: 2021-10-16 4date: 2021-10-16
5thumbnail: png 5thumbnail: png
6layout: exhibit 6layout: exhibit
7
8images:
9 - url: firefox_lazy.png
10 - url: firefox_lazy_transparent.png
11--- 7---
8
9::: figure
10![](firefox_lazy.png)
11:::
12
13::: figure
14![](firefox_lazy_transparent.png)
15:::
diff --git a/content/art/drawings/2021-cute-ava/index.md b/content/art/drawings/2021-cute-ava/index.md
index dd350bb..962c0ce 100644
--- a/content/art/drawings/2021-cute-ava/index.md
+++ b/content/art/drawings/2021-cute-ava/index.md
@@ -4,7 +4,8 @@ title: Cute Avatar
4date: 2021-03-01 4date: 2021-03-01
5thumbnail: png 5thumbnail: png
6layout: exhibit 6layout: exhibit
7
8images:
9 - url: ava.png
10--- 7---
8
9::: figure
10![](ava.png)
11:::
diff --git a/content/art/drawings/2021-eeveelutions/index.md b/content/art/drawings/2021-eeveelutions/index.md
index 87c0869..9cd4352 100644
--- a/content/art/drawings/2021-eeveelutions/index.md
+++ b/content/art/drawings/2021-eeveelutions/index.md
@@ -4,12 +4,16 @@ title: Eeveelutions
4date: 2021-08-19 4date: 2021-08-19
5thumbnail: png 5thumbnail: png
6layout: exhibit 6layout: exhibit
7
8images:
9 - url: eevee.png
10 description: Eevee
11 - url: flareon.png
12 description: Flareon
13 - url: flareon_wink.png
14 description: Flareon, winking
15--- 7---
8
9::: figure
10![Eevee](eevee.png)
11:::
12
13::: figure
14![Flareon](flareon.png)
15:::
16
17::: figure
18![Flareon, winking](flareon_wink.png)
19:::
diff --git a/content/art/drawings/2021-lycanroc-ava/index.md b/content/art/drawings/2021-lycanroc-ava/index.md
index 3e0fe64..8b7fb1d 100644
--- a/content/art/drawings/2021-lycanroc-ava/index.md
+++ b/content/art/drawings/2021-lycanroc-ava/index.md
@@ -4,9 +4,10 @@ title: Lycanroc Avatar
4date: 2021-10-19 4date: 2021-10-19
5thumbnail: png 5thumbnail: png
6layout: exhibit 6layout: exhibit
7
8images:
9 - url: ava.png
10--- 7---
11 8
12Avatar for [@feralbot@botsin.space](https://botsin.space/@feralbot), a bot that posts pictures of feral characters from [e926](https://e926.net/). 9Avatar for [@feralbot@botsin.space](https://botsin.space/@feralbot), a bot that posts pictures of feral characters from [e926](https://e926.net/).
10
11::: figure
12![](ava.png)
13:::
diff --git a/content/art/drawings/2021-refsheet/index.md b/content/art/drawings/2021-refsheet/index.md
index 8617a95..e9b4333 100644
--- a/content/art/drawings/2021-refsheet/index.md
+++ b/content/art/drawings/2021-refsheet/index.md
@@ -4,12 +4,16 @@ title: Reference Sheet Views
4date: 2021-10-06 4date: 2021-10-06
5thumbnail: png 5thumbnail: png
6layout: exhibit 6layout: exhibit
7
8images:
9 - url: bottom.png
10 description: Bottom view
11 - url: bottom_cofe.png
12 description: Bottom view, holding a cup of coffee
13 - url: side.png
14 description: Side view
15--- 7---
8
9::: figure
10![Bottom view](bottom.png)
11:::
12
13::: figure
14![Bottom view, holding a cup of coffee](bottom_cofe.png)
15:::
16
17::: figure
18![Side view](side.png)
19:::
diff --git a/content/art/drawings/2021-spooky-ava-1/index.md b/content/art/drawings/2021-spooky-ava-1/index.md
index 500bd11..70f000d 100644
--- a/content/art/drawings/2021-spooky-ava-1/index.md
+++ b/content/art/drawings/2021-spooky-ava-1/index.md
@@ -4,7 +4,8 @@ title: \"Spooky\" Avatar
4date: 2021-10-07 4date: 2021-10-07
5thumbnail: png 5thumbnail: png
6layout: exhibit 6layout: exhibit
7
8images:
9 - url: ava.png
10--- 7---
8
9::: figure
10![](ava.png)
11:::
diff --git a/content/art/drawings/2021-spooky-ava-2/index.md b/content/art/drawings/2021-spooky-ava-2/index.md
index 7fca6f0..672c4c0 100644
--- a/content/art/drawings/2021-spooky-ava-2/index.md
+++ b/content/art/drawings/2021-spooky-ava-2/index.md
@@ -4,7 +4,8 @@ title: Spooky Avatar
4date: 2021-10-14 4date: 2021-10-14
5thumbnail: png 5thumbnail: png
6layout: exhibit 6layout: exhibit
7
8images:
9 - url: ava.png
10--- 7---
8
9::: figure
10![](ava.png)
11:::
diff --git a/content/art/drawings/2022-autumn-fox/index.md b/content/art/drawings/2022-autumn-fox/index.md
index 6816680..ebd51ab 100644
--- a/content/art/drawings/2022-autumn-fox/index.md
+++ b/content/art/drawings/2022-autumn-fox/index.md
@@ -4,10 +4,11 @@ title: Autumn Fox
4date: 2022-02-25 4date: 2022-02-25
5thumbnail: png 5thumbnail: png
6layout: exhibit 6layout: exhibit
7
8images:
9 - url: pic.png
10--- 7---
11 8
12First attempt at cel shading. 9First attempt at cel shading.
13It's actually incomplete, but I felt like I had hit a roadblock with the shading and wanted to try again with another drawing. 10It's actually incomplete, but I felt like I had hit a roadblock with the shading and wanted to try again with another drawing.
11
12::: figure
13![](pic.png)
14:::
diff --git a/content/lightbox.js b/content/lightbox.js
index e4a2c29..e672d63 100644
--- a/content/lightbox.js
+++ b/content/lightbox.js
@@ -9,7 +9,7 @@
9 const lightboxFooterEl = lightboxEl.querySelector(".o-lightbox__footer"); 9 const lightboxFooterEl = lightboxEl.querySelector(".o-lightbox__footer");
10 const figureEls = Array.from(mainEl.querySelectorAll(".js-lightbox__image")); 10 const figureEls = Array.from(mainEl.querySelectorAll(".js-lightbox__image"));
11 11
12 const closeable = lightboxContainerEl.classList.contains("js-lightbox--closeable"); 12 const standalone = lightboxContainerEl.classList.contains("js-lightbox--standalone");
13 let currentIndex = 0; 13 let currentIndex = 0;
14 let visible = !lightboxContainerEl.classList.contains("u-d-none"); 14 let visible = !lightboxContainerEl.classList.contains("u-d-none");
15 let mouseDown = false; 15 let mouseDown = false;
@@ -20,7 +20,7 @@
20 } 20 }
21 21
22 const hide = () => { 22 const hide = () => {
23 if (closeable) { 23 if (!standalone) {
24 visible = false; 24 visible = false;
25 lightboxContainerEl.classList.add("u-d-none"); 25 lightboxContainerEl.classList.add("u-d-none");
26 } 26 }
@@ -56,41 +56,27 @@
56 setIndex(i); 56 setIndex(i);
57 }; 57 };
58 58
59 let anchorEl; 59 const imgEl = figureEl.querySelector("img");
60 let imgEl; 60 const captionEl = figureEl.querySelector("figcaption");
61
62 if (figureEl.firstElementChild.tagName === "A") {
63 anchorEl = figureEl.firstElementChild;
64 imgEl = anchorEl.firstElementChild;
65 } else {
66 imgEl = figureEl.firstElementChild;
67 anchorEl = document.createElement("a");
68 anchorEl.href = imgEl.src;
69 61
70 figureEl.insertBefore(anchorEl, imgEl); 62 const src = imgEl.src;
71 figureEl.removeChild(imgEl); 63 const description = captionEl?.innerHTML ?? "";
72 anchorEl.appendChild(imgEl);
73 }
74 64
75 anchorEl.addEventListener("click", go);
76 const thumbnailButtonEl = document.createElement("button"); 65 const thumbnailButtonEl = document.createElement("button");
77 const thumbnailImgEl = document.createElement("img"); 66 const thumbnailImgEl = document.createElement("img");
78 67
79 thumbnailImgEl.classList.add("o-lightbox__thumbnail-img"); 68 thumbnailImgEl.classList.add("o-lightbox__thumbnail-img");
80 thumbnailImgEl.src = anchorEl.href; 69 thumbnailImgEl.src = src;
81 70
82 thumbnailButtonEl.classList.add("o-lightbox__thumbnail"); 71 thumbnailButtonEl.classList.add("o-lightbox__thumbnail");
83 thumbnailButtonEl.appendChild(thumbnailImgEl); 72 thumbnailButtonEl.appendChild(thumbnailImgEl);
84 thumbnailButtonEl.addEventListener("click", go); 73 thumbnailButtonEl.addEventListener("click", go);
85 74
86 if (i === currentIndex) {
87 thumbnailButtonEl.classList.add("is-selected");
88 }
89
90 lightboxFooterEl.appendChild(thumbnailButtonEl); 75 lightboxFooterEl.appendChild(thumbnailButtonEl);
91 76
92 const captionEl = figureEl.querySelector("figcaption"); 77 if (!standalone) {
93 const description = captionEl?.innerHTML ?? ""; 78 figureEl.firstElementChild.addEventListener("click", go);
79 }
94 80
95 return { 81 return {
96 thumbnailEl: thumbnailButtonEl, 82 thumbnailEl: thumbnailButtonEl,
@@ -106,7 +92,7 @@
106 lightboxFooterEl.remove(); 92 lightboxFooterEl.remove();
107 } 93 }
108 94
109 if (closeable) { 95 if (!standalone) {
110 document.addEventListener('mousedown', (e) => { 96 document.addEventListener('mousedown', (e) => {
111 if (visible) { 97 if (visible) {
112 mouseDown = !lightboxEl.contains(e.target) || lightboxEl === e.target; 98 mouseDown = !lightboxEl.contains(e.target) || lightboxEl === e.target;
diff --git a/filters/code.lua b/filters/code.lua
new file mode 100644
index 0000000..2d6e5a5
--- /dev/null
+++ b/filters/code.lua
@@ -0,0 +1,15 @@
1local common = require 'filters.lib.common'
2
3function CodeBlock(el)
4 if el.classes[1] == "plain" then
5 el = pandoc.Div({ el }, { class = 's-code' })
6 elseif el.classes[1] then
7 local formatted = pandoc.pipe('pygmentize', {
8 '-l', el.classes[1], '-f', 'html', '-O', 'cssclass=s-code s-code--highlight',
9 }, el.text)
10
11 if formatted then el = pandoc.RawBlock('html', formatted) end
12 end
13
14 return common.wide(el)
15end
diff --git a/filters/headers.lua b/filters/headers.lua
new file mode 100644
index 0000000..ea9cde6
--- /dev/null
+++ b/filters/headers.lua
@@ -0,0 +1,9 @@
1function Header(el)
2 if el.level <= 3 then
3 local newchildren = pandoc.List()
4 newchildren:insert(pandoc.Span(el.content, { class = 's-headings__primary' }))
5 el.content = newchildren
6 end
7
8 return el
9end
diff --git a/filters/icons.lua b/filters/icons.lua
new file mode 100644
index 0000000..9e921f3
--- /dev/null
+++ b/filters/icons.lua
@@ -0,0 +1,12 @@
1function Str(el)
2 local icon = el.text:match('^:(.*):$')
3
4 if icon then
5 return pandoc.RawInline('html',
6 '<svg class="o-icon o-icon--inline" width="1em" height="1em" aria-hidden="true">\
7 <use href="/icons.svg#' .. icon .. '"></use>\
8 </svg>')
9 end
10
11 return el
12end
diff --git a/filters/lib/common.lua b/filters/lib/common.lua
new file mode 100644
index 0000000..7654eb9
--- /dev/null
+++ b/filters/lib/common.lua
@@ -0,0 +1,30 @@
1function wide(el)
2 local els = pandoc.List()
3
4 els:insert(pandoc.RawBlock("html", "</div>"))
5 if pcall(function() return #el end) then
6 els:extend(el)
7 else
8 els:insert(el)
9 end
10 els:insert(pandoc.RawBlock("html", "<div class=\"l-container l-container--narrow u-ml-0\">"))
11
12 return els
13end
14
15function dump(o)
16 if type(o) == 'table' then
17 local s = '{ '
18 for k, v in pairs(o) do
19 if type(k) ~= 'number' then k = '"' .. k .. '"' end
20 s = s .. '[' .. k .. '] = ' .. dump(v) .. ','
21 end
22 return s .. '} '
23 else
24 return tostring(o)
25 end
26end
27
28return {
29 wide = wide
30}
diff --git a/filters/macros.lua b/filters/macros.lua
index cb7975b..04cead6 100644
--- a/filters/macros.lua
+++ b/filters/macros.lua
@@ -1,12 +1,6 @@
1function wide(el) 1local common = require 'filters.lib.common'
2 local els = pandoc.List()
3 2
4 els:insert(pandoc.RawBlock("html", "</div>")) 3local vars = {}
5 els:insert(el)
6 els:insert(pandoc.RawBlock("html", "<div class=\"l-container l-container--narrow u-ml-0\">"))
7
8 return els
9end
10 4
11function alert(el) 5function alert(el)
12 el.classes = pandoc.List() 6 el.classes = pandoc.List()
@@ -14,22 +8,26 @@ function alert(el)
14 el.classes:insert("o-alert--primary") 8 el.classes:insert("o-alert--primary")
15 el.classes:insert("s-alerts__alert") 9 el.classes:insert("s-alerts__alert")
16 10
17 return wide(el) 11 return common.wide(el)
18end 12end
19 13
20function figure(el) 14function figure(el)
21 local images = pandoc.List() 15 local images = pandoc.List()
22
23 pandoc.walk_block(el, { Image = function(iel) images:insert(iel) end }) 16 pandoc.walk_block(el, { Image = function(iel) images:insert(iel) end })
17 images[1].classes:insert("c-figure__image")
18
19 local class = "c-figure js-lightbox__image"
20 if vars.layout and vars.layout.is_exhibit then
21 class = class .. " u-d-none@js"
22 end
23
24 el = pandoc.List()
24 25
25 el = pandoc.RawBlock("html", 26 el:insert(pandoc.RawBlock("html", "<figure class=\"" .. class .. "\">"))
26 "<figure class=\"c-figure js-lightbox__image\">\ 27 el:insert(pandoc.Link(images[1], images[1].src, nil, { class = "c-figure__link" }))
27 <a class=\"c-figure__link\" href=\"" .. images[1].src .. "\">\ 28 el:insert(pandoc.RawBlock("html", "</figure>"))
28 <img class=\"c-figure__image\" src=\"" .. images[1].src .. "\" title=\"" .. images[1].title .. "\" />\
29 </a>\
30 </figure>")
31 29
32 return wide(el) 30 return common.wide(el)
33end 31end
34 32
35function Div(el) 33function Div(el)
@@ -42,42 +40,6 @@ function Div(el)
42 return el 40 return el
43end 41end
44 42
45function CodeBlock(el) 43function meta(meta) vars = meta end
46 if el.classes[1] == "plain" then
47 el = pandoc.Div({ el }, { class = 's-code' })
48 elseif el.classes[1] then
49 local formatted = pandoc.pipe('pygmentize', {
50 '-l', el.classes[1], '-f', 'html', '-O', 'cssclass=s-code s-code--highlight',
51 }, el.text)
52
53 if formatted then el = pandoc.RawBlock('html', formatted) end
54 end
55
56 return wide(el)
57end
58
59function Header(el)
60 if el.level <= 3 then
61 local newchildren = pandoc.List()
62 newchildren:insert(pandoc.Span(el.content, { class = 's-headings__primary' }))
63 el.content = newchildren
64 end
65
66 return el
67end
68
69function Table(el)
70 return wide(el)
71end
72 44
73function Str(el) 45return { { Meta = meta }, { Div = Div } }
74 local icon = el.text:match('^:(.*):$')
75
76 if icon then
77 return pandoc.RawInline('html',
78 '<svg class="o-icon o-icon--inline" width="1em" height="1em" aria-hidden="true"><use href="/icons.svg#' ..
79 icon .. '"></use></svg>')
80 end
81
82 return el
83end
diff --git a/filters/tables.lua b/filters/tables.lua
new file mode 100644
index 0000000..2ff4eea
--- /dev/null
+++ b/filters/tables.lua
@@ -0,0 +1,5 @@
1local common = require 'filters.lib.common'
2
3function Table(el)
4 return common.wide(el)
5end
diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua
index 4f7200a..8f32bd4 100644
--- a/scripts/metadata_filter.lua
+++ b/scripts/metadata_filter.lua
@@ -290,14 +290,6 @@ function process(global, meta)
290 if meta.list_limit then meta.list_limit = tonumber(pandoc.utils.stringify(meta.list_limit)) end 290 if meta.list_limit then meta.list_limit = tonumber(pandoc.utils.stringify(meta.list_limit)) end
291 if meta.position then meta.position = pandoc.utils.stringify(meta.position) end 291 if meta.position then meta.position = pandoc.utils.stringify(meta.position) end
292 292
293 if meta.images then
294 for i = 1, #meta.images do
295 local image = meta.images[i]
296 image.url = make_absolute(pandoc.utils.stringify(image.url), meta.file_out)
297 image.url = resolve_url(global.site.url, global.file_out, image.url)
298 end
299 end
300
301 if meta.feed then 293 if meta.feed then
302 if meta.file_out:match(".html$") then 294 if meta.file_out:match(".html$") then
303 meta.feed = { 295 meta.feed = {
diff --git a/templates/feed_entry.xml b/templates/feed_entry.xml
index f0a7f1e..03d6569 100644
--- a/templates/feed_entry.xml
+++ b/templates/feed_entry.xml
@@ -22,15 +22,4 @@ $else$
22 </author> 22 </author>
23 $endfor$ 23 $endfor$
24$endif$ 24$endif$
25<content type="html"><![CDATA[ 25<content type="html"><![CDATA[$it.content$]]></content>
26 $it.content$
27
28 $if(it.layout.is_exhibit)$
29 $for(it.images)$
30 <figure>
31 <img src="$it.url.full$" alt="$it.description$" />
32 <figcaption>$it.description$</figcaption>
33 </figure>
34 $endfor$
35 $endif$
36]]></content>
diff --git a/templates/layouts/exhibit.html b/templates/layouts/exhibit.html
index a7eeec1..cee28f9 100644
--- a/templates/layouts/exhibit.html
+++ b/templates/layouts/exhibit.html
@@ -5,7 +5,7 @@
5 itemtype="https://schema.org/$schema_type$" 5 itemtype="https://schema.org/$schema_type$"
6 itemid="$url.full$" 6 itemid="$url.full$"
7> 7>
8 <section class="c-exhibit js-lightbox"> 8 <section class="c-exhibit js-lightbox js-lightbox--standalone">
9 <div class="c-exhibit__content o-lightbox"> 9 <div class="c-exhibit__content o-lightbox">
10 <img class="o-lightbox__img" /> 10 <img class="o-lightbox__img" />
11 11
@@ -52,13 +52,6 @@
52 <div class="l-container l-container--pad-x l-container--pad-y l-container--narrow-125 u-pt-400"> 52 <div class="l-container l-container--pad-x l-container--pad-y l-container--narrow-125 u-pt-400">
53 <div class="s-body s-colored-links s-headings s-blockquotes s-code s-lists s-tables s-alerts e-content" itemprop="articleBody"> 53 <div class="s-body s-colored-links s-headings s-blockquotes s-code s-lists s-tables s-alerts e-content" itemprop="articleBody">
54$body$ 54$body$
55
56 $for(images)$
57 <figure class="c-figure js-lightbox__image u-d-none@js">
58 <img src="$it.url.rel$" alt="$it.description$" />
59 <figcaption>$it.description$</figcaption>
60 </figure>
61 $endfor$
62 </div> 55 </div>
63 </div> 56 </div>
64</main> 57</main>
diff --git a/templates/layouts/page.html b/templates/layouts/page.html
index 4058748..689d17b 100644
--- a/templates/layouts/page.html
+++ b/templates/layouts/page.html
@@ -36,7 +36,7 @@ $body$
36 $endif$ 36 $endif$
37 </article> 37 </article>
38 38
39 <div class="o-backdrop js-lightbox js-lightbox--closeable u-d-none t-dark"> 39 <div class="o-backdrop js-lightbox u-d-none t-dark">
40 <div class="o-lightbox"> 40 <div class="o-lightbox">
41 <button class="o-lightbox__close-btn o-action-button o-action-button--quiet o-action-button--round"> 41 <button class="o-lightbox__close-btn o-action-button o-action-button--quiet o-action-button--round">
42 <svg class="l-media__block o-icon" width="1em" height="1em" aria-hidden="true"> 42 <svg class="l-media__block o-icon" width="1em" height="1em" aria-hidden="true">
diff --git a/yarn.lock b/yarn.lock
index e7c2fd1..202211f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1280,7 +1280,7 @@ internal-slot@^1.0.3:
1280 1280
1281"iro-design@git+https://git.vulpes.one/git/iro-design.git": 1281"iro-design@git+https://git.vulpes.one/git/iro-design.git":
1282 version "1.0.0" 1282 version "1.0.0"
1283 resolved "git+https://git.vulpes.one/git/iro-design.git#3f9783606896b9d51055c38a052d3612c9181421" 1283 resolved "git+https://git.vulpes.one/git/iro-design.git#b3970ea623c1cd3daaf8f06204130c20cb2d1104"
1284 dependencies: 1284 dependencies:
1285 "@oddbird/blend" "^0.2.3" 1285 "@oddbird/blend" "^0.2.3"
1286 include-media "^1.4.9" 1286 include-media "^1.4.9"