aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.md.md2
-rwxr-xr-xSuckIt18
-rw-r--r--TODO.md25
-rw-r--r--default.template47
-rwxr-xr-xnotYetAnotherWiki.lua98
5 files changed, 134 insertions, 56 deletions
diff --git a/README.md.md b/README.md.md
index bc85e8c..31ea1e7 100644
--- a/README.md.md
+++ b/README.md.md
@@ -1 +1 @@
title=notYetAnotherWiki title=nYAW
diff --git a/SuckIt b/SuckIt
index 8950850..a544f48 100755
--- a/SuckIt
+++ b/SuckIt
@@ -41,6 +41,7 @@ do
41 # Doesn't help with redownloads, coz natch a dynamic site isn't cached. But I can at least comment out the curl command during testing to save time. 41 # Doesn't help with redownloads, coz natch a dynamic site isn't cached. But I can at least comment out the curl command during testing to save time.
42 curl --silent --no-progress-meter ${ogURL}/${base}/${file}?cover=print -o ${ogWiki}/${base}/${file}.HTM 42 curl --silent --no-progress-meter ${ogURL}/${base}/${file}?cover=print -o ${ogWiki}/${base}/${file}.HTM
43 # Attempt to separate user profiles from user content. Doesn't work when people turn their profiles into content. 43 # Attempt to separate user profiles from user content. Doesn't work when people turn their profiles into content.
44 dest=""
44 if [[ "${base}" == "Main" ]]; then 45 if [[ "${base}" == "Main" ]]; then
45 dest="unsorted" 46 dest="unsorted"
46 mkdir -p `dirname users/${file}` 47 mkdir -p `dirname users/${file}`
@@ -48,8 +49,23 @@ do
48 if [ -s users/${file}_fos.SED ]; then 49 if [ -s users/${file}_fos.SED ]; then
49 dest="users" 50 dest="users"
50 fi 51 fi
51 rm users/${file}_fos.SED 52 rm users/${file}_fos.SED >/dev/null 2>&1
52 rm -d `dirname users/${file}` >/dev/null 2>&1 53 rm -d `dirname users/${file}` >/dev/null 2>&1
54 fi
55 # "Devuan" is only two pages that get sorted. "Sandbox" is a mixture of standard examples, stuff that was copied to PmWiki, and other things that should get unsorted.
56 # Skipping anything with "<a href="/Main/UnknownUser">UnknownUser</a></span></div>".
57 if [[ "${base}" == "Sandbox" ]]; then
58 dest="unsorted"
59 mkdir -p `dirname users/${file}`
60 sed -i -E ${ogWiki}/${base}/${file}.HTM -e "s%<a href=\"/Main/UnknownUser\">UnknownUser</a></span></div>%%w users/${file}_fos.SED"
61 if [ -s users/${file}_fos.SED ]; then
62 dest=""
63 fi
64 rm users/${file}_fos.SED >/dev/null 2>&1
65 rm -d `dirname users/${file}` >/dev/null 2>&1
66 fi
67
68 if [[ "${dest}" != "" ]]; then
53 mkdir -p `dirname ${dest}/${file}` 69 mkdir -p `dirname ${dest}/${file}`
54 realURL=${dest}/${file} 70 realURL=${dest}/${file}
55 echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}_fos\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md 71 echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}_fos\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md
diff --git a/TODO.md b/TODO.md
index 673e0dc..dfcacdd 100644
--- a/TODO.md
+++ b/TODO.md
@@ -4,16 +4,9 @@ Make it perphekd!
4 4
5## Do these 5## Do these
6 6
7Automate symlinks.
8
9- any .md.md file should be linked along with it's matching .md file if it's outside of Foswiki/ and PmWiki/.
10
11Other colour shenanigans.
12
13TOC 7TOC
14 8
15- Maybe have it on the left, as the sub menu of the current page's menu item, automatically generated from the $body$ headings. 9- Lengthy headings need to be tamed.
16- Sub headings get sub menus etc.
17 10
18Check the timestamps on the files, only update if source is newer than destination. Meh, it's already 600 times faster than the pandoc version. 11Check the timestamps on the files, only update if source is newer than destination. Meh, it's already 600 times faster than the pandoc version.
19 12
@@ -35,14 +28,28 @@ Deal with complex directory trees.
35- On the gripping hand, this is where we want empty directories to vanish. 28- On the gripping hand, this is where we want empty directories to vanish.
36- SOOOOOOO don't show empty directories, but show their subs that have content, even if that sub is deep, but as per usual stop once we find a sub on that branch. EEEEW branches. 29- SOOOOOOO don't show empty directories, but show their subs that have content, even if that sub is deep, but as per usual stop once we find a sub on that branch. EEEEW branches.
37 30
31Fix up linky conversion. DONE, mostly.
32
33- This is the "page moved" problem, but now it's "page copied" and "page linked", a generic solution might work.
34- Need to deal with real file name versus title. Also symlink name not matching what it points to.
35- . Hmmm, might it be good policy to have a single canonical context for each page? The "real URL" .md.md thing?
36- . Loop through the manually placed symlinks, adjusting "real URL" as we go.
37- + What to do about mulitple symlinks pointing to the same page? Compare timestamps, most recent wins.
38
38FIXTHEM: If there's a single word and period at the beginning of a line, it gets turned into a list, or list item by lunamark at the final Parse stage. 39FIXTHEM: If there's a single word and period at the beginning of a line, it gets turned into a list, or list item by lunamark at the final Parse stage.
39 40
41Automate symlinks.
42
43- any .md.md file should be linked along with it's matching .md file if it's outside of Foswiki/ and PmWiki/.
44
40 45
41## Some ideas 46## Some ideas
42 47
43Mostly from something chomwitt deleted. 48Mostly from something chomwitt deleted.
44 49
45- A toolbar is mentioned, which is what I'm half way through creating with those hamburger / sunglasses icons, they are a bar of tools. 50- A toolbar is mentioned, which is what I'm half way through creating with those hamburger / sunglasses icons, they are a bar of tools.
51- + "everything" and "unsorted" as toolbar icons.
52- + Maybe "users"?
46- Maybe tabs as well as a toolbar, for the list of sub directories. 53- Maybe tabs as well as a toolbar, for the list of sub directories.
47- Syntax highlighting in code blocks. 54- Syntax highlighting in code blocks.
48- Allow default.template files in sub directories. 55- Allow default.template files in sub directories.
@@ -62,6 +69,8 @@ Mostly from something chomwitt deleted.
62 69
63## Try out 70## Try out
64 71
72https://inclusive-components.design/tooltips-toggletips/ has some ideas about the "tooltip" HTML attribute, and what to do about it. A rabbit hole that ends in javascript, but might be useful up to that point.
73
65htmx 74htmx
66 75
67cgit has Lua 76cgit has Lua
diff --git a/default.template b/default.template
index b49b4d6..a23bf89 100644
--- a/default.template
+++ b/default.template
@@ -17,24 +17,23 @@
17 menu {list-style-type: none;} 17 menu {list-style-type: none;}
18 pre { 18 pre {
19 background-image: linear-gradient(to right, $PinkFloyd$, $onefangPurple$); 19 background-image: linear-gradient(to right, $PinkFloyd$, $onefangPurple$);
20 overflow-x: auto; 20 width: fit-content; max-width: 99%; overflow-x: auto;
21 width: 99%; 21 margin: 2px; border: 2px solid grey;
22 margin: 2px;
23 border: 2px solid grey;
24 } 22 }
25 table, td, th {border-collapse: collapse; border: 2px solid grey;} 23 table, td, th {border-collapse: collapse; border: 2px solid grey;}
26 24
27 .toolTip {background: darkcyan;} 25 .toolTip {background: darkcyan; font-size: 1.42em;}
28 26
29 .boxWrapper { 27 .boxWrapper {
30 height: 100%; width: 100%; 28 height: 100%; width: 100%;
31 margin: 0; padding: 0; border: none; 29 margin: 0; padding: 0; border: none;
32 display: grid; 30 display: grid;
33// grid-template-areas: 31// grid-template-areas:
34// "logo trail" 32// "logo tools"
35// "logo head" 33// "logo head"
36// "menu body" 34// "menu body"
37// "history foot"; 35// "history foot"
36// "nyaw .";
38 grid-template-columns: auto 1fr auto auto; 37 grid-template-columns: auto 1fr auto auto;
39 grid-template-rows: auto auto 1fr auto auto; 38 grid-template-rows: auto auto 1fr auto auto;
40// grid-auto-columns: minmax(auto, auto); 39// grid-auto-columns: minmax(auto, auto);
@@ -42,7 +41,7 @@
42 overflow-x: auto; overflow-y: auto; 41 overflow-x: auto; overflow-y: auto;
43 } 42 }
44 .boxLogo {grid-area: logo; grid-column: 1 / 1; grid-row: 1 / 2; height: min-content;} 43 .boxLogo {grid-area: logo; grid-column: 1 / 1; grid-row: 1 / 2; height: min-content;}
45 .boxTrail {grid-area: trail; grid-column: 2 / 4; grid-row: 1 / 1; height: min-content;} 44 .boxTools {grid-area: tools; grid-column: 2 / 4; grid-row: 1 / 1; height: min-content;}
46 .boxHead {grid-area: head; grid-column: 2 / 4; grid-row: 2 / 2; height: min-content; text-align: right;} 45 .boxHead {grid-area: head; grid-column: 2 / 4; grid-row: 2 / 2; height: min-content; text-align: right;}
47 46
48 .boxMenu {grid-area: menu; grid-column: 1 / 1; grid-row: 3 / 3; height: min-content; width: min-content; vertical-align: top; padding: 4px;} 47 .boxMenu {grid-area: menu; grid-column: 1 / 1; grid-row: 3 / 3; height: min-content; width: min-content; vertical-align: top; padding: 4px;}
@@ -57,18 +56,18 @@
57 56
58 .boxHistory {grid-area: history; grid-column: 1 / 1; grid-row: 4 / 4; height: min-content;} 57 .boxHistory {grid-area: history; grid-column: 1 / 1; grid-row: 4 / 4; height: min-content;}
59 .boxFoot {grid-area: foot; grid-column: 2 / 4; grid-row: 4 / 4; height: min-content; text-align: right;} 58 .boxFoot {grid-area: foot; grid-column: 2 / 4; grid-row: 4 / 4; height: min-content; text-align: right;}
60 .boxnyaw {grid-area: foot; grid-column: 1 / 4; grid-row: 5 / 5; height: min-content; text-align: right; font-size: 0.55em;} 59 .boxnyaw {grid-area: nyaw; grid-column: 1 / 4; grid-row: 5 / 5; height: min-content; text-align: right; font-size: 0.55em;}
61 60
62 #modeToggleBody {display: none;} 61 #modeToggleBody {display: none;}
63 #modeToggleMenu {display: none;} 62 #modeToggleMenu {display: none;}
64 #modeBtn {color: white; display: inline-block;} 63 #modeBtn {color: white; display: inline-block;}
65 #modeToggleBody:checked ~ body background-image: linear-gradient($karenPurple$, $onefangPurple$);{}
66 #modeToggleBody:checked ~ pre {background-image: linear-gradient(to right, $onefangPurple$, $PinkFloyd$);}
67 #modeToggleBody:checked ~ .modeBtn {color: black;} 64 #modeToggleBody:checked ~ .modeBtn {color: black;}
65// #modeToggleBody:checked ~ body background-image: linear-gradient($karenPurple$, $onefangPurple$);{}
66// #modeToggleBody:checked ~ pre {background-image: linear-gradient(to right, $onefangPurple$, $PinkFloyd$);}
68 67
69 #modeToggleMenu:checked ~ .boxLogo {display: none;} 68 #modeToggleMenu:checked ~ .boxLogo {display: none;}
70 #modeToggleMenu:checked ~ .boxHead {display: none;} 69 #modeToggleMenu:checked ~ .boxHead {display: none;}
71// #modeToggleMenu:checked ~ .boxTrail {display: none;} 70// #modeToggleMenu:checked ~ .boxTools {display: none;}
72 71
73 #modeToggleMenu:checked ~ .boxMenu {display: none;} 72 #modeToggleMenu:checked ~ .boxMenu {display: none;}
74 #modeToggleBody:checked ~ .boxBody {background: white; color: black;} 73 #modeToggleBody:checked ~ .boxBody {background: white; color: black;}
@@ -86,20 +85,20 @@
86 <div class="boxWrapper"> 85 <div class="boxWrapper">
87 <input type="checkbox" id="modeToggleMenu"/> 86 <input type="checkbox" id="modeToggleMenu"/>
88 <input type="checkbox" id="modeToggleBody"/> 87 <input type="checkbox" id="modeToggleBody"/>
89 <div class="boxLogo"><header><nav> 88 <div class="boxLogo" id="top"><header><nav>
90 <a href="$home$"><img src="$logo$" alt="Not (Yet) (Another / A) Wiki." title="Not (Yet) (Another / A) Wiki."/></a> 89 <a href="$home$"><img src="$logo$" alt="not (Yet) (Another / A) Wiki."/></a>
91 </nav></header></div> 90 </nav></header></div>
92 <div class="boxTrail"><header><nav> 91 <div class="boxTools"><header><nav>
93 <b class="toolTip" title="🍔 hides or shows non content. 92 &nbsp; <b class="toolTip" title="🍔 hides / shows non content, reverse hamburger menu.
94🕶 switches between dark and light themes. 93🕶 switches between dark and light themes.
95🪵 will be for logging in, when I have written that bit. 94🪵 will be for logging in, when I have written that bit.
96🔍 will be the search, when I have written that bit. 95🔍 will be the search, when I have written that bit.
97👣 is a trail of the steps to get here.">❓</b> 96👣 is a trail of the steps to get here.">❓</b>
98 <b class="toolTip"><label for="modeToggleMenu" class='modeBtn'>&#127828;</label></b> 97 &nbsp; <b class="toolTip"><label for="modeToggleMenu" class='modeBtn'>&#127828;</label></b>
99 <b class="toolTip"><label for="modeToggleBody" class='modeBtn'>&#x1F576;</label></b> 98 &nbsp; <b class="toolTip"><label for="modeToggleBody" class='modeBtn'>&#x1F576;</label></b>
100 <b class="toolTip">&#129717;</b> 99 &nbsp; <b class="toolTip">&#129717;</b>
101 <b class="toolTip">&#128269;</b> 100 &nbsp; <b class="toolTip">&#128269;</b>
102 <b> &nbsp; &#x1f463; &nbsp; $trail$ </b> 101 <b> &nbsp; &#x1f463; $trail$ </b>
103 </nav></header></div> 102 </nav></header></div>
104 <div class="boxHead"><header><nav><b>$header$</b> &nbsp; </nav></header></div> 103 <div class="boxHead"><header><nav><b>$header$</b> &nbsp; </nav></header></div>
105 104
@@ -109,7 +108,7 @@
109 <div class="boxHistory"><footer>$history$</footer></div> 108 <div class="boxHistory"><footer>$history$</footer></div>
110 <div class="boxFoot"><footer>$footer$</footer></div> 109 <div class="boxFoot"><footer>$footer$</footer></div>
111 <div class="boxnyaw"><footer> 110 <div class="boxnyaw"><footer>
112 <p>Powered&nbsp;by&nbsp;<a href="https://sledjhamr.org/cgit/notYetAnotherWiki/about/">notYetAnotherWiki</a>&nbsp;v&nbsp;0.0 &nbsp; No cookies or scripts where harmed in the making of this web site. &nbsp; May contain low fat CSS.</p> 111 <p>Powered&nbsp;by&nbsp;<a href="https://sledjhamr.org/notYetAnotherWiki/">notYetAnotherWiki</a>&nbsp;v&nbsp;0.0 &nbsp; No cookies or scripts where harmed in the making of this web site. &nbsp; May contain low fat CSS.</p>
113 </footer></div> 112 </footer></div>
114 </div> 113 </div>
115 </body> 114 </body>
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua
index 8be3850..974fde6 100755
--- a/notYetAnotherWiki.lua
+++ b/notYetAnotherWiki.lua
@@ -31,6 +31,7 @@ local GlobalMetaData = {
31} 31}
32 32
33local Files, Subs, xLinks = {}, {}, {} 33local Files, Subs, xLinks = {}, {}, {}
34local Context = {} -- Coz can't otherwise pass context through to the deeper Lunamark functions I'm overriding.
34 35
35local Template = '' 36local Template = ''
36local h = io.open("default.template", 'r') 37local h = io.open("default.template", 'r')
@@ -87,6 +88,7 @@ local toFile = function(name, key, value)
87 local bits, bit = stringBits(name) 88 local bits, bit = stringBits(name)
88 local path = '' 89 local path = ''
89 Files[name] = {} 90 Files[name] = {}
91 Files[name].headers = {}
90 Files[name].bits = bits 92 Files[name].bits = bits
91 Files[name].bit = bit 93 Files[name].bit = bit
92 for i, d in ipairs(bits) do 94 for i, d in ipairs(bits) do
@@ -107,6 +109,7 @@ local toFile = function(name, key, value)
107 h = io.open(name .. '.md', 'r') 109 h = io.open(name .. '.md', 'r')
108 if nil ~= h then 110 if nil ~= h then
109-- print('Parsing ' .. name .. '.md') 111-- print('Parsing ' .. name .. '.md')
112 Context = Files[name]
110 body = h:read('*a') ; h:close() 113 body = h:read('*a') ; h:close()
111 -- Deal with my typical double spaced sentence endings, and other things. 114 -- Deal with my typical double spaced sentence endings, and other things.
112 local result = RE.compile( [=[{~ 115 local result = RE.compile( [=[{~
@@ -119,10 +122,13 @@ local toFile = function(name, key, value)
119 {":::"} -> '' / 122 {":::"} -> '' /
120 {"-noComment-"} -> ' -- ' / 123 {"-noComment-"} -> ' -- ' /
121 {"| bgcolor=#" {([^ ])+} " " } -> "| <span style='background: #%2;'> bgcolor=#%2 </span> " / -- Deal with debdog's color table. 124 {"| bgcolor=#" {([^ ])+} " " } -> "| <span style='background: #%2;'> bgcolor=#%2 </span> " / -- Deal with debdog's color table.
125 {"[" {([^]])+} ']{style="color: ' {([^}])+} "}" } -> "<span style='color: %3;'>%2</span>" /
126 {"[" {([^]])+} "]{style='color: " {([^}])+} "}" } -> "<span style='color: %3;'>%2</span>" /
122 {"{#"[A-Za-z_]+"}"} -> '' / 127 {"{#"[A-Za-z_]+"}"} -> '' /
123 {"### [[edit](/bin/edit/Main/" {([^%nl])+} } -> '' / 128 {"### [[edit](/bin/edit/Main/" {([^%nl])+} } -> '' /
129 {"#"+ " " {([^%nl])+} } -> header /
124 . 130 .
125 )* ~}]=], { } ):match(body) 131 )* ~}]=], { header = function(a) table.insert(Context.headers, a); return a end } ):match(body)
126 body = result 132 body = result
127-- {"<!--".*"-->"} -> '' / 133-- {"<!--".*"-->"} -> '' /
128-- {"[$]"} -> '$dlr$' / -- Replace $, coz otherwise it confuses things later. 134-- {"[$]"} -> '$dlr$' / -- Replace $, coz otherwise it confuses things later.
@@ -215,7 +221,7 @@ toSub('')
215if nil == Directory then Directory = '.' end 221if nil == Directory then Directory = '.' end
216 222
217-- Sort out realURL for symlinked .md.md files. 223-- Sort out realURL for symlinked .md.md files.
218for l in io.popen('find -L ' .. Directory .. ' -name "*.md.md" -xtype l -printf "%P\n"'):lines() do 224for l in io.popen('find -L ' .. Directory .. ' -name unsorted -prune -o -name "*.md.md" -xtype l -printf "%P\n"'):lines() do
219 local metadata = readMdMd(string.sub(l, 1, -4), {}) 225 local metadata = readMdMd(string.sub(l, 1, -4), {})
220-- FIXME - if this already exists, compare the timestamps, most recent wins. 226-- FIXME - if this already exists, compare the timestamps, most recent wins.
221 metadata.realURL = string.sub(l, 1, -7) 227 metadata.realURL = string.sub(l, 1, -7)
@@ -228,6 +234,24 @@ for l in io.popen('find -L ' .. Directory .. ' -name "*.md.md" -xtype l -printf
228 end 234 end
229end 235end
230 236
237-- Clean up unsorted.
238for l in io.popen('find -L ' .. Directory .. ' -name unsorted -prune -o -name "*.md" -a -not -name "*.md.md" -xtype l -printf "%P\n"'):lines() do
239 local tp = '_fos'
240 local metadata = readMdMd(l, {})
241 if nil ~= metadata then
242 if "PmWiki" == metadata.ogWiki then tp = '_pm' end
243 if nil ~= metadata.ogFile then
244 local unsort = 'unsorted/' .. metadata.ogFile
245 local a, e = io.open(unsort .. tp .. '.md' , 'r')
246 if nil ~= a then
247 a:close()
248 os.execute('rm ' .. unsort .. tp .. '.*')
249 end
250 end
251 end
252end
253
254-- Look for copied pages from the other wikis.
231for l in io.popen('find -L ' .. Directory .. ' -name "*.HTM" -type f,l -printf "%P\n"'):lines() do 255for l in io.popen('find -L ' .. Directory .. ' -name "*.HTM" -type f,l -printf "%P\n"'):lines() do
232-- print('pandoc converting ' .. l .. ' -> ' .. string.sub(l, 1, -4) .. 'md') 256-- print('pandoc converting ' .. l .. ' -> ' .. string.sub(l, 1, -4) .. 'md')
233 -- Open the HTM files and do the initial cleanups, then pandoc them. 257 -- Open the HTM files and do the initial cleanups, then pandoc them.
@@ -626,9 +650,20 @@ local LunamarkOpts = {
626} 650}
627local Writer = Lunamark.writer.html5.new(LunamarkOpts) 651local Writer = Lunamark.writer.html5.new(LunamarkOpts)
628-- Can override the various writer functions, there's something for each of the basic HTML elements. 652-- Can override the various writer functions, there's something for each of the basic HTML elements.
629local Context = {} -- Coz can't otherwise pass context through to the deeper Lunamark functions I'm overriding.
630local lunaLinky = function(url) -- Fix up the links. 653local lunaLinky = function(url) -- Fix up the links.
631 if ('https://wiki.devuan.org/' ~= url) and ('https://fos.wiki.devuan.org/' ~= url) then 654 if ('https://wiki.devuan.org/' ~= url) and ('https://fos.wiki.devuan.org/' ~= url) then
655 -- TODO - This might be covering up a bug elsewhere.
656 if '/Main/' == string.sub(url, 1, 6) then
657 local link = linkFrom(Context.path, 'Foswiki/Main')
658 if '' == link then
659 url = string.sub(url, 7) .. '.HTML'
660 else
661 url = link .. '/' .. string.sub(url, 7) .. '.HTML'
662 end
663 end
664 if '/System/' == string.sub(url, 1, 8) then
665 url = 'https://fos.wiki.devuan.org' .. url
666 end
632 for i, p in ipairs{'https://wiki.devuan.org/?n=', 'https://wiki.devuan.org?n=', 'PmWiki/uploads/', 'Foswiki/pub/', 'https://fos.wiki.devuan.org/'} do 667 for i, p in ipairs{'https://wiki.devuan.org/?n=', 'https://wiki.devuan.org?n=', 'PmWiki/uploads/', 'Foswiki/pub/', 'https://fos.wiki.devuan.org/'} do
633 if p == string.sub(url, 1, #p) then 668 if p == string.sub(url, 1, #p) then
634 local ur = string.sub(url, #p + 1) 669 local ur = string.sub(url, #p + 1)
@@ -646,26 +681,28 @@ local lunaLinky = function(url) -- Fix up the links.
646 end 681 end
647 if (nil ~= md) and (nil ~= md.realURL) then url = md.realURL end 682 if (nil ~= md) and (nil ~= md.realURL) then url = md.realURL end
648 683
649 local xlnk = xLinks[string.gsub(ur, '%..*', '', 1)] 684 if ('https://fos.wiki.devuan.org/bin/' ~= string.sub(url, 1, 32)) and ('https://fos.wiki.devuan.org/System/' ~= string.sub(url, 1, 35)) then
650 if nil == Context.path then 685 local xlnk = xLinks[string.gsub(ur, '%..*', '', 1)]
651 url = string.gsub(ur, '%.', '/', 1) 686 if nil == Context.path then
652 else 687 url = string.gsub(ur, '%.', '/', 1)
653 if nil == xlnk then xlnk = string.gsub(string.gsub(ur, '%..*', '', 1), '/.*', '', 1) end 688 else
654 if '' ~= Context.path then xlnk = linkFrom(Context.path, xlnk) end 689 if nil == xlnk then xlnk = string.gsub(string.gsub(ur, '%..*', '', 1), '/.*', '', 1) end
655 if '/' == string.sub(xlnk, 1, 1) then xlnk = string.sub(xlnk, 2) end 690 if '' ~= Context.path then xlnk = linkFrom(Context.path, xlnk) end
656 if ('' ~= xlnk) and ('/' ~= string.sub(xlnk, -1)) then xlnk = xlnk .. '/' end 691 if '/' == string.sub(xlnk, 1, 1) then xlnk = string.sub(xlnk, 2) end
657 if 'DUNNO/' == xlnk then print('OOPS! page not found - @' .. Context.path .. ' / ' .. Context.bit .. '\t' .. url .. ' -> ' .. xlnk .. ' ' .. string.gsub(ur, '.*%.', '', 1) .. '.HTML') end 692 if ('' ~= xlnk) and ('/' ~= string.sub(xlnk, -1)) then xlnk = xlnk .. '/' end
658 end 693 if 'DUNNO/' == xlnk then print('OOPS! page not found - @' .. Context.path .. ' / ' .. Context.bit .. '\t' .. url .. ' -> ' .. xlnk .. ' ' .. string.gsub(ur, '.*%.', '', 1) .. '.HTML') end
694 end
659-- if (nil ~= md) and (nil ~= md.realURL) then url = md.realURL 695-- if (nil ~= md) and (nil ~= md.realURL) then url = md.realURL
660-- else 696-- else
661 url = xlnk .. string.gsub(ur, '.*%.', '', 1) 697 url = xlnk .. string.gsub(ur, '.*%.', '', 1)
662-- end 698-- end
663 if 'PmWiki/uploads/' == p then 699 if 'PmWiki/uploads/' == p then
664 url = '../' .. p .. string.gsub(ur, '%.', '.', 1) 700 url = '../' .. p .. string.gsub(ur, '%.', '.', 1)
665 elseif 'Foswiki/pub/' == p then 701 elseif 'Foswiki/pub/' == p then
666 url = '../' .. p .. ur 702 url = '../' .. p .. ur
667 else 703 else
668 url = url .. '.HTML' 704 url = url .. '.HTML'
705 end
669 end 706 end
670 end 707 end
671 end 708 end
@@ -673,6 +710,10 @@ local lunaLinky = function(url) -- Fix up the links.
673 return url 710 return url
674end 711end
675 712
713function Writer.header(s, level)
714 local text = Lunamark.util.rope_to_string(s)
715 return '<h' .. level .. ' id="' .. RE.gsub(text, '{[ ]}', '_') .. '">' .. text .. ' <a style="font-size: 0.42em;" href="#top">👆</a></h' .. level .. '>'
716end
676local OgWriterLink = Writer.link -- So we can call the original from within mine, we are just changing the URL. 717local OgWriterLink = Writer.link -- So we can call the original from within mine, we are just changing the URL.
677function Writer.link(lab, url, tit) 718function Writer.link(lab, url, tit)
678 return OgWriterLink(lab, lunaLinky(url), tit) 719 return OgWriterLink(lab, lunaLinky(url), tit)
@@ -700,10 +741,10 @@ for name, file in pairs(Files) do
700 for i, b in ipairs(bits) do 741 for i, b in ipairs(bits) do
701 local p = table.concat(bits, '/', 1, i) 742 local p = table.concat(bits, '/', 1, i)
702 if i < #bits then 743 if i < #bits then
703 metadata.trail = metadata.trail .. '<a href="' .. linkFrom(file.path, p) .. Subs[p].whichPage .. '">' .. b .. '</a> &#x1f463; &nbsp; ' 744 metadata.trail = metadata.trail .. '<a href="' .. linkFrom(file.path, p) .. Subs[p].whichPage .. '">' .. b .. '</a> &nbsp; &#x1f463; '
704 linkFrom(file.path, table.concat(bits, '/', 1, i)) 745 linkFrom(file.path, table.concat(bits, '/', 1, i))
705 else 746 else
706 metadata.trail = metadata.trail .. b .. ' &nbsp; ' 747 metadata.trail = metadata.trail .. ' ' .. b
707 end 748 end
708 end 749 end
709 750
@@ -736,7 +777,20 @@ for name, file in pairs(Files) do
736 url = Files[file.path .. '/' .. f].metadata.URL 777 url = Files[file.path .. '/' .. f].metadata.URL
737 end 778 end
738 if nil == title then title = f end 779 if nil == title then title = f end
739 if bit == f then metadata.menu = metadata.menu .. '<p>' .. title .. '</p>' 780 if bit == f then
781 metadata.menu = metadata.menu .. '<p>' .. title .. '</p>'
782 for j, g in ipairs(file.headers) do
783 local beg, en = RE.find(g, [['{']])
784 if nil ~= beg then
785 g = string.sub(g, 1, beg - 2)
786 end
787 local h = string.sub(RE.gsub(g, '{[#]}', ''), 2)
788 local l = string.len(g) - string.len(h)
789 g = h
790 h = RE.gsub(h, '{[ ]}', '&nbsp;')
791-- FIXME - if it's a linky, strip off the URL part. The Wiki audit has such things.
792 metadata.menu = metadata.menu .. '<p>' .. string.rep('&nbsp;', l) .. '<a style="font-size: 0.80em;" href="#' .. RE.gsub(g, '{[ ]}', '_') .. '">' .. h .. '</a></p>'
793 end
740 else 794 else
741 if nil ~= url then metadata.menu = metadata.menu .. '<p><a href="' .. url .. '">' .. title .. ' &#9757;</a></p>' 795 if nil ~= url then metadata.menu = metadata.menu .. '<p><a href="' .. url .. '">' .. title .. ' &#9757;</a></p>'
742 else metadata.menu = metadata.menu .. '<p><a href="' .. f .. '.HTML">' .. title .. '</a></p>' 796 else metadata.menu = metadata.menu .. '<p><a href="' .. f .. '.HTML">' .. title .. '</a></p>'