From 9dd962166a1849a31b25767a81cf269f4b99d4a5 Mon Sep 17 00:00:00 2001 From: dvs1 Date: Mon, 16 Dec 2024 13:25:52 +1000 Subject: Commit the test version of the code. --- README | 5 +-- TODO.md | 50 ++++++++++++++++++++++ default.template | 69 +++++++++++++++++++++++++++++++ menu.template | 40 ++++++++++++++++++ notYetAnotherWiki.lua | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 272 insertions(+), 4 deletions(-) create mode 100644 TODO.md create mode 100644 default.template create mode 100644 menu.template create mode 100755 notYetAnotherWiki.lua diff --git a/README b/README index 039cf88..e58061c 100644 --- a/README +++ b/README @@ -1,4 +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 hem on the page itself. +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. diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..8921862 --- /dev/null +++ b/TODO.md @@ -0,0 +1,50 @@ +Try out - + +htmx + +pandoc replacements + cmark-gfm + +cgit has Lua + + +User system - + levels - + banned + reader + member + moderator + editor + admin + shell + root + +Banned people can't do squat, except maybe pester an admin once to start the unbanning process. + +When first registered, accounts are set to reader level. +Initial verification by email. +Readers can only edit their own profile. + +If an existing member vouches for a reader, they get promoted to member. +Some invite system would count is vouching, but need to get secure invite credentials to someone outside the system. + +Members can chat, and create their own sandboxes that might get promoted by editors / moderators to proper content. + +Moderators can move things around, including to a spam/trash place. They can ban readers and members. + +Editors can edit any content, and move things around. They can't edit the site elements itself. +So they can edit the site menu and structure of the content, but not the footer? +Certainly can't edit any admin stuff. + +Admins are set by other admins. +Admins can promote / demote people and content at any time. +Admins can edit anything, including web editing of config files, and managing of modules. + +shell level means you have direct access to the files that are the web +site, including configuration and modules. Likely this is the person +that set the system up in the first place. + +Admin should have access to everything that shell level has, but there's always things need tweaking at some lower level. +Built in file browser might do the trick. Would be useful for content creators to to organise the content. Naturally should obey the permisisons. + +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 @@ + + + + + + + $pagetitle$ + + + + + + + + + + + + + + + + + + + + + +
alt textsite top menu plus login and register buttons.
+ menu for the current directory + $menu$ + + $webtrail$ for this page +
+
+
+

$pagetitle$

+ Author: $author$ + $body$ +
+
+
+

Web site atom feed, history, and source code   Powered by notYetAnotherWiki Version -0.1.

+
+
+ + diff --git a/menu.template b/menu.template new file mode 100644 index 0000000..7cf0ba2 --- /dev/null +++ b/menu.template @@ -0,0 +1,40 @@ + + + + + + + $pagetitle$ + + + + + + + diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua new file mode 100755 index 0000000..1f077b5 --- /dev/null +++ b/notYetAnotherWiki.lua @@ -0,0 +1,112 @@ +#!/usr/bin/env luajit + +--[[ TODOs +Contstruct metadata.webtrail in createHTML from links to index.HTML in the various bits of the path of the input file. + +Construct a default set of menus if menu.md / header.md doesn't exist in each directory. +Same for footer.md I guess. + +For such fragments, rename their results to footer.FRAGMENT. metadata.isFragment + +BUG - sub directories get their links screwed with extra path. + +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 and history for single page. Alas cgit only seems to have ATOM feed and commit log on the whole repo, not individual files. +]] + +local lcmark = require("lcmark") + +local createHTML = function(cm, file, menu) +-- cm = string.gsub(cm, '._ ', '.  ') + if nil ~= file then print('About to parse file ' .. file) end + local result = '' + local body, metadata, err = lcmark.convert(cm, "html", {smart = true, yaml_metadata = true, columns = 0}) + + if nil == body then print('oops! ' .. err) else + local bod, err = lcmark.compile_template(body) + if nil == bod then print('oops! ' .. err) else + local templateFile = metadata.template + metadata['_'] = ' ' + if nil == templateFile then templateFile = 'default' end + templateFile = templateFile .. '.template' + if nil == menu then + templateFile = nil + else + metadata.menu = menu + end + metadata.body = lcmark.apply_template(bod, metadata) + + local tm = '' + if nil ~= templateFile then + local h = io.open(templateFile, 'r') + if nil ~= h then + tm = tm .. h:read('*a') + h:close() + else + print('oops! No such file ' .. templateFile) + end + + local template, err = lcmark.compile_template(tm) + if nil == template then print('oops! ' .. err) else + result = lcmark.apply_template(template, metadata) + end + else + result = body + end + end + end + + if ('' ~= result) and (nil ~= file) then + local base = string.gsub(file, '%.md$', '') + print('Creating file ' .. base .. '.HTML') + local a, e = io.open(base .. '.HTML', 'w') + if nil == a then print('Could not open ' .. base .. '.HTML - ' .. e) else + a:write(result) + a:close() + end + end + return result +end + + +local cm = '' +local filename = '' +local menu = '' + + +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>') +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 nil ~= h then + cm = cm .. h:read('*a') + h:close() + else + print('oops! No such file ' .. a) + 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') + if nil ~= h then + createHTML(h:read('*a'), l, menu) + h:close() + else + print('oops! No such file ' .. l) + end + end +end -- cgit v1.1