summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2021-11-14 09:28:25 +0100
committerVolpeon <git@volpeon.ink>2021-11-14 09:28:25 +0100
commitac027192285ad741b3ac1b837e1c363beb8f3791 (patch)
tree7f00bf8cb177ce844a9deb8f2a8dbe0bed721edd
parentUpdate (diff)
downloadvolpeon.ink-ac027192285ad741b3ac1b837e1c363beb8f3791.tar.gz
volpeon.ink-ac027192285ad741b3ac1b837e1c363beb8f3791.tar.bz2
volpeon.ink-ac027192285ad741b3ac1b837e1c363beb8f3791.zip
Generate special list metadata
-rw-r--r--content/profiles/bandcamp/index.md6
-rw-r--r--content/profiles/email/index.md6
-rw-r--r--content/profiles/fediverse/index.md6
-rw-r--r--content/profiles/git/index.md5
-rw-r--r--content/profiles/git/main.md (renamed from content/profiles/github/main.md)0
-rw-r--r--content/profiles/github/index.md5
-rw-r--r--content/profiles/index.md2
-rw-r--r--content/projects/emojis/index.md5
-rw-r--r--content/projects/index.md2
-rw-r--r--scripts/metadata_filter.lua96
-rw-r--r--templates/base.html4
-rw-r--r--templates/layouts/categorized_list.html86
-rw-r--r--templates/layouts/deep_categorized_list.html54
-rw-r--r--templates/layouts/list.html64
-rw-r--r--templates/partials/grid_card.html33
-rw-r--r--templates/partials/list_card.html34
16 files changed, 189 insertions, 219 deletions
diff --git a/content/profiles/bandcamp/index.md b/content/profiles/bandcamp/index.md
index 34f3c88..0a47469 100644
--- a/content/profiles/bandcamp/index.md
+++ b/content/profiles/bandcamp/index.md
@@ -1,5 +1,5 @@
1--- 1---
2title: Bandcamp 2title: Bandcamp
3icon: parallelogram 3icon: parallelogram
4list_icon: icon-arrow-up-right 4list_post_icon: icon-arrow-up-right
5--- 5---
diff --git a/content/profiles/email/index.md b/content/profiles/email/index.md
index e305535..6eef738 100644
--- a/content/profiles/email/index.md
+++ b/content/profiles/email/index.md
@@ -1,5 +1,5 @@
1--- 1---
2title: E-Mail 2title: E-Mail
3icon: envelope 3icon: envelope
4list_icon: icon-arrow-up-right 4list_post_icon: icon-arrow-up-right
5--- 5---
diff --git a/content/profiles/fediverse/index.md b/content/profiles/fediverse/index.md
index ed35dc1..56eb848 100644
--- a/content/profiles/fediverse/index.md
+++ b/content/profiles/fediverse/index.md
@@ -1,5 +1,5 @@
1--- 1---
2title: Fediverse 2title: Fediverse
3icon: graph 3icon: graph
4list_icon: icon-arrow-up-right 4list_post_icon: icon-arrow-up-right
5--- 5---
diff --git a/content/profiles/git/index.md b/content/profiles/git/index.md
new file mode 100644
index 0000000..0d747a6
--- /dev/null
+++ b/content/profiles/git/index.md
@@ -0,0 +1,5 @@
1---
2title: Git
3icon: git-branch
4list_post_icon: icon-arrow-up-right
5---
diff --git a/content/profiles/github/main.md b/content/profiles/git/main.md
index fb25680..fb25680 100644
--- a/content/profiles/github/main.md
+++ b/content/profiles/git/main.md
diff --git a/content/profiles/github/index.md b/content/profiles/github/index.md
deleted file mode 100644
index d4f011d..0000000
--- a/content/profiles/github/index.md
+++ /dev/null
@@ -1,5 +0,0 @@
1---
2title: Git
3icon: git-branch
4list_icon: icon-arrow-up-right
5---
diff --git a/content/profiles/index.md b/content/profiles/index.md
index 1041807..6514367 100644
--- a/content/profiles/index.md
+++ b/content/profiles/index.md
@@ -1,5 +1,5 @@
1--- 1---
2title: Profiles 2title: Profiles
3position: 1
3list_grid: true 4list_grid: true
4list_icon: icon-arrow-up-right
5--- 5---
diff --git a/content/projects/emojis/index.md b/content/projects/emojis/index.md
index cbffe1b..58ad85b 100644
--- a/content/projects/emojis/index.md
+++ b/content/projects/emojis/index.md
@@ -1,4 +1,5 @@
1--- 1---
2title: Emojis 2title: Emojis
3icon: smile 3icon: smile
4list_post_icon: icon-arrow-right
4--- 5---
diff --git a/content/projects/index.md b/content/projects/index.md
index c79f803..546ae46 100644
--- a/content/projects/index.md
+++ b/content/projects/index.md
@@ -1,5 +1,5 @@
1--- 1---
2title: Projects 2title: Projects
3position: 2
3list_grid: true 4list_grid: true
4list_icon: icon-arrow-right
5--- 5---
diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua
index ebd69f1..b16d472 100644
--- a/scripts/metadata_filter.lua
+++ b/scripts/metadata_filter.lua
@@ -1,5 +1,14 @@
1local path = require 'pandoc.path' 1local path = require 'pandoc.path'
2 2
3function pandoc.List:flatMap(fn)
4 local mapped = self:map(fn)
5 local result = pandoc.List()
6
7 for i = 1, #mapped do result:extend(mapped[i]) end
8
9 return result
10end
11
3function format_date(date) 12function format_date(date)
4 if not date then return date end 13 if not date then return date end
5 14
@@ -49,14 +58,12 @@ function resolve_url(site_url, ref_file, target_file)
49end 58end
50 59
51function resolve_layout(depth) 60function resolve_layout(depth)
52 local layout = "deep_categorized_list" 61 local layout = "categorized_list"
53 62
54 if depth == "0" then 63 if depth == "0" then
55 layout = "page" 64 layout = "page"
56 elseif depth == "1" then 65 elseif depth == "1" then
57 layout = "list" 66 layout = "list"
58 elseif depth == "2" then
59 layout = "categorized_list"
60 end 67 end
61 68
62 return layout 69 return layout
@@ -91,14 +98,14 @@ function prep_menu(active_id, main_menu)
91 return { items = items, active = active_item } 98 return { items = items, active = active_item }
92end 99end
93 100
94function process_pages(global, order, pages_by_id) 101function process_pages(global, parent, order, pages_by_id)
95 if not pages_by_id then return nil end 102 if not pages_by_id then return nil end
96 103
97 local pages_all = pandoc.List() 104 local pages_all = pandoc.List()
98 local pages_date_desc = pandoc.List() 105 local pages_date_desc = pandoc.List()
99 106
100 for _, page in pairs(pages_by_id) do 107 for _, page in pairs(pages_by_id) do
101 local p = process(global, page) 108 local p = process(global, parent, page)
102 if not p.unlisted then 109 if not p.unlisted then
103 pages_all:insert(p) 110 pages_all:insert(p)
104 if p.date then pages_date_desc:insert(p) end 111 if p.date then pages_date_desc:insert(p) end
@@ -176,7 +183,77 @@ function find_depth(pages)
176 return tostring(depth) 183 return tostring(depth)
177end 184end
178 185
179function process(global, meta) 186function generate_list(meta)
187 if meta.depth == "1" then
188 return meta.pages.all:map(function(p)
189 return {
190 title = p.title,
191 subtitle = p.subtitle,
192 date = p.date,
193 url = p.url,
194 icon = p.icon or meta.icon,
195 post_icon = meta.list_post_icon,
196 indicator = meta.list_read_indicators,
197 }
198 end)
199 elseif meta.depth == "2" then
200 return meta.pages.all:map(function(cat)
201 return {
202 title = cat.title,
203 content = pandoc.utils.stringify(cat.content),
204 url = cat.url,
205 grid = cat.list_grid,
206 items = cat.pages.all:map(function(p)
207 return {
208 title = p.title,
209 subtitle = p.subtitle,
210 date = p.date,
211 url = p.url,
212 icon = p.icon or cat.icon,
213 post_icon = cat.list_post_icon or meta.list_post_icon,
214 indicator = cat.list_read_indicators,
215 }
216 end),
217 }
218 end)
219 elseif meta.depth == "3" then
220 return meta.pages.all:map(function(cat)
221 return {
222 title = cat.title,
223 content = pandoc.utils.stringify(cat.content),
224 url = cat.url,
225 grid = cat.list_grid,
226 items = cat.pages.all:flatMap(function(c)
227 if c.pages then
228 return c.pages.all:map(function(p)
229 return {
230 title = p.title,
231 subtitle = p.subtitle or c.title,
232 url = p.url,
233 icon = p.icon or c.icon,
234 post_icon = c.list_post_icon or cat.list_post_icon,
235 indicator = c.list_read_indicators,
236 }
237 end)
238 else
239 local l = pandoc.List()
240 l:insert({
241 title = c.title,
242 subtitle = c.subtitle,
243 url = c.url,
244 icon = c.icon or meta.icon,
245 post_icon = meta.list_post_icon,
246 indicator = meta.list_read_indicators,
247 })
248 return l
249 end
250 end),
251 }
252 end)
253 end
254end
255
256function process(global, parent, meta)
180 meta.namespace = resolve_namespace(meta.namespace) 257 meta.namespace = resolve_namespace(meta.namespace)
181 meta.file_out = pandoc.utils.stringify(meta.file_out):gsub("^out", "") 258 meta.file_out = pandoc.utils.stringify(meta.file_out):gsub("^out", "")
182 meta.url = meta.url and pandoc.utils.stringify(meta.url) 259 meta.url = meta.url and pandoc.utils.stringify(meta.url)
@@ -209,7 +286,8 @@ function process(global, meta)
209 meta.menus.main = prep_menu(meta.namespace.root.id, meta.menus.main) 286 meta.menus.main = prep_menu(meta.namespace.root.id, meta.menus.main)
210 end 287 end
211 288
212 meta.pages = process_pages(global, meta.list_order, meta.pages) 289 meta.pages =
290 process_pages(global, { parent = parent, meta = meta }, meta.list_order, meta.pages)
213 meta.depth = (meta.pages and find_depth(meta.pages.all)) or "0" 291 meta.depth = (meta.pages and find_depth(meta.pages.all)) or "0"
214 meta.layout = prep_layout(meta.layout or resolve_layout(meta.depth)) 292 meta.layout = prep_layout(meta.layout or resolve_layout(meta.depth))
215 293
@@ -227,11 +305,13 @@ function process(global, meta)
227 meta.last_update = meta.date 305 meta.last_update = meta.date
228 end 306 end
229 307
308 meta.list = generate_list(meta)
309
230 return meta 310 return meta
231end 311end
232 312
233function Meta(meta) 313function Meta(meta)
234 meta.site.url = pandoc.utils.stringify(meta.site.url):gsub("/$", "") 314 meta.site.url = pandoc.utils.stringify(meta.site.url):gsub("/$", "")
235 315
236 return process(meta, meta) 316 return process(meta, nil, meta)
237end 317end
diff --git a/templates/base.html b/templates/base.html
index ede7941..eb088c4 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -63,9 +63,7 @@
63 </nav> 63 </nav>
64 64
65 <main> 65 <main>
66 $if(layout.is_deep_categorized_list)$ 66 $if(layout.is_categorized_list)$
67${layouts/deep_categorized_list()}
68 $elseif(layout.is_categorized_list)$
69${layouts/categorized_list()} 67${layouts/categorized_list()}
70 $elseif(layout.is_list)$ 68 $elseif(layout.is_list)$
71${layouts/list()} 69${layouts/list()}
diff --git a/templates/layouts/categorized_list.html b/templates/layouts/categorized_list.html
index ad510ae..aea8863 100644
--- a/templates/layouts/categorized_list.html
+++ b/templates/layouts/categorized_list.html
@@ -6,80 +6,18 @@ $body$
6 </div> 6 </div>
7 7
8 <div class="c-card-list"> 8 <div class="c-card-list">
9 $for(pages.all)$ 9 $for(list)$
10 $if(it.pages)$ 10 <h2 class="c-card-list__category-header">
11 <h2 class="c-card-list__category-header"> 11 <a href="$it.url.rel$">$it.title$</a>
12 <a href="$it.url.rel$">$it.title$</a> 12 </h2>
13 </h2> 13 $if(it.grid)$
14 $if(it.list_grid)$ 14 <div class="c-card-list__category-content c-card-list__category-content--grid">
15 <div class="c-card-list__category-content c-card-list__category-content--grid"> 15 $it.items:partials/grid_card()$
16 $for(it.pages.all)$ 16 </div>
17 <a href="$it.url.rel$" class="c-card-list__card c-card"> 17 $else$
18 $if(pages.all.list_read_indicators)$ 18 <div class="c-card-list__category-content">
19 <div class="c-card__block c-card__block--indicator"></div> 19 $it.items:partials/list_card()$
20 $endif$ 20 </div>
21 $if(pages.all.icon)$
22 <svg class="c-card__block o-icon" width="1em" height="1em">
23 <use href="/symbols.svg#icon-$pages.all.icon$"></use>
24 </svg>
25 $endif$
26 <div class="c-card__block c-card__block--main">
27 $if(it.date)$
28 <time datetime="$it.date.yyyy_mm_dd$">
29 <small class="u-dn@sm-hi">
30 $it.date.short$
31 </small>
32 <small class="u-dn@sm-lo">
33 $it.date.long$
34 </small>
35 </time>
36 <strong class="u-db">$it.title$</strong>
37 $else$
38 $it.title$
39 $endif$
40 </div>
41 $if(list_icon)$
42 <svg class="c-card__block o-icon" width="1em" height="1em">
43 <use href="/symbols.svg#$list_icon$"></use>
44 </svg>
45 $endif$
46 </a>
47 $endfor$
48 </div>
49 $else$
50 <div class="c-card-list__category-content">
51 $for(it.pages.all)$
52 <a href="$it.url.rel$" class="c-card-list__card c-card">
53 $if(pages.all.list_read_indicators)$
54 <div class="c-card__block c-card__block--indicator"></div>
55 $endif$
56 $if(pages.all.icon)$
57 <svg class="c-card__block o-icon" width="1em" height="1em">
58 <use href="/symbols.svg#icon-$pages.all.icon$"></use>
59 </svg>
60 $endif$
61 <div class="c-card__block c-card__block--main">
62 $it.title$
63 </div>
64 $if(it.date)$
65 <time datetime="$it.date.yyyy_mm_dd$" class="c-card__block u-fs0">
66 <small class="u-dn@sm-hi">
67 $it.date.short$
68 </small>
69 <small class="u-dn@sm-lo">
70 $it.date.long$
71 </small>
72 </time>
73 $endif$
74 $if(list_icon)$
75 <svg class="c-card__block o-icon" width="1em" height="1em">
76 <use href="/symbols.svg#$list_icon$"></use>
77 </svg>
78 $endif$
79 </a>
80 $endfor$
81 </div>
82 $endif$
83 $endif$ 21 $endif$
84 $endfor$ 22 $endfor$
85 </div> 23 </div>
diff --git a/templates/layouts/deep_categorized_list.html b/templates/layouts/deep_categorized_list.html
deleted file mode 100644
index eec16c9..0000000
--- a/templates/layouts/deep_categorized_list.html
+++ /dev/null
@@ -1,54 +0,0 @@
1<section class="l-container l-container--pad-x l-container--pad-y l-container--content">
2 <div class="s-headlines s-colored-links">
3 <h1 class="u-mt0"><span class="s-headlines__title-inner">$title$</span></h1>
4
5$body$
6 </div>
7
8 <div class="c-card-list">
9 $for(pages.all)$
10 $if(it.pages)$
11 <h2 class="c-card-list__category-header">
12 <a href="$it.url.rel$">$it.title$</a>
13 </h2>
14 <div class="c-card-list__category-content$if(it.list_grid)$ c-card-list__category-content--grid$endif$">
15 $for(pages.all.pages.all)$
16 $for(pages.all.pages.all.pages.all)$
17 <a href="$it.url.rel$" class="c-card-list__card c-card">
18 $if(pages.all.list_read_indicators)$
19 <div class="c-card__block c-card__block--indicator"></div>
20 $endif$
21 $if(pages.all.pages.all.icon)$
22 <svg class="c-card__block o-icon" width="1em" height="1em">
23 <use href="/symbols.svg#icon-$pages.all.pages.all.icon$"></use>
24 </svg>
25 $endif$
26 <div class="c-card__block c-card__block--main">
27 <small class="u-db">$pages.all.pages.all.title$</small>
28 <strong class="u-db">$it.title$</strong>
29 </div>
30 $if(it.date)$
31 <time datetime="$it.date.yyyy_mm_dd$" class="c-card__block u-fs0">
32 <small class="u-dn@sm-hi">
33 $it.date.short$
34 </small>
35 <small class="u-dn@sm-lo">
36 $it.date.long$
37 </small>
38 </time>
39 $endif$
40 $if(pages.all.list_icon)$
41 <svg class="c-card__block o-icon" width="1em" height="1em">
42 <use href="/symbols.svg#$pages.all.list_icon$"></use>
43 </svg>
44 $endif$
45 </a>
46 $endfor$
47 $endfor$
48 </div>
49 $endif$
50 $endfor$
51 </div>
52</section>
53
54
diff --git a/templates/layouts/list.html b/templates/layouts/list.html
index b4647a1..7a9d573 100644
--- a/templates/layouts/list.html
+++ b/templates/layouts/list.html
@@ -8,71 +8,11 @@ $body$
8 <div class="c-card-list"> 8 <div class="c-card-list">
9 $if(list_grid)$ 9 $if(list_grid)$
10 <div class="c-card-list__category-content c-card-list__category-content--grid"> 10 <div class="c-card-list__category-content c-card-list__category-content--grid">
11 $for(pages.all)$ 11 $list:partials/grid_card()$
12 <a href="$it.url.rel$" class="c-card-list__card c-card">
13 $if(list_read_indicators)$
14 <div class="c-card__block c-card__block--indicator"></div>
15 $endif$
16 $if(icon)$
17 <svg class="c-card__block o-icon">
18 <use href="/symbols.svg#icon-$icon$"></use>
19 </svg>
20 $endif$
21 <div class="c-card__block c-card__block--main">
22 $if(it.date)$
23 <time datetime="$it.date.yyyy_mm_dd$">
24 <small class="u-dn@sm-hi">
25 $it.date.short$
26 </small>
27 <small class="u-dn@sm-lo">
28 $it.date.long$
29 </small>
30 </time>
31 <strong class="u-db">$it.title$</strong>
32 $else$
33 $it.title$
34 $endif$
35 </div>
36 $if(list_icon)$
37 <svg class="c-card__block o-icon" width="1em" height="1em">
38 <use href="/symbols.svg#$list_icon$"></use>
39 </svg>
40 $endif$
41 </a>
42 $endfor$
43 </div> 12 </div>
44 $else$ 13 $else$
45 <div class="c-card-list__category-content"> 14 <div class="c-card-list__category-content">
46 $for(pages.all)$ 15 $list:partials/list_card()$
47 <a href="$it.url.rel$" class="c-card-list__card c-card">
48 $if(list_read_indicators)$
49 <div class="c-card__block c-card__block--indicator"></div>
50 $endif$
51 $if(icon)$
52 <svg class="c-card__block o-icon">
53 <use href="/symbols.svg#icon-$icon$"></use>
54 </svg>
55 $endif$
56 <div class="c-card__block c-card__block--main">
57 $it.title$
58 </div>
59 $if(it.date)$
60 <time datetime="$it.date.yyyy_mm_dd$" class="c-card__block u-fs0">
61 <small class="u-dn@sm-hi">
62 $it.date.short$
63 </small>
64 <small class="u-dn@sm-lo">
65 $it.date.long$
66 </small>
67 </time>
68 $endif$
69 $if(list_icon)$
70 <svg class="c-card__block o-icon" width="1em" height="1em">
71 <use href="/symbols.svg#$list_icon$"></use>
72 </svg>
73 $endif$
74 </a>
75 $endfor$
76 </div> 16 </div>
77 $endif$ 17 $endif$
78 </div> 18 </div>
diff --git a/templates/partials/grid_card.html b/templates/partials/grid_card.html
new file mode 100644
index 0000000..25c2271
--- /dev/null
+++ b/templates/partials/grid_card.html
@@ -0,0 +1,33 @@
1<a href="$it.url.rel$" class="c-card-list__card c-card">
2 $if(it.indicator)$
3 <div class="c-card__block c-card__block--indicator"></div>
4 $endif$
5 $if(it.icon)$
6 <svg class="c-card__block o-icon" width="1em" height="1em">
7 <use href="/symbols.svg#icon-$it.icon$"></use>
8 </svg>
9 $endif$
10 <div class="c-card__block c-card__block--main">
11 $if(it.subtitle)$
12 <small class="u-db">$it.subtitle$</small>
13 <strong class="u-db">$it.title$</strong>
14 $elseif(it.date)$
15 <time datetime="$it.date.yyyy_mm_dd$">
16 <small class="u-dn@sm-hi">
17 $it.date.short$
18 </small>
19 <small class="u-dn@sm-lo">
20 $it.date.long$
21 </small>
22 </time>
23 <strong class="u-db">$it.title$</strong>
24 $else$
25 $it.title$
26 $endif$
27 </div>
28 $if(it.post_icon)$
29 <svg class="c-card__block o-icon" width="1em" height="1em">
30 <use href="/symbols.svg#$it.post_icon$"></use>
31 </svg>
32 $endif$
33</a>
diff --git a/templates/partials/list_card.html b/templates/partials/list_card.html
new file mode 100644
index 0000000..644e0d3
--- /dev/null
+++ b/templates/partials/list_card.html
@@ -0,0 +1,34 @@
1<a href="$it.url.rel$" class="c-card-list__card c-card">
2 $if(it.indicator)$
3 <div class="c-card__block c-card__block--indicator"></div>
4 $endif$
5 $if(it.icon)$
6 <svg class="c-card__block o-icon" width="1em" height="1em">
7 <use href="/symbols.svg#icon-$it.icon$"></use>
8 </svg>
9 $endif$
10 <div class="c-card__block c-card__block--main">
11 $it.title$
12 </div>
13 $if(it.subtitle)$
14 <div class="c-card__block u-fs0">
15 <small>
16 $it.subtitle$
17 </small>
18 </div>
19 $elseif(it.date)$
20 <time datetime="$it.date.yyyy_mm_dd$" class="c-card__block u-fs0">
21 <small class="u-dn@sm-hi">
22 $it.date.short$
23 </small>
24 <small class="u-dn@sm-lo">
25 $it.date.long$
26 </small>
27 </time>
28 $endif$
29 $if(it.post_icon)$
30 <svg class="c-card__block o-icon" width="1em" height="1em">
31 <use href="/symbols.svg#$it.post_icon$"></use>
32 </svg>
33 $endif$
34</a>