aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--TODO.md1
-rw-r--r--default.template2
-rwxr-xr-xnotYetAnotherWiki.lua26
3 files changed, 24 insertions, 5 deletions
diff --git a/TODO.md b/TODO.md
index 1c87341..dfcacdd 100644
--- a/TODO.md
+++ b/TODO.md
@@ -6,7 +6,6 @@ Make it perphekd!
6 6
7TOC 7TOC
8 8
9- Add anchors, so clicking on them goes to the heading.
10- Lengthy headings need to be tamed. 9- Lengthy headings need to be tamed.
11 10
12Check 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.
diff --git a/default.template b/default.template
index 2357782..a23bf89 100644
--- a/default.template
+++ b/default.template
@@ -85,7 +85,7 @@
85 <div class="boxWrapper"> 85 <div class="boxWrapper">
86 <input type="checkbox" id="modeToggleMenu"/> 86 <input type="checkbox" id="modeToggleMenu"/>
87 <input type="checkbox" id="modeToggleBody"/> 87 <input type="checkbox" id="modeToggleBody"/>
88 <div class="boxLogo"><header><nav> 88 <div class="boxLogo" id="top"><header><nav>
89 <a href="$home$"><img src="$logo$" alt="not (Yet) (Another / A) Wiki."/></a> 89 <a href="$home$"><img src="$logo$" alt="not (Yet) (Another / A) Wiki."/></a>
90 </nav></header></div> 90 </nav></header></div>
91 <div class="boxTools"><header><nav> 91 <div class="boxTools"><header><nav>
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua
index 44f311c..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( [=[{~
@@ -123,8 +126,9 @@ local toFile = function(name, key, value)
123 {"[" {([^]])+} "]{style='color: " {([^}])+} "}" } -> "<span style='color: %3;'>%2</span>" / 126 {"[" {([^]])+} "]{style='color: " {([^}])+} "}" } -> "<span style='color: %3;'>%2</span>" /
124 {"{#"[A-Za-z_]+"}"} -> '' / 127 {"{#"[A-Za-z_]+"}"} -> '' /
125 {"### [[edit](/bin/edit/Main/" {([^%nl])+} } -> '' / 128 {"### [[edit](/bin/edit/Main/" {([^%nl])+} } -> '' /
129 {"#"+ " " {([^%nl])+} } -> header /
126 . 130 .
127 )* ~}]=], { } ):match(body) 131 )* ~}]=], { header = function(a) table.insert(Context.headers, a); return a end } ):match(body)
128 body = result 132 body = result
129-- {"<!--".*"-->"} -> '' / 133-- {"<!--".*"-->"} -> '' /
130-- {"[$]"} -> '$dlr$' / -- Replace $, coz otherwise it confuses things later. 134-- {"[$]"} -> '$dlr$' / -- Replace $, coz otherwise it confuses things later.
@@ -646,7 +650,6 @@ local LunamarkOpts = {
646} 650}
647local Writer = Lunamark.writer.html5.new(LunamarkOpts) 651local Writer = Lunamark.writer.html5.new(LunamarkOpts)
648-- 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.
649local Context = {} -- Coz can't otherwise pass context through to the deeper Lunamark functions I'm overriding.
650local lunaLinky = function(url) -- Fix up the links. 653local lunaLinky = function(url) -- Fix up the links.
651 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
652 -- TODO - This might be covering up a bug elsewhere. 655 -- TODO - This might be covering up a bug elsewhere.
@@ -707,6 +710,10 @@ local lunaLinky = function(url) -- Fix up the links.
707 return url 710 return url
708end 711end
709 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
710local 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.
711function Writer.link(lab, url, tit) 718function Writer.link(lab, url, tit)
712 return OgWriterLink(lab, lunaLinky(url), tit) 719 return OgWriterLink(lab, lunaLinky(url), tit)
@@ -770,7 +777,20 @@ for name, file in pairs(Files) do
770 url = Files[file.path .. '/' .. f].metadata.URL 777 url = Files[file.path .. '/' .. f].metadata.URL
771 end 778 end
772 if nil == title then title = f end 779 if nil == title then title = f end
773 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
774 else 794 else
775 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>'
776 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>'