From b5ea24207d9a6b1d6d7bc37d83952848588cd2e0 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sat, 15 Apr 2023 16:47:26 +0100 Subject: further blog infra structure --- blog/test-post.lua | 17 +++++++++++------ blogindex.lua | 37 +++++++++++++++++++++++++++++++++++++ build.sh | 8 ++++++-- h.lua | 1 + head.html | 7 ++++++- index.lua | 1 + 6 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 blogindex.lua diff --git a/blog/test-post.lua b/blog/test-post.lua index c6cbd84..06fe9e3 100644 --- a/blog/test-post.lua +++ b/blog/test-post.lua @@ -1,20 +1,24 @@ require'h' -head = mkhead'reblogcca' - - +local meta = { + title='what do i mean by "telephony"', + date="2022-12-22", + tags={"telephony"}, +} +if ... then return meta end +local head = mkhead'reblogcca' -top = header { +local top = header { img({id='me',src='/me.png'},''), h1 'rebecca blog', p [[ there is some text here ]], } -breadcrumbs = bcrumb { +local breadcrumbs = bcrumb { {'< home','/'}, {'rebecca blog','/blog'}, - {'what do i mean by "telephone"'} + {meta.title}, } sect = section { @@ -25,3 +29,4 @@ sect = section { print(html{ head, top, breadcrumbs, sect, }) + diff --git a/blogindex.lua b/blogindex.lua new file mode 100644 index 0000000..4322164 --- /dev/null +++ b/blogindex.lua @@ -0,0 +1,37 @@ +require'h' + +local head = mkhead'blog listing' +local top = mktopbox('/me.png','rebecca blog',p'page listing') +local bread = bcrumb{ + {'< home','/'}, + {'rebecca blog'} +} + +local metas={} +local posix = require'posix' +for fname in posix.dirent.files'blog' do + if fname:sub(1,1) ~= '.' then + local meta = loadfile('blog/'..fname)(true) + meta.fname = meta.fname or fname:gsub('%.lua$','') + table.insert(metas,meta) + end +end +table.sort(metas,function(a,b) return a.date>b.date end) + +local list = {} +for _,it in ipairs(metas) do + table.insert(list, li{ + tag('time',{datetime=it.date},it.date), + a(it.title,'/blog/'..it.fname..'.html') + }) +end + +local listsect = section { + p'the', + ul({class="postlist"},list) +} + + +print(html{ + head, top, bread, listsect +}) diff --git a/build.sh b/build.sh index 03ce4db..2590b09 100755 --- a/build.sh +++ b/build.sh @@ -35,7 +35,11 @@ bpn index cf bg.png cf me.png -md blog/ -bpn blog/test-post + +# md blog/ +# bpn blog/test-post +# bpn blog/post-alpha +# bpn blog/post-beta +# bp blogindex.lua blog/index.html cf 4d.html diff --git a/h.lua b/h.lua index 16ccb21..60b9ce3 100644 --- a/h.lua +++ b/h.lua @@ -39,6 +39,7 @@ local function fmt_tag(tag) end function tag(tname, a1, a2) + -- tag(tname,body) or tag(tname,attrs,body) local body, attrs if a2 then attrs=a1 body=a2 else attrs=nil body=a1 end return setmetatable({tag=true,tname=tname,attrs=attrs,body=body},{__tostring=fmt_tag}) diff --git a/head.html b/head.html index ef35088..6a4b2e9 100644 --- a/head.html +++ b/head.html @@ -4,16 +4,21 @@ diff --git a/index.lua b/index.lua index d8f7c2e..59a6879 100644 --- a/index.lua +++ b/index.lua @@ -38,6 +38,7 @@ footer = safe [[ + ]] -- cgit v1.2.3