From 07a50a4b3cd2ac4c3ef4ab314ba8bc00043d8219 Mon Sep 17 00:00:00 2001 From: the lemons Date: Sat, 5 Feb 2022 17:57:20 -0600 Subject: improve directives 1. DEADEND defeats the collaborative purpose of the site, and BACKLINK is fairly useless without it. 2. PAGETITLE has been added, and it should be useful in cases where REDIRECT is used heavily. --- about.html | 7 ++----- zzcxz.cgi | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/about.html b/about.html index a96a417..7751e11 100644 --- a/about.html +++ b/about.html @@ -63,13 +63,10 @@ surround text in square brackets to [emphasize it as important].
  • - type #BACKLINK <room> <action> on its own line to cause the room to link back to an already existing room. replace <action> with the text you desire to appear in the link. replace <room> with everything after https://zzcxz.citrons.xyz/g/. for example, to make a link with the text "go back" which links to https://zzcxz.citrons.xyz/g/xxxxx, type the line #BACKLINK xxxxx go back. #BACKLINK cannot add new actions. + type #REDIRECT <room> on its own line to cause the action to bring you to <room> instead of a new room. replace <room> with the five letters at the end of the url of the desired room. for instance, to make the action link to https://zzcxz.citrons.xyz/g/zzcxz, type #REDIRECT zzcxz.
  • - type #REDIRECT <room> to cause the action to bring you to <room> instead of a new room. like with #BACKLINK replace <room> with the five letters at the end of the url of the desired room. - -
  • - type #DEADEND to prevent people from taking additional actions on the page. this is mostly useful in combination with #BACKLINK. + by default, a title at the top of the page contains the action which brings you to the room. this title can be overridden with #PAGETITLE <title>.
  • you can add /raw to the end of the URL of a room to see its markup (on the lines starting with tab) (example). this feature could also potentially be utilized to implement third-party interfaces. diff --git a/zzcxz.cgi b/zzcxz.cgi index 8f8b480..6fbdb47 100755 --- a/zzcxz.cgi +++ b/zzcxz.cgi @@ -144,13 +144,10 @@ local function parse_directive(line, directives) directive = directive and directive:lower() if not directive then return - elseif directive == "backlink" then - local page, action = args:match "^(%w%w%w%w%w)%s+(.+)$" - if not page then return end - directives.backlinks = directives.backlinks or {} - table.insert(directives.backlinks, {page = page, action = action}) - elseif directive == "deadend" then - directives.deadend = true + elseif directive == "pagetitle" then + if args:match "^%s*$" then return end + if utf8.len(args) > 150 then return end + directives.title = args elseif directive == "redirect" then local redirect = args:match "^%s*(%w%w%w%w%w)%s*$" if not redirect then return end @@ -265,7 +262,7 @@ local function new_action(page, action, result) local new = assert(io.open('content/'..new_name, 'w')) action = action:gsub('\n', ' ') - assert(new:write(action..'\n')) + assert(new:write((directives.title or action)..'\n')) for line in (result..'\n'):gmatch "(.-\n)" do assert(new:write('\t' .. line)) end @@ -399,6 +396,8 @@ map["^/g/(%w%w%w%w%w)/act$"] = function(p) local form = parse_qs(io.read "a") form.wyd = form.wyd or "something" form.happens = form.happens or "something" + + local prev, prev_direct = convert_markup(form.happens) return base { title = "do something new", @@ -406,8 +405,10 @@ map["^/g/(%w%w%w%w%w)/act$"] = function(p) page = p, content = convert_markup(page.content), preview = preview_template { - title = html_encode(form.wyd), - content = convert_markup(form.happens), + title = + prev_direct.title and html_encode(prev_direct.title) + or html_encode(form.wyd), + content = prev, }, title = html_encode(form.wyd), editing = html_encode(form.happens), -- cgit v1.2.3