From 38883f20665f5dc81a3aa568e6d6d8749cab4c9f Mon Sep 17 00:00:00 2001
From: dvs1
Date: Mon, 16 Dec 2024 20:54:10 +1000
Subject: TODO-- Implement smart menus.
---
TODO.HTML | 11 +++----
TODO.md | 4 +--
about/index.HTML | 8 ++---
default.template | 2 +-
index.HTML | 8 ++---
menu.fragment | 6 ++++
menu.md | 6 ----
notYetAnotherWiki.lua | 83 ++++++++++++++++++++++++++++++++++++---------------
testing/index.HTML | 8 ++---
9 files changed, 80 insertions(+), 56 deletions(-)
create mode 100644 menu.fragment
delete mode 100644 menu.md
diff --git a/TODO.HTML b/TODO.HTML
index 8002a46..cd3c57c 100644
--- a/TODO.HTML
+++ b/TODO.HTML
@@ -34,14 +34,12 @@
|
- about testing plus login and register buttons |
+ about testing plus login and register buttons |
menu for the current directory
-
+ index
+TODO
|
@@ -55,9 +53,8 @@
Author:
Do these -
-Construct a default set of menus if the menu.md / header.md fragments don’t exist in each directory. Same for footer.md I guess.
-For such fragments, rename their results to menu.FRAGMENT. metadata.isFragment
BUG - sub directories get their links screwed with extra path.
+For such fragments, rename their results to menu.FRAGMENT. metadata.isFragment
Contstruct metadata.webtrail in createHTML from links to index.HTML in the various bits of the path of the input file.
Check the timestamps on the files, only update if source is newer than destination. Meh, it’s already 600 times faster than the pandoc version.
Add atom feed for single page. Alas cgit only seems to have ATOM feed on the whole repo, not individual files.
diff --git a/TODO.md b/TODO.md
index c4cab66..697904e 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,11 +1,9 @@
Do these -
-Construct a default set of menus if the menu.md / header.md fragments don't exist in each directory. Same for footer.md I guess.
+BUG - sub directories get their links screwed with extra path.
For such fragments, rename their results to menu.FRAGMENT. metadata.isFragment
-BUG - sub directories get their links screwed with extra path.
-
Contstruct metadata.webtrail in createHTML from links to index.HTML in the various bits of the path of the input file.
Check the timestamps on the files, only update if source is newer than destination. Meh, it's already 600 times faster than the pandoc version.
diff --git a/about/index.HTML b/about/index.HTML
index a46aa36..bb6a53c 100644
--- a/about/index.HTML
+++ b/about/index.HTML
@@ -34,14 +34,12 @@
|
- about testing plus login and register buttons |
+ about testing plus login and register buttons |
menu for the current directory
-
+ index
+TODO
|
diff --git a/default.template b/default.template
index a0ab5d0..97f8073 100644
--- a/default.template
+++ b/default.template
@@ -34,7 +34,7 @@
|
- about testing plus login and register buttons |
+ $header$ plus login and register buttons |
menu for the current directory
diff --git a/index.HTML b/index.HTML
index 8d433c5..2bcb624 100644
--- a/index.HTML
+++ b/index.HTML
@@ -34,14 +34,12 @@
|
- about testing plus login and register buttons |
+ about testing plus login and register buttons |
menu for the current directory
-
+ index
+TODO
|
diff --git a/menu.fragment b/menu.fragment
new file mode 100644
index 0000000..7a0e09f
--- /dev/null
+++ b/menu.fragment
@@ -0,0 +1,6 @@
+---
+template: menu
+---
+
+- [home](index.HTML)
+- [TODO](TODO.HTML)
diff --git a/menu.md b/menu.md
deleted file mode 100644
index 7a0e09f..0000000
--- a/menu.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-template: menu
----
-
-- [home](index.HTML)
-- [TODO](TODO.HTML)
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua
index 9fa3178..cfe7459 100755
--- a/notYetAnotherWiki.lua
+++ b/notYetAnotherWiki.lua
@@ -2,7 +2,7 @@
local lcmark = require("lcmark")
-local createHTML = function(cm, file, menu)
+local createHTML = function(cm, file, header, menu)
-- cm = string.gsub(cm, '._ ', '. ')
if nil ~= file then print('About to parse file ' .. file) end
local result = ''
@@ -19,6 +19,7 @@ local createHTML = function(cm, file, menu)
templateFile = nil
else
metadata.menu = menu
+ metadata.header = header
end
metadata.body = lcmark.apply_template(bod, metadata)
@@ -55,43 +56,77 @@ local createHTML = function(cm, file, menu)
end
-local cm = ''
-local filename = ''
-local menu = ''
+local cm, filename, header, menu = '', '', '', ''
+local site = {}
+for l in io.popen('find . -name "*.md" -type f -printf "%P\n"'):lines() do
+ local s = {}
+ local f = ''
+ local c = 1
+ for p in string.gmatch(l, '(%w+)/') do
+ table.insert(s, p)
+ c = c + #p + 1
+ end
+ local full = string.sub(l, c, -1)
+ local base = string.gsub(full, '%.md$', '')
+ table.insert(s, base)
-local h = io.open('menu.md', 'r')
-if nil ~= h then
- print('Found menu.md')
- menu = createHTML(h:read('*a'))
- h:close()
- menu = string.gsub(menu, 'ul>', 'menu>')
+ if 'menu' == s[#s] then
+ local h = io.open(l, 'r')
+ if nil ~= h then
+ print('Found ' .. l)
+ menu = createHTML(h:read('*a'))
+ h:close()
+ menu = string.gsub(menu, 'ul>', 'menu>')
+ end
+ else
+ if 1 ~= #s then
+ site[l] = s
+ else
+ site[l] = base
+ end
+ end
end
+-- TODO - Only do these first things if menu.md doesn't exist, the second for headers.md
+--if '' == menu then
+ for k, v in pairs(site) do
+ if 'string' == type(v) then
+ local m = '[' .. v .. '](' .. v .. '.HTML)\n'
+ menu = menu .. string.gsub(createHTML(m), 'ul>', 'menu>')
+ else
+ local path = ''
+ for i, w in ipairs(v) do
+ path = path .. w .. '/'
+ end
+ header = header .. '' .. v[1] .. ' '
+ end
+ end
+--end
-if 0 ~= #arg then
- for i,a in ipairs(arg) do
- if filename == '' then filename = a end
- local h = io.open(a, 'r')
+
+if 0 == #arg then
+ for l in io.popen('find . -name "*.md" -type f -printf "%P\n"'):lines() do
+ cm = ''
+ local h = io.open(l, 'r')
if nil ~= h then
- cm = cm .. h:read('*a')
+ createHTML(h:read('*a'), l, header, menu)
h:close()
else
- print('oops! No such file ' .. a)
+ print('oops! No such file ' .. l)
end
end
- if filename == '' then filename = 'test.md' end
- createHTML(cm, filename, menu)
else
- local sticks = io.popen('find . -name "*.md" -type f -printf "%P\n"')
- for l in sticks:lines() do
- cm = ''
- local h = io.open(l, 'r')
+ for i,a in ipairs(arg) do
+ if filename == '' then filename = a end
+ local h = io.open(a, 'r')
if nil ~= h then
- createHTML(h:read('*a'), l, menu)
+ cm = cm .. h:read('*a')
h:close()
else
- print('oops! No such file ' .. l)
+ print('oops! No such file ' .. a)
end
end
+ if filename == '' then filename = 'test.md' end
+ createHTML(cm, filename, header, menu)
end
diff --git a/testing/index.HTML b/testing/index.HTML
index befc0aa..05a496e 100644
--- a/testing/index.HTML
+++ b/testing/index.HTML
@@ -34,14 +34,12 @@
| | | |