diff options
| author | dvs1 | 2024-12-16 13:25:52 +1000 |
|---|---|---|
| committer | dvs1 | 2024-12-16 13:25:52 +1000 |
| commit | 9dd962166a1849a31b25767a81cf269f4b99d4a5 (patch) | |
| tree | f75f63a74441a44280921bb02059d518cb0c180a | |
| parent | Again, nope. lol (diff) | |
| download | notYetAnotherWiki-9dd962166a1849a31b25767a81cf269f4b99d4a5.zip notYetAnotherWiki-9dd962166a1849a31b25767a81cf269f4b99d4a5.tar.gz notYetAnotherWiki-9dd962166a1849a31b25767a81cf269f4b99d4a5.tar.bz2 notYetAnotherWiki-9dd962166a1849a31b25767a81cf269f4b99d4a5.tar.xz | |
Commit the test version of the code.
| -rw-r--r-- | README | 5 | ||||
| -rw-r--r-- | TODO.md | 50 | ||||
| -rw-r--r-- | default.template | 69 | ||||
| -rw-r--r-- | menu.template | 40 | ||||
| -rwxr-xr-x | notYetAnotherWiki.lua | 112 |
5 files changed, 272 insertions, 4 deletions
| @@ -1,4 +1 @@ | |||
| 1 | An empty README.md file which should be edited to be a proper about page. | https://sledjhamr.org/cgit/notYetAnotherWiki/atom is the atom feed, since this old version of cgit doesn't support showing them on the page itself. | |
| 2 | |||
| 3 | |||
| 4 | https://sledjhamr.org/cgit/notYetAnotherWiki/atom is the atom feed, since this old version of cgit doesn't support showing hem on the page itself. | ||
| @@ -0,0 +1,50 @@ | |||
| 1 | Try out - | ||
| 2 | |||
| 3 | htmx | ||
| 4 | |||
| 5 | pandoc replacements | ||
| 6 | cmark-gfm | ||
| 7 | |||
| 8 | cgit has Lua | ||
| 9 | |||
| 10 | |||
| 11 | User system - | ||
| 12 | levels - | ||
| 13 | banned | ||
| 14 | reader | ||
| 15 | member | ||
| 16 | moderator | ||
| 17 | editor | ||
| 18 | admin | ||
| 19 | shell | ||
| 20 | root | ||
| 21 | |||
| 22 | Banned people can't do squat, except maybe pester an admin once to start the unbanning process. | ||
| 23 | |||
| 24 | When first registered, accounts are set to reader level. | ||
| 25 | Initial verification by email. | ||
| 26 | Readers can only edit their own profile. | ||
| 27 | |||
| 28 | If an existing member vouches for a reader, they get promoted to member. | ||
| 29 | Some invite system would count is vouching, but need to get secure invite credentials to someone outside the system. | ||
| 30 | |||
| 31 | Members can chat, and create their own sandboxes that might get promoted by editors / moderators to proper content. | ||
| 32 | |||
| 33 | Moderators can move things around, including to a spam/trash place. They can ban readers and members. | ||
| 34 | |||
| 35 | Editors can edit any content, and move things around. They can't edit the site elements itself. | ||
| 36 | So they can edit the site menu and structure of the content, but not the footer? | ||
| 37 | Certainly can't edit any admin stuff. | ||
| 38 | |||
| 39 | Admins are set by other admins. | ||
| 40 | Admins can promote / demote people and content at any time. | ||
| 41 | Admins can edit anything, including web editing of config files, and managing of modules. | ||
| 42 | |||
| 43 | shell level means you have direct access to the files that are the web | ||
| 44 | site, including configuration and modules. Likely this is the person | ||
| 45 | that set the system up in the first place. | ||
| 46 | |||
| 47 | Admin should have access to everything that shell level has, but there's always things need tweaking at some lower level. | ||
| 48 | Built in file browser might do the trick. Would be useful for content creators to to organise the content. Naturally should obey the permisisons. | ||
| 49 | |||
| 50 | root level is whoever controls the server things are running on. They can do anything at all. | ||
diff --git a/default.template b/default.template new file mode 100644 index 0000000..1e08cb6 --- /dev/null +++ b/default.template | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | <!DOCTYPE html> | ||
| 2 | <html> | ||
| 3 | <head> | ||
| 4 | <meta charset="utf-8"> | ||
| 5 | <meta name="generator" contents="lcmark"> | ||
| 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> | ||
| 7 | <title>$pagetitle$</title> | ||
| 8 | <link rel="icon" type="image/png" href="$favicon$" /> | ||
| 9 | <style> | ||
| 10 | html {font-family: sans-serif;} | ||
| 11 | |||
| 12 | body { | ||
| 13 | background-color: black; | ||
| 14 | color: white !important; | ||
| 15 | } | ||
| 16 | |||
| 17 | pre { | ||
| 18 | background-color: #cc00ff; | ||
| 19 | overflow: auto; | ||
| 20 | width: 42%; | ||
| 21 | } | ||
| 22 | |||
| 23 | menu { | ||
| 24 | list-style-type: none; | ||
| 25 | } | ||
| 26 | |||
| 27 | .contentBox { | ||
| 28 | overflow-y: auto; | ||
| 29 | overflow-x: hidden; | ||
| 30 | } | ||
| 31 | </style> | ||
| 32 | </head> | ||
| 33 | <body bgcolor="black" text="white" alink="red" link="yellow" vlink="blue"> | ||
| 34 | <table> | ||
| 35 | <tr> | ||
| 36 | <td><img src="Connie_click-me.gif" alt="alt text" title="Not (Yet) (Another / A) Wiki."/></td> | ||
| 37 | <td>site top menu plus login and register buttons.</td> | ||
| 38 | </tr> | ||
| 39 | <td rowspan=0 style="background-color: rebeccapurple; text-align:left; white-space:nowrap; vertical-align:top"> | ||
| 40 | menu for the current directory | ||
| 41 | $menu$ | ||
| 42 | </td> | ||
| 43 | <td style="background-color: rebeccapurple"> | ||
| 44 | $webtrail$ for this page | ||
| 45 | </td> | ||
| 46 | </tr> | ||
| 47 | <tr> | ||
| 48 | <td> | ||
| 49 | <main class="contentBox"> | ||
| 50 | <div name="contentFrame"> | ||
| 51 | <h1>$pagetitle$</h1> | ||
| 52 | Author: $author$ | ||
| 53 | $body$ | ||
| 54 | </div> | ||
| 55 | </main> | ||
| 56 | </td> | ||
| 57 | </tr> | ||
| 58 | <tr> | ||
| 59 | <td style="background-color: rebeccapurple"> | ||
| 60 | <p>Web site <a href="$feedatom$">atom feed</a>, <a href="$history$">history</a>, and <a href="$sourcecode$">source code</a> Powered by <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/about/">notYetAnotherWiki</a> Version -0.1.</p> | ||
| 61 | </td> | ||
| 62 | </tr> | ||
| 63 | <tr> | ||
| 64 | <td> | ||
| 65 | </td> | ||
| 66 | </tr> | ||
| 67 | </table> | ||
| 68 | </body> | ||
| 69 | </html> | ||
diff --git a/menu.template b/menu.template new file mode 100644 index 0000000..7cf0ba2 --- /dev/null +++ b/menu.template | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | <!DOCTYPE html> | ||
| 2 | <html> | ||
| 3 | <head> | ||
| 4 | <meta charset="utf-8"> | ||
| 5 | <meta name="generator" contents="lcmark"> | ||
| 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> | ||
| 7 | <title>$pagetitle$</title> | ||
| 8 | <link rel="icon" type="image/png" href="$favicon$" /> | ||
| 9 | <style> | ||
| 10 | html { | ||
| 11 | font-family: sans-serif; | ||
| 12 | } | ||
| 13 | |||
| 14 | * { | ||
| 15 | box-sizing: border-box; | ||
| 16 | } | ||
| 17 | |||
| 18 | body { | ||
| 19 | margin: 0; | ||
| 20 | } | ||
| 21 | |||
| 22 | .menuBox { | ||
| 23 | position: fixed; | ||
| 24 | height: 100%; | ||
| 25 | width: 10%; | ||
| 26 | } | ||
| 27 | |||
| 28 | menu { | ||
| 29 | list-style-type: none; | ||
| 30 | padding: 5px; | ||
| 31 | } | ||
| 32 | |||
| 33 | </style> | ||
| 34 | </head> | ||
| 35 | <body bgcolor="black" text="white" alink="red" link="blue" vlink="purple"> | ||
| 36 | <nav class="menuBox"> | ||
| 37 | $body$ | ||
| 38 | </nav> | ||
| 39 | </body> | ||
| 40 | </html> | ||
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua new file mode 100755 index 0000000..1f077b5 --- /dev/null +++ b/notYetAnotherWiki.lua | |||
| @@ -0,0 +1,112 @@ | |||
| 1 | #!/usr/bin/env luajit | ||
| 2 | |||
| 3 | --[[ TODOs | ||
| 4 | Contstruct metadata.webtrail in createHTML from links to index.HTML in the various bits of the path of the input file. | ||
| 5 | |||
| 6 | Construct a default set of menus if menu.md / header.md doesn't exist in each directory. | ||
| 7 | Same for footer.md I guess. | ||
| 8 | |||
| 9 | For such fragments, rename their results to footer.FRAGMENT. metadata.isFragment | ||
| 10 | |||
| 11 | BUG - sub directories get their links screwed with extra path. | ||
| 12 | |||
| 13 | 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. | ||
| 14 | |||
| 15 | Add atom feed and history for single page. Alas cgit only seems to have ATOM feed and commit log on the whole repo, not individual files. | ||
| 16 | ]] | ||
| 17 | |||
| 18 | local lcmark = require("lcmark") | ||
| 19 | |||
| 20 | local createHTML = function(cm, file, menu) | ||
| 21 | -- cm = string.gsub(cm, '._ ', '. ') | ||
| 22 | if nil ~= file then print('About to parse file ' .. file) end | ||
| 23 | local result = '' | ||
| 24 | local body, metadata, err = lcmark.convert(cm, "html", {smart = true, yaml_metadata = true, columns = 0}) | ||
| 25 | |||
| 26 | if nil == body then print('oops! ' .. err) else | ||
| 27 | local bod, err = lcmark.compile_template(body) | ||
| 28 | if nil == bod then print('oops! ' .. err) else | ||
| 29 | local templateFile = metadata.template | ||
| 30 | metadata['_'] = ' ' | ||
| 31 | if nil == templateFile then templateFile = 'default' end | ||
| 32 | templateFile = templateFile .. '.template' | ||
| 33 | if nil == menu then | ||
| 34 | templateFile = nil | ||
| 35 | else | ||
| 36 | metadata.menu = menu | ||
| 37 | end | ||
| 38 | metadata.body = lcmark.apply_template(bod, metadata) | ||
| 39 | |||
| 40 | local tm = '' | ||
| 41 | if nil ~= templateFile then | ||
| 42 | local h = io.open(templateFile, 'r') | ||
| 43 | if nil ~= h then | ||
| 44 | tm = tm .. h:read('*a') | ||
| 45 | h:close() | ||
| 46 | else | ||
| 47 | print('oops! No such file ' .. templateFile) | ||
| 48 | end | ||
| 49 | |||
| 50 | local template, err = lcmark.compile_template(tm) | ||
| 51 | if nil == template then print('oops! ' .. err) else | ||
| 52 | result = lcmark.apply_template(template, metadata) | ||
| 53 | end | ||
| 54 | else | ||
| 55 | result = body | ||
| 56 | end | ||
| 57 | end | ||
| 58 | end | ||
| 59 | |||
| 60 | if ('' ~= result) and (nil ~= file) then | ||
| 61 | local base = string.gsub(file, '%.md$', '') | ||
| 62 | print('Creating file ' .. base .. '.HTML') | ||
| 63 | local a, e = io.open(base .. '.HTML', 'w') | ||
| 64 | if nil == a then print('Could not open ' .. base .. '.HTML - ' .. e) else | ||
| 65 | a:write(result) | ||
| 66 | a:close() | ||
| 67 | end | ||
| 68 | end | ||
| 69 | return result | ||
| 70 | end | ||
| 71 | |||
| 72 | |||
| 73 | local cm = '' | ||
| 74 | local filename = '' | ||
| 75 | local menu = '' | ||
| 76 | |||
| 77 | |||
| 78 | local h = io.open('menu.md', 'r') | ||
| 79 | if nil ~= h then | ||
| 80 | print('Found menu.md') | ||
| 81 | menu = createHTML(h:read('*a')) | ||
| 82 | h:close() | ||
| 83 | menu = string.gsub(menu, 'ul>', 'menu>') | ||
| 84 | end | ||
| 85 | |||
| 86 | |||
| 87 | if 0 ~= #arg then | ||
| 88 | for i,a in ipairs(arg) do | ||
| 89 | if filename == '' then filename = a end | ||
| 90 | local h = io.open(a, 'r') | ||
| 91 | if nil ~= h then | ||
| 92 | cm = cm .. h:read('*a') | ||
| 93 | h:close() | ||
| 94 | else | ||
| 95 | print('oops! No such file ' .. a) | ||
| 96 | end | ||
| 97 | end | ||
| 98 | if filename == '' then filename = 'test.md' end | ||
| 99 | createHTML(cm, filename, menu) | ||
| 100 | else | ||
| 101 | local sticks = io.popen('find . -name "*.md" -type f -printf "%P\n"') | ||
| 102 | for l in sticks:lines() do | ||
| 103 | cm = '' | ||
| 104 | local h = io.open(l, 'r') | ||
| 105 | if nil ~= h then | ||
| 106 | createHTML(h:read('*a'), l, menu) | ||
| 107 | h:close() | ||
| 108 | else | ||
| 109 | print('oops! No such file ' .. l) | ||
| 110 | end | ||
| 111 | end | ||
| 112 | end | ||
