From 9763ea03164f983d77051a84609dcae80885b1c0 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Fri, 12 Nov 2021 20:39:46 +0100 Subject: Improved page --- assets/css/components/_header.scss | 2 +- .../9thPK7O3xn/dreams/biological-experiments.md | 5 +- content/9thPK7O3xn/dreams/false-awakening.md | 5 +- content/9thPK7O3xn/dreams/index.md | 2 +- content/9thPK7O3xn/dreams/infinite-skyscrapers.md | 5 +- filters/common_actions.lua | 2 +- scripts/metadata_filter.lua | 57 ++++++++-------------- templates/base.html | 4 +- templates/feed.xml | 6 +-- templates/layouts/categorized_list.html | 54 ++++++++------------ templates/layouts/index.html | 8 +-- templates/layouts/list.html | 50 +++++++------------ templates/layouts/page.html | 2 +- 13 files changed, 74 insertions(+), 128 deletions(-) diff --git a/assets/css/components/_header.scss b/assets/css/components/_header.scss index 90ed827..1a10345 100644 --- a/assets/css/components/_header.scss +++ b/assets/css/components/_header.scss @@ -26,7 +26,7 @@ ), 'light'); @include component(namespace()) { - height: prop(--dims --height); + height: prop(--dims --height); @include element('nav') { display: inline-flex; diff --git a/content/9thPK7O3xn/dreams/biological-experiments.md b/content/9thPK7O3xn/dreams/biological-experiments.md index acf2198..156e300 100644 --- a/content/9thPK7O3xn/dreams/biological-experiments.md +++ b/content/9thPK7O3xn/dreams/biological-experiments.md @@ -1,7 +1,6 @@ --- -date: 2012-01-01 -title: Biological experiments -show_date: true +date: 2012-01-01 +title: Biological experiments --- *I don't remember the real date of this dream, just that it happened in 2012.* diff --git a/content/9thPK7O3xn/dreams/false-awakening.md b/content/9thPK7O3xn/dreams/false-awakening.md index 6499b98..7d6d8d4 100644 --- a/content/9thPK7O3xn/dreams/false-awakening.md +++ b/content/9thPK7O3xn/dreams/false-awakening.md @@ -1,7 +1,6 @@ --- -date: 2015-07-29 -title: False awakening -show_date: true +date: 2015-07-29 +title: False awakening --- It was noon. I was tired and decided to lie down for a bit. I didn't want to fall asleep, though, so I tried to stay awake and kept checking the time since I had to go to the uni later. This went on for quite a while, resulting in a constant cycle of dozing → remembering to check the time → looking at my smartphone to check the time → going back to dozing → and so on. diff --git a/content/9thPK7O3xn/dreams/index.md b/content/9thPK7O3xn/dreams/index.md index c230cef..8c72776 100644 --- a/content/9thPK7O3xn/dreams/index.md +++ b/content/9thPK7O3xn/dreams/index.md @@ -2,7 +2,7 @@ title: Dream Journal position: 9 layout: list -show_dates: true +list_order: date_desc show_read_indicators: true create_feed: true --- diff --git a/content/9thPK7O3xn/dreams/infinite-skyscrapers.md b/content/9thPK7O3xn/dreams/infinite-skyscrapers.md index d02f9f4..33718a1 100644 --- a/content/9thPK7O3xn/dreams/infinite-skyscrapers.md +++ b/content/9thPK7O3xn/dreams/infinite-skyscrapers.md @@ -1,7 +1,6 @@ --- -date: 2021-01-09 -title: Infinite skyscrapers -show_date: true +date: 2021-01-09 +title: Infinite skyscrapers --- I'm in some strange world that consist of huge buildings, looking a lot like very simple skyscrapers, except they were all interconnected. I'm not even sure if there's a floor since I'm just floating, being able to fly around at will. There is also something chasing me and I'm trying to get away from it. diff --git a/filters/common_actions.lua b/filters/common_actions.lua index 8383ada..cfe2d58 100644 --- a/filters/common_actions.lua +++ b/filters/common_actions.lua @@ -22,7 +22,7 @@ function Header(el) if el.level <= 3 and el.identifier ~= '' then el.content:insert(pandoc.Space()) el.content:insert(pandoc.Link(pandoc.RawInline('html', - ''), + ''), '#' .. el.identifier, nil, { class = 's-headlines__link' })) end diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua index daad940..7039a2c 100644 --- a/scripts/metadata_filter.lua +++ b/scripts/metadata_filter.lua @@ -102,18 +102,16 @@ function prep_menu(active_id, main_menu) return { items = items, active = active_item } end -function process_pages(global, pages_by_id) +function process_pages(global, order, pages_by_id) if not pages_by_id then return nil end local pages_all = pandoc.List() - local pages_asc_title = pandoc.List() - local pages_desc_date = pandoc.List() + local pages_date_desc = pandoc.List() for _, page in pairs(pages_by_id) do local p = process(global, page) pages_all:insert(p) - pages_asc_title:insert(p) - if p.date then pages_desc_date:insert(p) end + if p.date then pages_date_desc:insert(p) end end pages_all:sort(function(p1, p2) @@ -125,20 +123,22 @@ function process_pages(global, pages_by_id) end elseif p2.position then return false - elseif p1.date then - if p2.date then - return p1.date.yyyy_mm_dd > p2.date.yyyy_mm_dd + elseif order == "date_desc" then + if p1.date then + if p2.date then + return p1.date.yyyy_mm_dd > p2.date.yyyy_mm_dd + else + return true + end else - return true + return false end - elseif p2.date then - return false else return p1.title < p2.title end end) - pages_desc_date:sort(function(p1, p2) + pages_date_desc:sort(function(p1, p2) if p1.position then if p2.position then return tonumber(p1.position) < tonumber(p2.position) @@ -150,26 +150,7 @@ function process_pages(global, pages_by_id) end end) - pages_asc_title:sort(function(p1, p2) - if p1.position then - if p2.position then - return tonumber(p1.position) < tonumber(p2.position) - else - return true - end - elseif p2.position then - return false - else - return p1.title < p2.title - end - end) - - local pages_data = { - all = pages_all, - desc_date = pages_desc_date, - asc_title = pages_asc_title, - by_id = pages_by_id, - } + local pages_data = { all = pages_all, date_desc = pages_date_desc, by_id = pages_by_id } return pages_data end @@ -196,7 +177,7 @@ function process(global, meta) 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 "" - + 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 if meta.create_feed then @@ -222,18 +203,18 @@ function process(global, meta) meta.menus.main = prep_menu(meta.namespace.root.id, meta.menus.main) end - meta.pages = process_pages(global, meta.pages) + meta.pages = process_pages(global, meta.list_order, meta.pages) if meta.date then meta.date = format_date(meta.date) - elseif meta.pages and #meta.pages.desc_date ~= 0 then - meta.date = meta.pages.desc_date[1].date + elseif meta.pages and #meta.pages.date_desc ~= 0 then + meta.date = meta.pages.date_desc[1].date end if meta.last_update then meta.last_update = format_date(meta.last_update) - elseif meta.pages and #meta.pages.desc_date ~= 0 then - meta.last_update = meta.pages.desc_date[1].last_update + elseif meta.pages and #meta.pages.date_desc ~= 0 then + meta.last_update = meta.pages.date_desc[1].last_update elseif meta.date then meta.last_update = meta.date end diff --git a/templates/base.html b/templates/base.html index 6573dc5..6424447 100644 --- a/templates/base.html +++ b/templates/base.html @@ -23,7 +23,7 @@ $endif$ $if(layout.is_categorized_list)$ - $for(pages.asc_title)$ + $for(pages.all)$ $if(it.feed)$ $endif$ @@ -47,7 +47,7 @@