diff options
author | dvs1 | 2024-12-16 20:54:10 +1000 |
---|---|---|
committer | dvs1 | 2024-12-16 20:54:10 +1000 |
commit | 38883f20665f5dc81a3aa568e6d6d8749cab4c9f (patch) | |
tree | f9e3ce877ccb96841afc48e99f0033c747550df5 | |
parent | Let's see if I can use emoji. (diff) | |
download | notYetAnotherWiki-38883f20665f5dc81a3aa568e6d6d8749cab4c9f.zip notYetAnotherWiki-38883f20665f5dc81a3aa568e6d6d8749cab4c9f.tar.gz notYetAnotherWiki-38883f20665f5dc81a3aa568e6d6d8749cab4c9f.tar.bz2 notYetAnotherWiki-38883f20665f5dc81a3aa568e6d6d8749cab4c9f.tar.xz |
TODO-- Implement smart menus.
-rw-r--r-- | TODO.HTML | 11 | ||||
-rw-r--r-- | TODO.md | 4 | ||||
-rw-r--r-- | about/index.HTML | 8 | ||||
-rw-r--r-- | default.template | 2 | ||||
-rw-r--r-- | index.HTML | 8 | ||||
-rw-r--r-- | menu.fragment (renamed from menu.md) | 0 | ||||
-rwxr-xr-x | notYetAnotherWiki.lua | 83 | ||||
-rw-r--r-- | testing/index.HTML | 8 |
8 files changed, 74 insertions, 50 deletions
@@ -34,14 +34,12 @@ | |||
34 | <table> | 34 | <table> |
35 | <tr> | 35 | <tr> |
36 | <td><img src="Connie_click-me.gif" alt="alt text" title="Not (Yet) (Another / A) Wiki."/></td> | 36 | <td><img src="Connie_click-me.gif" alt="alt text" title="Not (Yet) (Another / A) Wiki."/></td> |
37 | <td><a href="about/index.HTML">about</a> <a href="testing/index.HTML">testing</a> plus login and register buttons</td> | 37 | <td><a href="about/index.HTML">about</a> <a href="testing/index.HTML">testing</a> plus login and register buttons</td> |
38 | </tr> | 38 | </tr> |
39 | <td rowspan=0 style="background-color: rebeccapurple; text-align:left; white-space:nowrap; vertical-align:top"> | 39 | <td rowspan=0 style="background-color: rebeccapurple; text-align:left; white-space:nowrap; vertical-align:top"> |
40 | menu for the current directory | 40 | menu for the current directory |
41 | <menu> | 41 | <p><a href="index.HTML">index</a></p> |
42 | <li><a href="index.HTML">home</a></li> | 42 | <p><a href="TODO.HTML">TODO</a></p> |
43 | <li><a href="TODO.HTML">TODO</a></li> | ||
44 | </menu> | ||
45 | 43 | ||
46 | </td> | 44 | </td> |
47 | <td style="background-color: rebeccapurple"> | 45 | <td style="background-color: rebeccapurple"> |
@@ -55,9 +53,8 @@ | |||
55 | <h1></h1> | 53 | <h1></h1> |
56 | Author: | 54 | Author: |
57 | <p>Do these -</p> | 55 | <p>Do these -</p> |
58 | <p>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.</p> | ||
59 | <p>For such fragments, rename their results to menu.FRAGMENT. metadata.isFragment</p> | ||
60 | <p>BUG - sub directories get their links screwed with extra path.</p> | 56 | <p>BUG - sub directories get their links screwed with extra path.</p> |
57 | <p>For such fragments, rename their results to menu.FRAGMENT. metadata.isFragment</p> | ||
61 | <p>Contstruct metadata.webtrail in createHTML from links to index.HTML in the various bits of the path of the input file.</p> | 58 | <p>Contstruct metadata.webtrail in createHTML from links to index.HTML in the various bits of the path of the input file.</p> |
62 | <p>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.</p> | 59 | <p>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.</p> |
63 | <p>Add atom feed for single page. Alas cgit only seems to have ATOM feed on the whole repo, not individual files.</p> | 60 | <p>Add atom feed for single page. Alas cgit only seems to have ATOM feed on the whole repo, not individual files.</p> |
@@ -1,11 +1,9 @@ | |||
1 | Do these - | 1 | Do these - |
2 | 2 | ||
3 | 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. | 3 | BUG - sub directories get their links screwed with extra path. |
4 | 4 | ||
5 | For such fragments, rename their results to menu.FRAGMENT. metadata.isFragment | 5 | For such fragments, rename their results to menu.FRAGMENT. metadata.isFragment |
6 | 6 | ||
7 | BUG - sub directories get their links screwed with extra path. | ||
8 | |||
9 | Contstruct metadata.webtrail in createHTML from links to index.HTML in the various bits of the path of the input file. | 7 | Contstruct metadata.webtrail in createHTML from links to index.HTML in the various bits of the path of the input file. |
10 | 8 | ||
11 | 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. | 9 | 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 @@ | |||
34 | <table> | 34 | <table> |
35 | <tr> | 35 | <tr> |
36 | <td><img src="Connie_click-me.gif" alt="alt text" title="Not (Yet) (Another / A) Wiki."/></td> | 36 | <td><img src="Connie_click-me.gif" alt="alt text" title="Not (Yet) (Another / A) Wiki."/></td> |
37 | <td><a href="about/index.HTML">about</a> <a href="testing/index.HTML">testing</a> plus login and register buttons</td> | 37 | <td><a href="about/index.HTML">about</a> <a href="testing/index.HTML">testing</a> plus login and register buttons</td> |
38 | </tr> | 38 | </tr> |
39 | <td rowspan=0 style="background-color: rebeccapurple; text-align:left; white-space:nowrap; vertical-align:top"> | 39 | <td rowspan=0 style="background-color: rebeccapurple; text-align:left; white-space:nowrap; vertical-align:top"> |
40 | menu for the current directory | 40 | menu for the current directory |
41 | <menu> | 41 | <p><a href="index.HTML">index</a></p> |
42 | <li><a href="index.HTML">home</a></li> | 42 | <p><a href="TODO.HTML">TODO</a></p> |
43 | <li><a href="TODO.HTML">TODO</a></li> | ||
44 | </menu> | ||
45 | 43 | ||
46 | </td> | 44 | </td> |
47 | <td style="background-color: rebeccapurple"> | 45 | <td style="background-color: rebeccapurple"> |
diff --git a/default.template b/default.template index a0ab5d0..97f8073 100644 --- a/default.template +++ b/default.template | |||
@@ -34,7 +34,7 @@ | |||
34 | <table> | 34 | <table> |
35 | <tr> | 35 | <tr> |
36 | <td><img src="Connie_click-me.gif" alt="alt text" title="Not (Yet) (Another / A) Wiki."/></td> | 36 | <td><img src="Connie_click-me.gif" alt="alt text" title="Not (Yet) (Another / A) Wiki."/></td> |
37 | <td><a href="about/index.HTML">about</a> <a href="testing/index.HTML">testing</a> plus login and register buttons</td> | 37 | <td>$header$ plus login and register buttons</td> |
38 | </tr> | 38 | </tr> |
39 | <td rowspan=0 style="background-color: rebeccapurple; text-align:left; white-space:nowrap; vertical-align:top"> | 39 | <td rowspan=0 style="background-color: rebeccapurple; text-align:left; white-space:nowrap; vertical-align:top"> |
40 | menu for the current directory | 40 | menu for the current directory |
@@ -34,14 +34,12 @@ | |||
34 | <table> | 34 | <table> |
35 | <tr> | 35 | <tr> |
36 | <td><img src="Connie_click-me.gif" alt="alt text" title="Not (Yet) (Another / A) Wiki."/></td> | 36 | <td><img src="Connie_click-me.gif" alt="alt text" title="Not (Yet) (Another / A) Wiki."/></td> |
37 | <td><a href="about/index.HTML">about</a> <a href="testing/index.HTML">testing</a> plus login and register buttons</td> | 37 | <td><a href="about/index.HTML">about</a> <a href="testing/index.HTML">testing</a> plus login and register buttons</td> |
38 | </tr> | 38 | </tr> |
39 | <td rowspan=0 style="background-color: rebeccapurple; text-align:left; white-space:nowrap; vertical-align:top"> | 39 | <td rowspan=0 style="background-color: rebeccapurple; text-align:left; white-space:nowrap; vertical-align:top"> |
40 | menu for the current directory | 40 | menu for the current directory |
41 | <menu> | 41 | <p><a href="index.HTML">index</a></p> |
42 | <li><a href="index.HTML">home</a></li> | 42 | <p><a href="TODO.HTML">TODO</a></p> |
43 | <li><a href="TODO.HTML">TODO</a></li> | ||
44 | </menu> | ||
45 | 43 | ||
46 | </td> | 44 | </td> |
47 | <td style="background-color: rebeccapurple"> | 45 | <td style="background-color: rebeccapurple"> |
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua index 9fa3178..cfe7459 100755 --- a/notYetAnotherWiki.lua +++ b/notYetAnotherWiki.lua | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | local lcmark = require("lcmark") | 3 | local lcmark = require("lcmark") |
4 | 4 | ||
5 | local createHTML = function(cm, file, menu) | 5 | local createHTML = function(cm, file, header, menu) |
6 | -- cm = string.gsub(cm, '._ ', '. ') | 6 | -- cm = string.gsub(cm, '._ ', '. ') |
7 | if nil ~= file then print('About to parse file ' .. file) end | 7 | if nil ~= file then print('About to parse file ' .. file) end |
8 | local result = '' | 8 | local result = '' |
@@ -19,6 +19,7 @@ local createHTML = function(cm, file, menu) | |||
19 | templateFile = nil | 19 | templateFile = nil |
20 | else | 20 | else |
21 | metadata.menu = menu | 21 | metadata.menu = menu |
22 | metadata.header = header | ||
22 | end | 23 | end |
23 | metadata.body = lcmark.apply_template(bod, metadata) | 24 | metadata.body = lcmark.apply_template(bod, metadata) |
24 | 25 | ||
@@ -55,43 +56,77 @@ local createHTML = function(cm, file, menu) | |||
55 | end | 56 | end |
56 | 57 | ||
57 | 58 | ||
58 | local cm = '' | 59 | local cm, filename, header, menu = '', '', '', '' |
59 | local filename = '' | 60 | local site = {} |
60 | local menu = '' | ||
61 | 61 | ||
62 | for l in io.popen('find . -name "*.md" -type f -printf "%P\n"'):lines() do | ||
63 | local s = {} | ||
64 | local f = '' | ||
65 | local c = 1 | ||
66 | for p in string.gmatch(l, '(%w+)/') do | ||
67 | table.insert(s, p) | ||
68 | c = c + #p + 1 | ||
69 | end | ||
70 | local full = string.sub(l, c, -1) | ||
71 | local base = string.gsub(full, '%.md$', '') | ||
72 | table.insert(s, base) | ||
62 | 73 | ||
63 | local h = io.open('menu.md', 'r') | 74 | if 'menu' == s[#s] then |
64 | if nil ~= h then | 75 | local h = io.open(l, 'r') |
65 | print('Found menu.md') | 76 | if nil ~= h then |
66 | menu = createHTML(h:read('*a')) | 77 | print('Found ' .. l) |
67 | h:close() | 78 | menu = createHTML(h:read('*a')) |
68 | menu = string.gsub(menu, 'ul>', 'menu>') | 79 | h:close() |
80 | menu = string.gsub(menu, 'ul>', 'menu>') | ||
81 | end | ||
82 | else | ||
83 | if 1 ~= #s then | ||
84 | site[l] = s | ||
85 | else | ||
86 | site[l] = base | ||
87 | end | ||
88 | end | ||
69 | end | 89 | end |
70 | 90 | ||
91 | -- TODO - Only do these first things if menu.md doesn't exist, the second for headers.md | ||
92 | --if '' == menu then | ||
93 | for k, v in pairs(site) do | ||
94 | if 'string' == type(v) then | ||
95 | local m = '[' .. v .. '](' .. v .. '.HTML)\n' | ||
96 | menu = menu .. string.gsub(createHTML(m), 'ul>', 'menu>') | ||
97 | else | ||
98 | local path = '' | ||
99 | for i, w in ipairs(v) do | ||
100 | path = path .. w .. '/' | ||
101 | end | ||
102 | header = header .. '<a href="' .. string.sub(path, 1, -2) .. '.HTML">' .. v[1] .. '</a> ' | ||
103 | end | ||
104 | end | ||
105 | --end | ||
71 | 106 | ||
72 | if 0 ~= #arg then | 107 | |
73 | for i,a in ipairs(arg) do | 108 | if 0 == #arg then |
74 | if filename == '' then filename = a end | 109 | for l in io.popen('find . -name "*.md" -type f -printf "%P\n"'):lines() do |
75 | local h = io.open(a, 'r') | 110 | cm = '' |
111 | local h = io.open(l, 'r') | ||
76 | if nil ~= h then | 112 | if nil ~= h then |
77 | cm = cm .. h:read('*a') | 113 | createHTML(h:read('*a'), l, header, menu) |
78 | h:close() | 114 | h:close() |
79 | else | 115 | else |
80 | print('oops! No such file ' .. a) | 116 | print('oops! No such file ' .. l) |
81 | end | 117 | end |
82 | end | 118 | end |
83 | if filename == '' then filename = 'test.md' end | ||
84 | createHTML(cm, filename, menu) | ||
85 | else | 119 | else |
86 | local sticks = io.popen('find . -name "*.md" -type f -printf "%P\n"') | 120 | for i,a in ipairs(arg) do |
87 | for l in sticks:lines() do | 121 | if filename == '' then filename = a end |
88 | cm = '' | 122 | local h = io.open(a, 'r') |
89 | local h = io.open(l, 'r') | ||
90 | if nil ~= h then | 123 | if nil ~= h then |
91 | createHTML(h:read('*a'), l, menu) | 124 | cm = cm .. h:read('*a') |
92 | h:close() | 125 | h:close() |
93 | else | 126 | else |
94 | print('oops! No such file ' .. l) | 127 | print('oops! No such file ' .. a) |
95 | end | 128 | end |
96 | end | 129 | end |
130 | if filename == '' then filename = 'test.md' end | ||
131 | createHTML(cm, filename, header, menu) | ||
97 | end | 132 | 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 @@ | |||
34 | <table> | 34 | <table> |
35 | <tr> | 35 | <tr> |
36 | <td><img src="Connie_click-me.gif" alt="alt text" title="Not (Yet) (Another / A) Wiki."/></td> | 36 | <td><img src="Connie_click-me.gif" alt="alt text" title="Not (Yet) (Another / A) Wiki."/></td> |
37 | <td><a href="about/index.HTML">about</a> <a href="testing/index.HTML">testing</a> plus login and register buttons</td> | 37 | <td><a href="about/index.HTML">about</a> <a href="testing/index.HTML">testing</a> plus login and register buttons</td> |
38 | </tr> | 38 | </tr> |
39 | <td rowspan=0 style="background-color: rebeccapurple; text-align:left; white-space:nowrap; vertical-align:top"> | 39 | <td rowspan=0 style="background-color: rebeccapurple; text-align:left; white-space:nowrap; vertical-align:top"> |
40 | menu for the current directory | 40 | menu for the current directory |
41 | <menu> | 41 | <p><a href="index.HTML">index</a></p> |
42 | <li><a href="index.HTML">home</a></li> | 42 | <p><a href="TODO.HTML">TODO</a></p> |
43 | <li><a href="TODO.HTML">TODO</a></li> | ||
44 | </menu> | ||
45 | 43 | ||
46 | </td> | 44 | </td> |
47 | <td style="background-color: rebeccapurple"> | 45 | <td style="background-color: rebeccapurple"> |