From c20ea9f6922557db29061a5d53c067ab20c734b9 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 13 Nov 2021 18:03:55 +0100 Subject: Improved list generation, remove index template --- content/9thPK7O3xn/dreams/index.md | 1 - content/9thPK7O3xn/index.md | 2 +- content/9thPK7O3xn/misc/index.md | 1 - content/9thPK7O3xn/pages/index.md | 1 - content/index.md | 2 +- content/profiles/bandcamp/index.md | 5 ++ content/profiles/bandcamp/main.md | 5 ++ content/profiles/email/index.md | 5 ++ content/profiles/email/main.md | 5 ++ content/profiles/fediverse/index.md | 5 ++ content/profiles/fediverse/main.md | 5 ++ content/profiles/github/index.md | 5 ++ content/profiles/github/main.md | 5 ++ content/profiles/index.md | 5 ++ content/projects/emojis/index.md | 1 - content/projects/index.md | 2 +- metadata/metadata.yaml | 40 ++---------- scripts/metadata_filter.lua | 76 +++++++++++---------- templates/base.html | 4 +- templates/layouts/categorized_list.html | 98 ++++++++++++++++++++-------- templates/layouts/deep_categorized_list.html | 54 +++++++++++++++ templates/layouts/index.html | 67 ------------------- templates/layouts/list.html | 96 +++++++++++++++++++-------- 23 files changed, 288 insertions(+), 202 deletions(-) create mode 100644 content/profiles/bandcamp/index.md create mode 100644 content/profiles/bandcamp/main.md create mode 100644 content/profiles/email/index.md create mode 100644 content/profiles/email/main.md create mode 100644 content/profiles/fediverse/index.md create mode 100644 content/profiles/fediverse/main.md create mode 100644 content/profiles/github/index.md create mode 100644 content/profiles/github/main.md create mode 100644 content/profiles/index.md create mode 100644 templates/layouts/deep_categorized_list.html delete mode 100644 templates/layouts/index.html diff --git a/content/9thPK7O3xn/dreams/index.md b/content/9thPK7O3xn/dreams/index.md index bce4433..c89aad4 100644 --- a/content/9thPK7O3xn/dreams/index.md +++ b/content/9thPK7O3xn/dreams/index.md @@ -1,7 +1,6 @@ --- title: Dream Journal position: 9 -layout: list list_order: date_desc list_read_indicators: true create_feed: true diff --git a/content/9thPK7O3xn/index.md b/content/9thPK7O3xn/index.md index 0b14fcf..52ceada 100644 --- a/content/9thPK7O3xn/index.md +++ b/content/9thPK7O3xn/index.md @@ -1,6 +1,6 @@ --- title: Personal -layout: categorized_list +unlisted: true create_feed: true --- diff --git a/content/9thPK7O3xn/misc/index.md b/content/9thPK7O3xn/misc/index.md index 572cc05..d39ae3f 100644 --- a/content/9thPK7O3xn/misc/index.md +++ b/content/9thPK7O3xn/misc/index.md @@ -1,7 +1,6 @@ --- title: Other stuff position: 10 -layout: list list_read_indicators: true create_feed: true --- diff --git a/content/9thPK7O3xn/pages/index.md b/content/9thPK7O3xn/pages/index.md index 0dccffb..33818ff 100644 --- a/content/9thPK7O3xn/pages/index.md +++ b/content/9thPK7O3xn/pages/index.md @@ -1,7 +1,6 @@ --- title: Pages position: 0 -layout: list list_read_indicators: true create_feed: true --- diff --git a/content/index.md b/content/index.md index ca1da95..efc03c2 100644 --- a/content/index.md +++ b/content/index.md @@ -1,5 +1,5 @@ --- -title: Home +title: Volpeon's Den --- Hi, I'm Volpeon. I enjoy programming, creating vector art and designing user interfaces. diff --git a/content/profiles/bandcamp/index.md b/content/profiles/bandcamp/index.md new file mode 100644 index 0000000..34f3c88 --- /dev/null +++ b/content/profiles/bandcamp/index.md @@ -0,0 +1,5 @@ +--- +title: Bandcamp +icon: parallelogram +list_icon: icon-arrow-up-right +--- diff --git a/content/profiles/bandcamp/main.md b/content/profiles/bandcamp/main.md new file mode 100644 index 0000000..f94213f --- /dev/null +++ b/content/profiles/bandcamp/main.md @@ -0,0 +1,5 @@ +--- +title: volpeon +titlecase: false +url: https://bandcamp.com/volpeon +--- diff --git a/content/profiles/email/index.md b/content/profiles/email/index.md new file mode 100644 index 0000000..e305535 --- /dev/null +++ b/content/profiles/email/index.md @@ -0,0 +1,5 @@ +--- +title: E-Mail +icon: envelope +list_icon: icon-arrow-up-right +--- diff --git a/content/profiles/email/main.md b/content/profiles/email/main.md new file mode 100644 index 0000000..16f103a --- /dev/null +++ b/content/profiles/email/main.md @@ -0,0 +1,5 @@ +--- +title: me@volpeon.ink +titlecase: false +url: "mailto:me@volpeon.ink" +--- diff --git a/content/profiles/fediverse/index.md b/content/profiles/fediverse/index.md new file mode 100644 index 0000000..ed35dc1 --- /dev/null +++ b/content/profiles/fediverse/index.md @@ -0,0 +1,5 @@ +--- +title: Fediverse +icon: graph +list_icon: icon-arrow-up-right +--- diff --git a/content/profiles/fediverse/main.md b/content/profiles/fediverse/main.md new file mode 100644 index 0000000..70ee902 --- /dev/null +++ b/content/profiles/fediverse/main.md @@ -0,0 +1,5 @@ +--- +title: "@volpeon@mk.vulpes.one" +titlecase: false +url: "https://mk.vulpes.one/@volpeon" +--- diff --git a/content/profiles/github/index.md b/content/profiles/github/index.md new file mode 100644 index 0000000..d4f011d --- /dev/null +++ b/content/profiles/github/index.md @@ -0,0 +1,5 @@ +--- +title: Git +icon: git-branch +list_icon: icon-arrow-up-right +--- diff --git a/content/profiles/github/main.md b/content/profiles/github/main.md new file mode 100644 index 0000000..fb25680 --- /dev/null +++ b/content/profiles/github/main.md @@ -0,0 +1,5 @@ +--- +title: "git.vulpes.one" +titlecase: false +url: "https://git.vulpes.one/" +--- diff --git a/content/profiles/index.md b/content/profiles/index.md new file mode 100644 index 0000000..1041807 --- /dev/null +++ b/content/profiles/index.md @@ -0,0 +1,5 @@ +--- +title: Profiles +list_grid: true +list_icon: icon-arrow-up-right +--- diff --git a/content/projects/emojis/index.md b/content/projects/emojis/index.md index f650b2e..01054aa 100644 --- a/content/projects/emojis/index.md +++ b/content/projects/emojis/index.md @@ -1,6 +1,5 @@ --- title: Emojis icon: smile -layout: list list_grid: true --- diff --git a/content/projects/index.md b/content/projects/index.md index 8aa8f96..c79f803 100644 --- a/content/projects/index.md +++ b/content/projects/index.md @@ -1,5 +1,5 @@ --- title: Projects -layout: categorized_list list_grid: true +list_icon: icon-arrow-right --- diff --git a/metadata/metadata.yaml b/metadata/metadata.yaml index c8f2d72..679cdcb 100644 --- a/metadata/metadata.yaml +++ b/metadata/metadata.yaml @@ -11,43 +11,11 @@ menus: label: Projects url: /projects/ + - id: profiles + label: Profiles + url: /profiles/ + - id: 9thPK7O3xn label: Personal url: /9thPK7O3xn/ hidden: true - -profiles: - - platform: Bandcamp - icon: parallelogram - username: volpeon - url: https://bandcamp.com/volpeon - featured: true - - - platform: E-Mail - icon: envelope - username: me@volpeon.ink - featured: true - url: "mailto:me@volpeon.ink" - - - platform: Fediverse - icon: graph - username: "@volpeon@mk.vulpes.one" - url: "https://mk.vulpes.one/@volpeon" - featured: true - - - platform: GitHub - icon: git-branch - username: volpeon - url: "https://github.com/volpeon" - - - platform: IRC - icon: hash - username: volpeon - - - platform: Steam - username: volpeon - url: https://steamcommunity.com/id/volpeon/ - - - platform: XMPP - icon: messages - username: "<available>" diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua index 7039a2c..ebd69f1 100644 --- a/scripts/metadata_filter.lua +++ b/scripts/metadata_filter.lua @@ -33,30 +33,6 @@ function table_to_list(t, kv, cmp) return l end -function group_by(l, field, insert) - insert = insert or function(group, _, item) - if not group then - group = l:new({ item }) - return group - end - group:insert(item) - end - - local groups = {} - - for i = 1, #l do - local item = l[i] - local f = field(item) - - if f then - local out = insert(groups[f], f, item) - if out then groups[f] = out end - end - end - - return groups -end - function make_absolute(rel, base) return path.is_absolute(rel) and rel or path.join({ path.directory(base), rel }) end @@ -67,15 +43,28 @@ function resolve_url(site_url, ref_file, target_file) local ref_base_dir = path.directory(ref_file) local abs = target_file local rel = path.make_relative(abs, ref_base_dir, true) + local full = (abs[1] == "/" and (site_url .. abs)) or abs - return { abs = abs, rel = rel, full = (site_url .. abs) } + return { abs = abs, rel = rel, full = full } end -function resolve_layout(layout) - if layout then - layout = pandoc.utils.stringify(layout) - return { id = layout, ["is_" .. layout] = true } +function resolve_layout(depth) + local layout = "deep_categorized_list" + + if depth == "0" then + layout = "page" + elseif depth == "1" then + layout = "list" + elseif depth == "2" then + layout = "categorized_list" end + + return layout +end + +function prep_layout(layout) + layout = pandoc.utils.stringify(layout) + return { id = layout, ["is_" .. layout] = true } end function resolve_namespace(namespace) @@ -110,8 +99,10 @@ function process_pages(global, order, pages_by_id) for _, page in pairs(pages_by_id) do local p = process(global, page) - pages_all:insert(p) - if p.date then pages_date_desc:insert(p) end + if not p.unlisted then + pages_all:insert(p) + if p.date then pages_date_desc:insert(p) end + end end pages_all:sort(function(p1, p2) @@ -171,12 +162,27 @@ function titlecase(str) end) end +function find_depth(pages) + local depth = 0 + + for i = 1, #pages do + local p = pages[i] + local d = tonumber(p.depth) + if d > depth then depth = d end + end + + depth = depth + 1 + + return tostring(depth) +end + function process(global, meta) meta.namespace = resolve_namespace(meta.namespace) meta.file_out = pandoc.utils.stringify(meta.file_out):gsub("^out", "") - meta.layout = resolve_layout(meta.layout) - meta.url = resolve_url(global.site.url, global.file_out, meta.file_out) - meta.title = (meta.title and titlecase(pandoc.utils.stringify(meta.title))) or "" + meta.url = meta.url and pandoc.utils.stringify(meta.url) + meta.url = resolve_url(global.site.url, global.file_out, meta.url or meta.file_out) + meta.title = (meta.title and pandoc.utils.stringify(meta.title)) or "" + if meta.titlecase ~= false then meta.title = titlecase(meta.title) end if meta.list_order then meta.list_order = pandoc.utils.stringify(meta.list_order) end if meta.position then meta.position = pandoc.utils.stringify(meta.position) end @@ -204,6 +210,8 @@ function process(global, meta) end meta.pages = process_pages(global, meta.list_order, meta.pages) + meta.depth = (meta.pages and find_depth(meta.pages.all)) or "0" + meta.layout = prep_layout(meta.layout or resolve_layout(meta.depth)) if meta.date then meta.date = format_date(meta.date) diff --git a/templates/base.html b/templates/base.html index e736864..ede7941 100644 --- a/templates/base.html +++ b/templates/base.html @@ -63,8 +63,8 @@
- $if(namespace.root.is_index)$ -${layouts/index()} + $if(layout.is_deep_categorized_list)$ +${layouts/deep_categorized_list()} $elseif(layout.is_categorized_list)$ ${layouts/categorized_list()} $elseif(layout.is_list)$ diff --git a/templates/layouts/categorized_list.html b/templates/layouts/categorized_list.html index a3af43c..ad510ae 100644 --- a/templates/layouts/categorized_list.html +++ b/templates/layouts/categorized_list.html @@ -11,36 +11,76 @@ $body$

$it.title$

- + $if(it.list_grid)$ + + $else$ + + $endif$ $endif$ $endfor$ - - diff --git a/templates/layouts/deep_categorized_list.html b/templates/layouts/deep_categorized_list.html new file mode 100644 index 0000000..eec16c9 --- /dev/null +++ b/templates/layouts/deep_categorized_list.html @@ -0,0 +1,54 @@ +
+ + + +
+ + diff --git a/templates/layouts/index.html b/templates/layouts/index.html deleted file mode 100644 index 1eca10f..0000000 --- a/templates/layouts/index.html +++ /dev/null @@ -1,67 +0,0 @@ -
- - -
-

- Profiles -

-
- $for(profiles)$ - $if(it.featured)$ - $if(it.url)$ - - $else$ - - $endif$ - $endif$ - $endfor$ -
- -

- $pages.by_id.projects.title$ -

-
- $for(pages.by_id.projects.pages.all)$ - $for(it.pages.all)$ - - $if(pages.by_id.projects.pages.all.icon)$ - - - - $endif$ -
- $pages.by_id.projects.pages.all.title$ - $it.title$ -
- - - -
- $endfor$ - $endfor$ -
-
-
diff --git a/templates/layouts/list.html b/templates/layouts/list.html index 2ef02ab..b4647a1 100644 --- a/templates/layouts/list.html +++ b/templates/layouts/list.html @@ -6,33 +6,75 @@ $body$ -- cgit v1.2.3-70-g09d2