aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--INSTALL.md2
-rw-r--r--MeTaDaTa.md4
-rw-r--r--README6
-rw-r--r--TODO.md4
-rwxr-xr-xnotYetAnotherWiki.lua103
5 files changed, 111 insertions, 8 deletions
diff --git a/INSTALL.md b/INSTALL.md
index a4704e9..596f8bf 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -1,9 +1,7 @@
1--- 1---
2pagetitle: "INSTALL" 2pagetitle: "INSTALL"
3author: onefang 3author: onefang
4feedatom: https://sledjhamr.org/cgit/notYetAnotherWiki/atom
5history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/INSTALL.md 4history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/INSTALL.md
6sourcecode: https://sledjhamr.org/cgit/notYetAnotherWiki/
7--- 5---
8 6
9notYetAnotherWiki uses [lcmark](https://github.com/jgm/lcmark) to parse [CommonMark](https://commonmark.org/) into HTML. You can probably install it using luarocks. lua-yaml is the YAML parsing library I test with. 7notYetAnotherWiki uses [lcmark](https://github.com/jgm/lcmark) to parse [CommonMark](https://commonmark.org/) into HTML. You can probably install it using luarocks. lua-yaml is the YAML parsing library I test with.
diff --git a/MeTaDaTa.md b/MeTaDaTa.md
new file mode 100644
index 0000000..ab7b673
--- /dev/null
+++ b/MeTaDaTa.md
@@ -0,0 +1,4 @@
1---
2feedatom: https://sledjhamr.org/cgit/notYetAnotherWiki/atom
3sourcecode: https://sledjhamr.org/cgit/notYetAnotherWiki/
4---
diff --git a/README b/README
index 82f1538..29e3b63 100644
--- a/README
+++ b/README
@@ -1,9 +1,7 @@
1--- 1---
2pagetitle: "notYetAnotherWiki" 2pagetitle: "notYetAnotherWiki"
3author: onefang 3author: onefang
4feedatom: https://sledjhamr.org/cgit/notYetAnotherWiki/atom
5history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/index.md 4history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/index.md
6sourcecode: https://sledjhamr.org/cgit/notYetAnotherWiki/
7--- 5---
8 6
9notYetAnotherWiki is not another wiki, at least not yet. It'll be much 7notYetAnotherWiki is not another wiki, at least not yet. It'll be much
@@ -70,6 +68,10 @@ Currently it'll scan the current directory and subdirectories looking for
70variations. Then it produces .HTML files converted from these .md files, 68variations. Then it produces .HTML files converted from these .md files,
71and links them all together into a web site. 69and links them all together into a web site.
72 70
71Any .md file that is just the beginning metadata block doesn't get
72rendered into HTML, but is global metadata for this directory and subs,
73though the subs can override this with their own metadata.md files.
74
73git is used to store the .md files, and provides edit history. Added on 75git is used to store the .md files, and provides edit history. Added on
74the footer is links to cgit, which is used to store the files in git on 76the footer is links to cgit, which is used to store the files in git on
75your server. This provides acces to the source code, history, and ATOM 77your server. This provides acces to the source code, history, and ATOM
diff --git a/TODO.md b/TODO.md
index 5f03522..f809490 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,14 +1,10 @@
1--- 1---
2pagetitle: "TODO" 2pagetitle: "TODO"
3author: onefang 3author: onefang
4feedatom: https://sledjhamr.org/cgit/notYetAnotherWiki/atom
5history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/TODO.md 4history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/TODO.md
6sourcecode: https://sledjhamr.org/cgit/notYetAnotherWiki/
7--- 5---
8## Do these 6## Do these
9 7
10Any .md file that is just the beginning metadata block doesn't get rendered into HTML, but is global metadata for this directory and subs, though the subs can override this.
11
12Footer is still wrong. 8Footer is still wrong.
13 9
14Clean up the favicon and logo stuff. 10Clean up the favicon and logo stuff.
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua
index be46646..65137b5 100755
--- a/notYetAnotherWiki.lua
+++ b/notYetAnotherWiki.lua
@@ -120,6 +120,109 @@ for k, v in pairs(sites) do
120 local body, metadata, err = lcmark.convert(cm, "html", {smart = true, yaml_metadata = true, columns = 0}) 120 local body, metadata, err = lcmark.convert(cm, "html", {smart = true, yaml_metadata = true, columns = 0})
121 121
122 if nil == body then print('oops! ' .. err) else 122 if nil == body then print('oops! ' .. err) else
123
124
125 if '' == body then
126 -- A simple v.metadata = metadata wont work, you end up with a reference so that changes to metadata get applied to v.metadata.
127 v.metadata = {}
128 for l, y in pairs(metadata) do
129 v.metadata[l] = y
130 end
131 local argh = {}
132 for l, y in ipairs(v.files) do
133 if w.name ~= y.name then table.insert(argh, y) end
134 end
135 v.files = argh
136 print('')
137 else
138
139 local bod, err = lcmark.compile_template(body)
140 if nil == bod then print('oops! ' .. err) else
141 local templateFile = metadata.template
142 if nil == file then
143 templateFile = nil
144 else
145 if nil == templateFile then templateFile = 'default' end
146 templateFile = templateFile .. '.template'
147 for m, x in pairs(globalData) do if nil == metadata[m] then metadata[m] = x else print('metadata already has ' .. m) end end
148 if nil ~= v.metadata then
149 for m, x in pairs(v.metadata) do if nil == metadata[m] then metadata[m] = x else print('metadata already has ' .. m) end end
150 end
151 end
152
153 if nil ~= v.files then
154 for m, x in ipairs(v.files) do
155 metadata.menu = metadata.menu .. x.URL .. '\n'
156 end
157 end
158 if nil ~= v.subs then
159 for m, x in pairs(v.subs) do
160 metadata.header = metadata.header .. x.URL
161 end
162 end
163
164 local num = #(v.bits)
165 local trail = '<a href="' .. string.rep('../', num) .. '">home</a> &nbsp; '
166 local p = v.parent
167 for i = 1, num do
168 trail = trail .. '<a href="' .. string.rep('../', num - i) .. '">' .. v.bits[i] .. '</a> &nbsp; '
169 end
170 trail = trail .. w.name
171 metadata.trail = trail
172
173 metadata.body = lcmark.apply_template(bod, metadata)
174
175 local tm = ''
176 if nil ~= templateFile then
177 local h = io.open(templateFile, 'r')
178 if nil ~= h then
179 tm = tm .. h:read('*a')
180 h:close()
181 else
182 print('oops! No such file ' .. templateFile)
183 end
184
185 local template, err = lcmark.compile_template(tm)
186 if nil == template then print('oops! ' .. err) else
187 result = lcmark.apply_template(template, metadata)
188 end
189 else
190 result = body
191 end
192
193 if ('' ~= result) and (nil ~= file) then
194 local base = path .. w.name .. '.HTML'
195 print(base)
196 local a, e = io.open(base, 'w')
197 if nil == a then print('Could not open ' .. base .. ' - ' .. e) else
198 a:write(result)
199 a:close()
200 end
201 else
202 print('')
203 end
204 end
205
206 end
207 end
208
209 h:close()
210 else
211 print('oops! No such file ' .. file)
212 end
213
214 end
215 end
216
217end
218
219 local h = io.open(file, 'r')
220 if nil ~= h then
221 local cm = h:read('*a')
222 local result = ''
223 local body, metadata, err = lcmark.convert(cm, "html", {smart = true, yaml_metadata = true, columns = 0})
224
225 if nil == body then print('oops! ' .. err) else
123 local bod, err = lcmark.compile_template(body) 226 local bod, err = lcmark.compile_template(body)
124 if nil == bod then print('oops! ' .. err) else 227 if nil == bod then print('oops! ' .. err) else
125 local templateFile = metadata.template 228 local templateFile = metadata.template