diff options
author | dvs1 | 2024-12-28 16:02:18 +1000 |
---|---|---|
committer | dvs1 | 2024-12-28 16:02:18 +1000 |
commit | 2762f24493e5cb6e7b78ff55d9252ed24398c505 (patch) | |
tree | 984ba12511831a62d37f5b5501611a5c31eb548a | |
parent | One more failed attempt to tame HTML scrolling. (diff) | |
download | notYetAnotherWiki-2762f24493e5cb6e7b78ff55d9252ed24398c505.zip notYetAnotherWiki-2762f24493e5cb6e7b78ff55d9252ed24398c505.tar.gz notYetAnotherWiki-2762f24493e5cb6e7b78ff55d9252ed24398c505.tar.bz2 notYetAnotherWiki-2762f24493e5cb6e7b78ff55d9252ed24398c505.tar.xz |
TODO-- Directory level metadata files.
-rw-r--r-- | INSTALL.md | 2 | ||||
-rw-r--r-- | MeTaDaTa.md | 4 | ||||
-rw-r--r-- | README | 6 | ||||
-rw-r--r-- | TODO.md | 4 | ||||
-rwxr-xr-x | notYetAnotherWiki.lua | 103 |
5 files changed, 111 insertions, 8 deletions
@@ -1,9 +1,7 @@ | |||
1 | --- | 1 | --- |
2 | pagetitle: "INSTALL" | 2 | pagetitle: "INSTALL" |
3 | author: onefang | 3 | author: onefang |
4 | feedatom: https://sledjhamr.org/cgit/notYetAnotherWiki/atom | ||
5 | history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/INSTALL.md | 4 | history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/INSTALL.md |
6 | sourcecode: https://sledjhamr.org/cgit/notYetAnotherWiki/ | ||
7 | --- | 5 | --- |
8 | 6 | ||
9 | notYetAnotherWiki 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. | 7 | notYetAnotherWiki 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 | --- | ||
2 | feedatom: https://sledjhamr.org/cgit/notYetAnotherWiki/atom | ||
3 | sourcecode: https://sledjhamr.org/cgit/notYetAnotherWiki/ | ||
4 | --- | ||
@@ -1,9 +1,7 @@ | |||
1 | --- | 1 | --- |
2 | pagetitle: "notYetAnotherWiki" | 2 | pagetitle: "notYetAnotherWiki" |
3 | author: onefang | 3 | author: onefang |
4 | feedatom: https://sledjhamr.org/cgit/notYetAnotherWiki/atom | ||
5 | history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/index.md | 4 | history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/index.md |
6 | sourcecode: https://sledjhamr.org/cgit/notYetAnotherWiki/ | ||
7 | --- | 5 | --- |
8 | 6 | ||
9 | notYetAnotherWiki is not another wiki, at least not yet. It'll be much | 7 | notYetAnotherWiki 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 | |||
70 | variations. Then it produces .HTML files converted from these .md files, | 68 | variations. Then it produces .HTML files converted from these .md files, |
71 | and links them all together into a web site. | 69 | and links them all together into a web site. |
72 | 70 | ||
71 | Any .md file that is just the beginning metadata block doesn't get | ||
72 | rendered into HTML, but is global metadata for this directory and subs, | ||
73 | though the subs can override this with their own metadata.md files. | ||
74 | |||
73 | git is used to store the .md files, and provides edit history. Added on | 75 | git is used to store the .md files, and provides edit history. Added on |
74 | the footer is links to cgit, which is used to store the files in git on | 76 | the footer is links to cgit, which is used to store the files in git on |
75 | your server. This provides acces to the source code, history, and ATOM | 77 | your server. This provides acces to the source code, history, and ATOM |
@@ -1,14 +1,10 @@ | |||
1 | --- | 1 | --- |
2 | pagetitle: "TODO" | 2 | pagetitle: "TODO" |
3 | author: onefang | 3 | author: onefang |
4 | feedatom: https://sledjhamr.org/cgit/notYetAnotherWiki/atom | ||
5 | history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/TODO.md | 4 | history: https://sledjhamr.org/cgit/notYetAnotherWiki/log/TODO.md |
6 | sourcecode: https://sledjhamr.org/cgit/notYetAnotherWiki/ | ||
7 | --- | 5 | --- |
8 | ## Do these | 6 | ## Do these |
9 | 7 | ||
10 | Any .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 | |||
12 | Footer is still wrong. | 8 | Footer is still wrong. |
13 | 9 | ||
14 | Clean up the favicon and logo stuff. | 10 | Clean 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> ' | ||
166 | local p = v.parent | ||
167 | for i = 1, num do | ||
168 | trail = trail .. '<a href="' .. string.rep('../', num - i) .. '">' .. v.bits[i] .. '</a> ' | ||
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 | |||
217 | end | ||
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 |