aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--TODO.md5
-rwxr-xr-xnotYetAnotherWiki.lua40
2 files changed, 30 insertions, 15 deletions
diff --git a/TODO.md b/TODO.md
index be57fa2..d6f6039 100644
--- a/TODO.md
+++ b/TODO.md
@@ -7,12 +7,7 @@ Make it perphekd!
7 7
8Fix up linky conversion. DONE, mostly. 8Fix up linky conversion. DONE, mostly.
9 9
10- This is the "page moved" problem, but now it's "page copied" and "page linked", a generic solution might work.
11- Rethink this, I might be going the wrong way.
12- Need to deal with real file name versus title. Also symlink name not matching what it points to. 10- Need to deal with real file name versus title. Also symlink name not matching what it points to.
13- . Hmmm, might it be good policy to have a single canonical context for each page? The "real URL" .md.md thing?
14- . Loop through the manually placed symlinks, adjusting "real URL" as we go.
15- + What to do about mulitple symlinks pointing to the same page? Compare timestamps, most recent wins.
16 11
17Add atom feed for single page. Alas cgit only seems to have ATOM feed on the whole repo, not individual files. 12Add atom feed for single page. Alas cgit only seems to have ATOM feed on the whole repo, not individual files.
18 13
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua
index f4eebe4..c6628fb 100755
--- a/notYetAnotherWiki.lua
+++ b/notYetAnotherWiki.lua
@@ -220,17 +220,38 @@ local Directory = arg[1]
220toSub('') 220toSub('')
221if nil == Directory then Directory = '.' end 221if nil == Directory then Directory = '.' end
222 222
223-- Sort out realURL for symlinked .md.md files. 223--[[ Sort out realURL for symlinked .md.md files.
224 realURL is the generic URL part for this page. By policy it points to whatever is the latest copy / symlink of the original download .md.md.
225 realURL starts out being the path to the downloaded file and friends.
226 If we make a symlink during SuckIt, then that gets updated to point to the place the symlink is in.
227 below we compare timestamps and select the latest version if there's more than one symlink.
228 For the "page symlinked" problem, this should work if realURL is kept updated.
229 For the "page copied" problem, this should work if realURL is kept updated, same as symlinked really, coz that's just another copy.
230 For the "page moved" problem, that'll be the most recent symlink, the old one still has it's symlink pointing to the download .md.md, which gets updated with the current realURL.
231 So when some external old URL points to someplace a page used to be, it's old symlink points to the up to date download .md.md, and we know where to go to find the page now.
232]]
224for l in io.popen('find -L ' .. Directory .. ' -name unsorted -prune -o -name "*.md.md" -xtype l -printf "%P\n"'):lines() do 233for l in io.popen('find -L ' .. Directory .. ' -name unsorted -prune -o -name "*.md.md" -xtype l -printf "%P\n"'):lines() do
225 local metadata = readMdMd(string.sub(l, 1, -4), {}) 234 local metadata = readMdMd(string.sub(l, 1, -4), {})
226-- FIXME - if this already exists, compare the timestamps, most recent wins. 235 if nil == metadata.realURL then
227 metadata.realURL = string.sub(l, 1, -7) 236 metadata.realURL = string.sub(l, 1, -7)
228 local a, e = io.open(l, 'w') 237 else
229 if nil == a then print('Could not open ' .. l .. ' - ' .. e) else 238 if metadata.realURL ~= string.sub(l, 1, -7) then
230 for k, v in pairs(metadata) do 239 -- If this already exists, compare the timestamps, most recent wins.
231 a:write(k .. '=' .. v .. '\n') 240 local time0 = io.popen('ls -l --time-style=+%s "' .. metadata.realURL .. '.md.md" | cut -d \' \' -f 6'):read('l')
241 local time1 = io.popen('ls -l --time-style=+%s "' .. l .. '" | cut -d \' \' -f 6'):read('l')
242 if time0 > time1 then metadata = nil end
243 else metadata = nil end
244 end
245
246 if nil ~= metadata then
247-- DUNNO if this writes to the original file, or overwrites the symlink.
248 local a, e = io.open(l, 'w')
249 if nil == a then print('Could not open ' .. l .. ' - ' .. e) else
250 for k, v in pairs(metadata) do
251 a:write(k .. '=' .. v .. '\n')
252 end
253 a:close()
232 end 254 end
233 a:close()
234 end 255 end
235end 256end
236 257
@@ -253,8 +274,7 @@ end
253 274
254-- Look for copied pages from the other wikis. 275-- Look for copied pages from the other wikis.
255for l in io.popen('find -L ' .. Directory .. ' -name "*.HTM" -type f,l -printf "%P\n"'):lines() do 276for l in io.popen('find -L ' .. Directory .. ' -name "*.HTM" -type f,l -printf "%P\n"'):lines() do
256-- TODO - Only do this if .HTM is newer than .md, or .md doesn't exist. 277-- Only do this if .HTM is newer than .md, or .md doesn't exist.
257
258 local htime = io.popen("date -ur " .. l .. " +%s"):read('l') 278 local htime = io.popen("date -ur " .. l .. " +%s"):read('l')
259 local mtime = io.popen("date -ur " .. string.sub(l, 1, -4) .. "md +%s 2>/dev/null"):read('l') 279 local mtime = io.popen("date -ur " .. string.sub(l, 1, -4) .. "md +%s 2>/dev/null"):read('l')
260 if (nil == mtime) or (htime > mtime) then 280 if (nil == mtime) or (htime > mtime) then