diff options
| -rw-r--r-- | TODO.HTML | 48 | ||||
| -rw-r--r-- | TODO.md | 40 | ||||
| -rw-r--r-- | about/index.HTML | 9 | ||||
| -rw-r--r-- | default.template | 2 | ||||
| -rw-r--r-- | index.HTML | 17 | ||||
| -rwxr-xr-x | notYetAnotherWiki.lua | 170 |
6 files changed, 165 insertions, 121 deletions
| @@ -4,8 +4,8 @@ | |||
| 4 | <meta charset="utf-8"> | 4 | <meta charset="utf-8"> |
| 5 | <meta name="generator" contents="lcmark"> | 5 | <meta name="generator" contents="lcmark"> |
| 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> | 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> |
| 7 | <title></title> | 7 | <title>TODO</title> |
| 8 | <link rel="icon" type="image/png" href="" /> | 8 | <link rel="icon" type="image/png" href="cartdave_favicon.png" /> |
| 9 | <style> | 9 | <style> |
| 10 | html {font-family: sans-serif;} | 10 | html {font-family: sans-serif;} |
| 11 | 11 | ||
| @@ -34,12 +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/">about</a> <a href="testing/">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 | <p><a href="TODO.HTML">TODO</a></p> | 41 | <p><a href="index.HTML">index</a></p> |
| 42 | <p><a href="index.HTML">index</a></p> | 42 | <p><a href="TODO.HTML">TODO</a></p> |
| 43 | 43 | ||
| 44 | </td> | 44 | </td> |
| 45 | <td style="background-color: rebeccapurple"> | 45 | <td style="background-color: rebeccapurple"> |
| @@ -50,29 +50,29 @@ | |||
| 50 | <td> | 50 | <td> |
| 51 | <main class="contentBox"> | 51 | <main class="contentBox"> |
| 52 | <div name="contentFrame"> | 52 | <div name="contentFrame"> |
| 53 | <h1></h1> | 53 | <h1>TODO</h1> |
| 54 | Author: | 54 | Author: onefang |
| 55 | <p>Do these -</p> | 55 | <h2>Do these</h2> |
| 56 | <p>BUG - sub directories get their links screwed with extra path.</p> | 56 | <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. |
| 57 | <p>For such fragments, rename their results to menu.FRAGMENT. metadata.isFragment</p> | 57 | One quirk to watch for is if a URL path cahnges, the docs that have that URL need to be redone.</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> | ||
| 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> | ||
| 60 | <p>Add atom feed for single page. Alas cgit only seems to have ATOM feed on the whole repo, not individual files.</p> | 58 | <p>Add atom feed for single page. Alas cgit only seems to have ATOM feed on the whole repo, not individual files.</p> |
| 61 | <p>Try out -</p> | 59 | <h2>Try out</h2> |
| 62 | <p>htmx</p> | 60 | <p>htmx</p> |
| 63 | <p>pandoc replacements | 61 | <p>pandoc replacements |
| 64 | cmark-gfm</p> | 62 | cmark-gfm</p> |
| 65 | <p>cgit has Lua</p> | 63 | <p>cgit has Lua</p> |
| 66 | <p>User system - | 64 | <h2>User system</h2> |
| 67 | levels - | 65 | <ul> |
| 68 | banned | 66 | <li>levels -</li> |
| 69 | reader | 67 | <li>banned</li> |
| 70 | member | 68 | <li>reader</li> |
| 71 | moderator | 69 | <li>member</li> |
| 72 | editor | 70 | <li>moderator</li> |
| 73 | admin | 71 | <li>editor</li> |
| 74 | shell | 72 | <li>admin</li> |
| 75 | root</p> | 73 | <li>shell</li> |
| 74 | <li>root</li> | ||
| 75 | </ul> | ||
| 76 | <p>Banned people can’t do squat, except maybe pester an admin once to start the unbanning process.</p> | 76 | <p>Banned people can’t do squat, except maybe pester an admin once to start the unbanning process.</p> |
| 77 | <p>When first registered, accounts are set to reader level. | 77 | <p>When first registered, accounts are set to reader level. |
| 78 | Initial verification by email. | 78 | Initial verification by email. |
| @@ -100,7 +100,7 @@ Built in file browser might do the trick. Would be useful for content creators | |||
| 100 | </tr> | 100 | </tr> |
| 101 | <tr> | 101 | <tr> |
| 102 | <td style="background-color: rebeccapurple"> | 102 | <td style="background-color: rebeccapurple"> |
| 103 | <p>Page <a href="">history</a>. Web site <a href="">atom feed</a> and <a href="">source code</a> Powered by <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/about/">notYetAnotherWiki</a> Version -0.1.</p> | 103 | <p>Page <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/log/TODO.md">history</a>. Web site <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/atom">atom feed</a> and <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/">source code</a> Powered by <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/about/">notYetAnotherWiki</a> Version -0.1.</p> |
| 104 | </td> | 104 | </td> |
| 105 | </tr> | 105 | </tr> |
| 106 | <tr> | 106 | <tr> |
| @@ -1,18 +1,21 @@ | |||
| 1 | Do these - | 1 | --- |
| 2 | 2 | favicon: cartdave_favicon.png | |
| 3 | BUG - sub directories get their links screwed with extra path. | 3 | pagetitle: "TODO" |
| 4 | 4 | author: onefang | |
| 5 | For such fragments, rename their results to menu.FRAGMENT. metadata.isFragment | 5 | feedatom: https://sledjhamr.org/cgit/notYetAnotherWiki/atom |
| 6 | 6 | history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/TODO.md | |
| 7 | Contstruct metadata.webtrail in createHTML from links to index.HTML in the various bits of the path of the input file. | 7 | sourcecode: https://sledjhamr.org/cgit/notYetAnotherWiki/ |
| 8 | --- | ||
| 9 | ## Do these | ||
| 8 | 10 | ||
| 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. | 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. |
| 12 | One quirk to watch for is if a URL path cahnges, the docs that have that URL need to be redone. | ||
| 10 | 13 | ||
| 11 | Add atom feed for single page. Alas cgit only seems to have ATOM feed on the whole repo, not individual files. | 14 | Add atom feed for single page. Alas cgit only seems to have ATOM feed on the whole repo, not individual files. |
| 12 | 15 | ||
| 13 | 16 | ||
| 14 | 17 | ||
| 15 | Try out - | 18 | ## Try out |
| 16 | 19 | ||
| 17 | htmx | 20 | htmx |
| 18 | 21 | ||
| @@ -23,16 +26,17 @@ cgit has Lua | |||
| 23 | 26 | ||
| 24 | 27 | ||
| 25 | 28 | ||
| 26 | User system - | 29 | ## User system |
| 27 | levels - | 30 | |
| 28 | banned | 31 | - levels - |
| 29 | reader | 32 | - banned |
| 30 | member | 33 | - reader |
| 31 | moderator | 34 | - member |
| 32 | editor | 35 | - moderator |
| 33 | admin | 36 | - editor |
| 34 | shell | 37 | - admin |
| 35 | root | 38 | - shell |
| 39 | - root | ||
| 36 | 40 | ||
| 37 | Banned people can't do squat, except maybe pester an admin once to start the unbanning process. | 41 | Banned people can't do squat, except maybe pester an admin once to start the unbanning process. |
| 38 | 42 | ||
diff --git a/about/index.HTML b/about/index.HTML index e0cbee3..1488bdd 100644 --- a/about/index.HTML +++ b/about/index.HTML | |||
| @@ -34,16 +34,15 @@ | |||
| 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> 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 | <p><a href="TODO.HTML">TODO</a></p> | 41 | <p><a href="index.HTML">index</a></p> |
| 42 | <p><a href="index.HTML">index</a></p> | ||
| 43 | 42 | ||
| 44 | </td> | 43 | </td> |
| 45 | <td style="background-color: rebeccapurple"> | 44 | <td style="background-color: rebeccapurple"> |
| 46 | 👣 Web trail goes here. | 45 | 👣 |
| 47 | </td> | 46 | </td> |
| 48 | </tr> | 47 | </tr> |
| 49 | <tr> | 48 | <tr> |
| @@ -68,7 +67,7 @@ system built into the thing. Now it’s Yet Another Wiki.</p> | |||
| 68 | </tr> | 67 | </tr> |
| 69 | <tr> | 68 | <tr> |
| 70 | <td style="background-color: rebeccapurple"> | 69 | <td style="background-color: rebeccapurple"> |
| 71 | <p>Page <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/log/About/index.md">history</a>. Web site <a href="">atom feed</a> and <a href="">source code</a> Powered by <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/about/">notYetAnotherWiki</a> Version -0.1.</p> | 70 | <p>Page <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/log/About/index.md">history</a>. Web site <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/atom">atom feed</a> and <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/">source code</a> Powered by <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/about/">notYetAnotherWiki</a> Version -0.1.</p> |
| 72 | </td> | 71 | </td> |
| 73 | </tr> | 72 | </tr> |
| 74 | <tr> | 73 | <tr> |
diff --git a/default.template b/default.template index 97f8073..f8a435f 100644 --- a/default.template +++ b/default.template | |||
| @@ -41,7 +41,7 @@ | |||
| 41 | $menu$ | 41 | $menu$ |
| 42 | </td> | 42 | </td> |
| 43 | <td style="background-color: rebeccapurple"> | 43 | <td style="background-color: rebeccapurple"> |
| 44 | 👣 $webtrail$ | 44 | 👣 $trail$ |
| 45 | </td> | 45 | </td> |
| 46 | </tr> | 46 | </tr> |
| 47 | <tr> | 47 | <tr> |
| @@ -34,16 +34,16 @@ | |||
| 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/">about</a> <a href="testing/">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 | <p><a href="TODO.HTML">TODO</a></p> | 41 | <p><a href="index.HTML">index</a></p> |
| 42 | <p><a href="index.HTML">index</a></p> | 42 | <p><a href="TODO.HTML">TODO</a></p> |
| 43 | 43 | ||
| 44 | </td> | 44 | </td> |
| 45 | <td style="background-color: rebeccapurple"> | 45 | <td style="background-color: rebeccapurple"> |
| 46 | 👣 Web trail goes here. | 46 | 👣 |
| 47 | </td> | 47 | </td> |
| 48 | </tr> | 48 | </tr> |
| 49 | <tr> | 49 | <tr> |
| @@ -86,6 +86,15 @@ are moved to the decumentation section, where the original participants | |||
| 86 | and others can polish it into proper documentation about solving what has | 86 | and others can polish it into proper documentation about solving what has |
| 87 | suddenly become a common problem. Every one knows where to find it, on | 87 | suddenly become a common problem. Every one knows where to find it, on |
| 88 | the one system. They can chat about it, on the one system.</p> | 88 | the one system. They can chat about it, on the one system.</p> |
| 89 | <h2>What does it do already?</h2> | ||
| 90 | <p>Currently it’ll scan the current directory and subdirectories rooking for | ||
| 91 | .md files in CommonMark syntax. This should cover some MarkDown | ||
| 92 | variations. Then it produces .HTML files converted from these .md files, | ||
| 93 | and links them all together into a web site.</p> | ||
| 94 | <p>git is used to store the .md files, and provides edit history. Added on | ||
| 95 | the footer is links to cgit, which is used to store the files in git on | ||
| 96 | your server. This provides acces to the source code, history, and ATOM | ||
| 97 | feed for the site.</p> | ||
| 89 | 98 | ||
| 90 | </div> | 99 | </div> |
| 91 | </main> | 100 | </main> |
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua index 1746b0a..9d6f3f7 100755 --- a/notYetAnotherWiki.lua +++ b/notYetAnotherWiki.lua | |||
| @@ -2,13 +2,12 @@ | |||
| 2 | 2 | ||
| 3 | local lcmark = require("lcmark") | 3 | local lcmark = require("lcmark") |
| 4 | 4 | ||
| 5 | local globalData = {header = '', footer = '', menu = '', ['_'] = ' '} | 5 | local globalData = {header = '', footer = '', menu = '', ['_'] = ' ', ['dlr'] = '$'} |
| 6 | local site = {} | 6 | local site = {} |
| 7 | 7 | local dirs = {} | |
| 8 | |||
| 9 | local createHTML = function(cm, file) | 8 | local createHTML = function(cm, file) |
| 10 | -- cm = string.gsub(cm, '. ', '. ') | 9 | -- cm = string.gsub(cm, '. ', '. ') |
| 11 | if nil ~= file then print('About to parse file ' .. file) end | 10 | if nil ~= file then print('\nAbout to parse file ' .. file) end |
| 12 | local result = '' | 11 | local result = '' |
| 13 | local body, metadata, err = lcmark.convert(cm, "html", {smart = true, yaml_metadata = true, columns = 0}) | 12 | local body, metadata, err = lcmark.convert(cm, "html", {smart = true, yaml_metadata = true, columns = 0}) |
| 14 | 13 | ||
| @@ -25,11 +24,62 @@ local createHTML = function(cm, file) | |||
| 25 | if nill == metadata[k] then metadata[k] = v else print('metadata already has ' .. k) end | 24 | if nill == metadata[k] then metadata[k] = v else print('metadata already has ' .. k) end |
| 26 | end | 25 | end |
| 27 | end | 26 | end |
| 27 | |||
| 28 | if nil ~= file then | ||
| 29 | local depth = 0 | ||
| 30 | local base = '' | ||
| 31 | for p in string.gmatch(file, '(%w+)/') do | ||
| 32 | depth = depth + 1 | ||
| 33 | base = p | ||
| 34 | end | ||
| 35 | local path = string.sub(file, 1, #base) | ||
| 36 | |||
| 37 | metadata.header = '' | ||
| 38 | metadata.menu = '' | ||
| 39 | local trl = {} | ||
| 40 | metadata.trail = '' | ||
| 41 | local dir = dirs[''] | ||
| 42 | local dr, pdr, tr = '', '', '' | ||
| 43 | while nil ~= dir.subs do | ||
| 44 | local old = dir | ||
| 45 | for m, x in pairs(dir.subs) do | ||
| 46 | if x == string.sub(file, 1, #x) then | ||
| 47 | pdr = pdr .. '/' .. m | ||
| 48 | tr = tr .. '../' | ||
| 49 | dr = m | ||
| 50 | dir = dirs[dr] | ||
| 51 | table.insert(trl, '">' .. m .. '</a> 👣') | ||
| 52 | break | ||
| 53 | end | ||
| 54 | end | ||
| 55 | if old == dir then break end | ||
| 56 | end | ||
| 57 | table.remove(trl) | ||
| 58 | for m, x in ipairs(trl) do | ||
| 59 | tr = string.sub(tr, 4) | ||
| 60 | trl[m] = ' <a href="' .. tr .. x | ||
| 61 | end | ||
| 62 | metadata.trail = table.concat(trl) | ||
| 63 | |||
| 64 | if nil ~= dir.files then | ||
| 65 | for m, x in pairs(dir.files) do | ||
| 66 | local u = string.sub(x, 1 + #pdr) | ||
| 67 | metadata.menu = metadata.menu .. '<p><a href="' .. u .. '.HTML">' .. m .. '</a></p>\n' | ||
| 68 | end | ||
| 69 | end | ||
| 70 | if nil ~= dir.subs then | ||
| 71 | for m, x in pairs(dir.subs) do | ||
| 72 | local u = string.sub(x, 1 + #pdr) | ||
| 73 | metadata.header = metadata.header .. '<a href="' .. u .. '">' .. m .. '</a> ' | ||
| 74 | end | ||
| 75 | end | ||
| 76 | end | ||
| 77 | |||
| 28 | metadata.body = lcmark.apply_template(bod, metadata) | 78 | metadata.body = lcmark.apply_template(bod, metadata) |
| 29 | 79 | ||
| 30 | local tm = '' | 80 | local tm = '' |
| 31 | if nil ~= templateFile then | 81 | if nil ~= templateFile then |
| 32 | local h = io.open(templateFile, 'r') | 82 | local h = io.open(templateFile, 'r') |
| 33 | if nil ~= h then | 83 | if nil ~= h then |
| 34 | tm = tm .. h:read('*a') | 84 | tm = tm .. h:read('*a') |
| 35 | h:close() | 85 | h:close() |
| @@ -60,82 +110,64 @@ local createHTML = function(cm, file) | |||
| 60 | end | 110 | end |
| 61 | 111 | ||
| 62 | 112 | ||
| 113 | |||
| 63 | for l in io.popen('find . -name "*.md" -type f -printf "%P\n"'):lines() do | 114 | for l in io.popen('find . -name "*.md" -type f -printf "%P\n"'):lines() do |
| 64 | local s = {} | 115 | local dir = '' |
| 65 | local f = '' | 116 | local files, subs = {}, {} |
| 66 | local c = 1 | 117 | local c, parent = 1, '' |
| 118 | |||
| 67 | for p in string.gmatch(l, '(%w+)/') do | 119 | for p in string.gmatch(l, '(%w+)/') do |
| 68 | table.insert(s, p) | 120 | if '' == dir then |
| 121 | dir = p | ||
| 122 | if nil ~= dirs[dir] then | ||
| 123 | subs = dirs[dir].subs | ||
| 124 | files = dirs[dir].files | ||
| 125 | end | ||
| 126 | end | ||
| 127 | |||
| 128 | local path = string.sub(l, 1, -1 - #(string.gsub(l, '.*/', ''))) | ||
| 129 | if nil ~= dirs[parent] then | ||
| 130 | if nil == dirs[parent].subs then dirs[parent].subs = {} end | ||
| 131 | dirs[parent].subs[p] = path | ||
| 132 | elseif 1 == c then subs[p] = path | ||
| 133 | else | ||
| 134 | if ('' ~= parent) and (dir == parent) then subs[p] = path end | ||
| 135 | dirs[parent] = {subs = {[p] = path}} | ||
| 136 | end | ||
| 69 | c = c + #p + 1 | 137 | c = c + #p + 1 |
| 138 | parent = p | ||
| 139 | end | ||
| 140 | |||
| 141 | if (1 == c) and (nil ~= dirs[dir]) then | ||
| 142 | subs = dirs[dir].subs | ||
| 143 | files = dirs[dir].files | ||
| 70 | end | 144 | end |
| 145 | |||
| 71 | local base = string.gsub(string.sub(l, c, -1), '%.md$', '') | 146 | local base = string.gsub(string.sub(l, c, -1), '%.md$', '') |
| 72 | table.insert(s, base) | 147 | if nil ~= dirs[parent] then dirs[parent].files[base] = string.sub(l, 1, -4) |
| 73 | 148 | elseif 1 == c then files[base] = string.sub(l, 1, -4) | |
| 74 | -- TODO - should do the same for header.md and footer.md | ||
| 75 | if 'menu' == base then | ||
| 76 | local h = io.open(l, 'r') | ||
| 77 | if nil ~= h then | ||
| 78 | globalData.menuFound = true | ||
| 79 | print('Found ' .. l) | ||
| 80 | globalData.menu = string.gsub(createHTML(h:read('*a')), 'ul>', 'menu>') | ||
| 81 | h:close() | ||
| 82 | end | ||
| 83 | else | 149 | else |
| 84 | if 1 ~= #s then site[l] = s else site[l] = base end | 150 | if ('' ~= parent) and (dir == parent) then files[base] = string.sub(l, 1, -4) end |
| 151 | dirs[parent] = {files = {[base] = string.sub(l, 1, -4)}} | ||
| 85 | end | 152 | end |
| 86 | end | ||
| 87 | 153 | ||
| 88 | for k, v in pairs(site) do | 154 | -- FIXME - still some minor bug somewhere, this fixes that, but causes other problems. Meh, I can live with excess empty subs tables. |
| 89 | if 'string' == type(v) then | 155 | -- if (nil ~= subs) and (0 == #subs) then subs = nil end |
| 90 | if not globalData.menuFound then | 156 | dirs[dir] = {files = files, subs = subs} |
| 91 | local m = '[' .. v .. '](' .. v .. '.HTML)\n' | ||
| 92 | globalData.menu = globalData.menu .. string.gsub(createHTML(m), 'ul>', 'menu>') | ||
| 93 | end | ||
| 94 | elseif not globalData.headerFound then | ||
| 95 | local path = '' | ||
| 96 | for i, w in ipairs(v) do | ||
| 97 | path = path .. w .. '/' | ||
| 98 | end | ||
| 99 | globalData.header = globalData.header .. '<a href="' .. string.sub(path, 1, -2) .. '.HTML">' .. v[1] .. '</a> ' | ||
| 100 | end | ||
| 101 | end | 157 | end |
| 102 | 158 | ||
| 103 | 159 | for k, v in pairs(dirs) do | |
| 104 | local cm, filename = '', '' | 160 | if nil ~= v.files then |
| 105 | 161 | for m, x in pairs(v.files) do | |
| 106 | if 0 == #arg then | 162 | local file = x .. '.md' |
| 107 | for k, v in pairs(site) do | 163 | local h = io.open(file, 'r') |
| 108 | local path = '' | 164 | if nil ~= h then |
| 109 | if 'string' == type(v) then | 165 | createHTML(h:read('*a'), file) |
| 110 | path = v | 166 | h:close() |
| 111 | elseif not globalData.headerFound then | 167 | else |
| 112 | for i, w in ipairs(v) do | 168 | print('oops! No such file ' .. file) |
| 113 | path = path .. w .. '/' | ||
| 114 | end | 169 | end |
| 115 | path = string.sub(path, 1, -2) | ||
| 116 | end | ||
| 117 | path = path .. '.md' | ||
| 118 | 170 | ||
| 119 | cm = '' | ||
| 120 | local h = io.open(path, 'r') | ||
| 121 | if nil ~= h then | ||
| 122 | createHTML(h:read('*a'), path) | ||
| 123 | h:close() | ||
| 124 | else | ||
| 125 | print('oops! No such file ' .. path) | ||
| 126 | end | ||
| 127 | end | ||
| 128 | else | ||
| 129 | for i,a in ipairs(arg) do | ||
| 130 | if filename == '' then filename = a end | ||
| 131 | local h = io.open(a, 'r') | ||
| 132 | if nil ~= h then | ||
| 133 | cm = cm .. h:read('*a') | ||
| 134 | h:close() | ||
| 135 | else | ||
| 136 | print('oops! No such file ' .. a) | ||
| 137 | end | 171 | end |
| 138 | end | 172 | end |
| 139 | if filename == '' then filename = 'test.md' end | ||
| 140 | createHTML(cm, filename) | ||
| 141 | end | 173 | end |
