diff options
-rwxr-xr-x | SuckIt | 67 | ||||
-rw-r--r-- | TODO.md | 4 | ||||
-rw-r--r-- | default.template | 94 | ||||
-rwxr-xr-x | notYetAnotherWiki.lua | 172 | ||||
-rw-r--r-- | testing/index.md | 2 |
5 files changed, 254 insertions, 85 deletions
@@ -13,6 +13,10 @@ mkdir -p unsorted | |||
13 | rm -fr users | 13 | rm -fr users |
14 | mkdir -p users | 14 | mkdir -p users |
15 | 15 | ||
16 | # Copy across things like images that where uploaded. | ||
17 | mkdir -p /opt/nyaw/Foswiki/pub/ | ||
18 | # TODO - Should rsync this instead. | ||
19 | cp -r /opt/Foswiki/pub/Main /opt/nyaw/Foswiki/pub/ | ||
16 | filter=" | 20 | filter=" |
17 | -name _default -prune -o \ | 21 | -name _default -prune -o \ |
18 | -name _empty -prune -o \ | 22 | -name _empty -prune -o \ |
@@ -20,40 +24,46 @@ filter=" | |||
20 | -name Trash -prune -o \ | 24 | -name Trash -prune -o \ |
21 | -name TWiki -prune -o \ | 25 | -name TWiki -prune -o \ |
22 | " | 26 | " |
23 | URL="https://fos.wiki.devuan.org" | 27 | ogURL="https://fos.wiki.devuan.org" |
28 | ogWiki="Foswiki" | ||
24 | time find /opt/Foswiki/data ${filter} \ | 29 | time find /opt/Foswiki/data ${filter} \ |
25 | -name "*.txt" -type f,l -printf "%P\n" | while read line | 30 | -name "*.txt" -type f,l -printf "%P\n" | while read line |
26 | do | 31 | do |
27 | base=`echo "${line}" | cut -d '/' -f 1` | 32 | base=`echo "${line}" | cut -d '/' -f 1` |
28 | file=`echo "${line}" | cut -d '/' -f 2- | rev | cut -b 5- | rev` | 33 | file=`echo "${line}" | cut -d '/' -f 2- | rev | cut -b 5- | rev` |
29 | if [[ ! $file =~ (AdminGroup|AdminUser|AdminUserLeftBar|EditorGroup|GroupTemplate|GroupViewTemplate|NobodyGroup|PatternSkinUserViewTemplate|ProjectContributor|RegistrationAgent|SitePreferences|UnprocessedRegistrations|UnprocessedRegistrationsLog|UserHomepageHeader|UserList|UserListByDateJoined|UserListByLocation|UserList|UserListHeader|WebAtom|WebChanges|WebCreateNewTopic|WebHome|WebIndex|WebLeftBar|WebLeftBarExample|WebNotify|WebPreferences|WebRss|WebSearch|WebSearchAdvanced|WebTopicList|WikiGroups|WikiUsers)$ ]]; then | 34 | if [[ ! ${file} =~ (AdminGroup|AdminUser|AdminUserLeftBar|CommentPluginExamples|EditorGroup|GroupTemplate|GroupViewTemplate|NobodyGroup|PatternSkinUserViewTemplate|ProjectContributor|RegistrationAgent|SitePreferences|UnprocessedRegistrations|UnprocessedRegistrationsLog|UserHomepageHeader|UserList|UserListByDateJoined|UserListByLocation|UserList|UserListHeader|WebAtom|WebChanges|WebCreateNewTopic|WebHome|WebIndex|WebLeftBar|WebLeftBarExample|WebNotify|WebPreferences|WebRss|WebSearch|WebSearchAdvanced|WebTopicList|WikiGroups|WikiUsers)$ ]]; then |
35 | realURL=${ogWiki}/${base}/${file} | ||
30 | time=`date --rfc-3339=seconds -ur /opt/Foswiki/data/${base}/${file}.txt | cut -d '+' -f 1` | 36 | time=`date --rfc-3339=seconds -ur /opt/Foswiki/data/${base}/${file}.txt | cut -d '+' -f 1` |
31 | mkdir -p Foswiki/$base | 37 | mkdir -p ${ogWiki}/${base} |
32 | mkdir -p Foswiki/${base}/`dirname ${file}` | 38 | mkdir -p ${ogWiki}/${base}/`dirname ${file}` |
33 | echo -e "ogWiki=Foswiki\nogURL=${URL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > Foswiki/${base}/${file}.md.md | 39 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md |
34 | echo "downloading ${URL}/${base}/${file}?cover=print" | 40 | echo "downloading ${ogURL}/${base}/${file}?cover=print" |
35 | # 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. |
36 | curl --silent --no-progress-meter ${URL}/${base}/${file}?cover=print -o Foswiki/${base}/${file}.HTM | 42 | curl --silent --no-progress-meter ${ogURL}/${base}/${file}?cover=print -o ${ogWiki}/${base}/${file}.HTM |
37 | # 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. |
38 | if [[ "${base}" == "Main" ]]; then | 44 | if [[ "${base}" == "Main" ]]; then |
39 | dest="unsorted" | 45 | dest="unsorted" |
40 | mkdir -p `dirname users/${file}` | 46 | mkdir -p `dirname users/${file}` |
41 | sed -i -E Foswiki/${base}/${file}.HTM -e "s%<a href=\"/System/UserForm\">UserForm</a>%%w users/${file}_fos.SED" | 47 | sed -i -E ${ogWiki}/${base}/${file}.HTM -e "s%<a href=\"/System/UserForm\">UserForm</a>%%w users/${file}_fos.SED" |
42 | if [ -s users/${file}_fos.SED ]; then | 48 | if [ -s users/${file}_fos.SED ]; then |
43 | dest="users" | 49 | dest="users" |
44 | fi | 50 | fi |
45 | rm users/${file}_fos.SED | 51 | rm users/${file}_fos.SED |
46 | rm -d `dirname users/${file}` >/dev/null 2>&1 | 52 | rm -d `dirname users/${file}` >/dev/null 2>&1 |
47 | mkdir -p `dirname ${dest}/${file}` | 53 | mkdir -p `dirname ${dest}/${file}` |
48 | touch Foswiki/${base}/${file}.md | 54 | realURL=${dest}/${file} |
49 | ln -sfr Foswiki/${base}/${file}.md ${dest}/${file}_fos.md | 55 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}_fos\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md |
50 | ln -sfr Foswiki/${base}/${file}.md.md ${dest}/${file}_fos.md.md | 56 | touch ${ogWiki}/${base}/${file}.md |
51 | rm Foswiki/${base}/${file}.md | 57 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_fos.md |
58 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_fos.md.md | ||
59 | rm ${ogWiki}/${base}/${file}.md | ||
52 | fi | 60 | fi |
53 | fi | 61 | fi |
54 | done | 62 | done |
55 | 63 | ||
56 | 64 | ||
65 | # Copy across things like images that where uploaded. | ||
66 | cp -r /opt/pmwiki/uploads /opt/nyaw/PmWiki/ | ||
57 | filter=" | 67 | filter=" |
58 | -not -name "*~" -a \ | 68 | -not -name "*~" -a \ |
59 | -not -name ".flock" -a \ | 69 | -not -name ".flock" -a \ |
@@ -61,32 +71,37 @@ filter=" | |||
61 | -not -name ".lastmod" -a \ | 71 | -not -name ".lastmod" -a \ |
62 | -not -name ".pageindex" -a \ | 72 | -not -name ".pageindex" -a \ |
63 | " | 73 | " |
64 | URL="https://wiki.devuan.org" | 74 | ogURL="https://wiki.devuan.org" |
75 | ogWiki="PmWiki" | ||
65 | time find /opt/pmwiki/wiki.d ${filter} \ | 76 | time find /opt/pmwiki/wiki.d ${filter} \ |
66 | -name "*.*" -type f,l -printf "%P\n" | while read line | 77 | -name "*.*" -type f,l -printf "%P\n" | while read line |
67 | do | 78 | do |
68 | base=`echo "${line}" | cut -d '.' -f 1` | 79 | base=`echo "${line}" | cut -d '.' -f 1` |
80 | file=`echo "${line}" | cut -d '.' -f 2` | ||
69 | if [[ "${base}" != "Site" ]]; then | 81 | if [[ "${base}" != "Site" ]]; then |
70 | file=`echo "${line}" | cut -d '.' -f 2` | 82 | realURL=${ogWiki}/${base}/${file} |
71 | time=`date --rfc-3339=seconds -ur /opt/pmwiki/wiki.d/${base}.${file} | cut -d '+' -f 1` | 83 | time=`date --rfc-3339=seconds -ur /opt/pmwiki/wiki.d/${base}.${file} | cut -d '+' -f 1` |
72 | mkdir -p PmWiki/$base | 84 | mkdir -p ${ogWiki}/${base} |
73 | echo -e "ogWiki=PmWiki\nogURL=${URL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > PmWiki/${base}/${file}.md.md | 85 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md |
74 | # echo "downloading ${URL}/?n=${base}.${file}?action=markdown" | 86 | # echo "downloading ${ogURL}/?n=${base}.${file}?action=markdown" |
75 | # curl --no-progress-meter ${URL}/?n=${base}.${file}?action=markdown -o PmWiki/${base}/${file}.MARKDOWN | 87 | # curl --no-progress-meter ${ogURL}/?n=${base}.${file}?action=markdown -o ${ogWiki}/${base}/${file}.MARKDOWN |
76 | echo "downloading ${URL}/?n=${base}.${file}?action=print" | 88 | echo "downloading ${ogURL}/?n=${base}.${file}?action=print" |
77 | curl --no-progress-meter ${URL}/?n=${base}.${file}?action=print -o PmWiki/${base}/${file}.HTM | 89 | curl --no-progress-meter ${ogURL}/?n=${base}.${file}?action=print -o ${ogWiki}/${base}/${file}.HTM |
78 | # Seems there's no way to tell user profiles apart from user content. Unless I can find a list of users somewhere. Don't think there is one. | 90 | # Seems there's no way to tell user profiles apart from user content. Unless I can find a list of users somewhere. Don't think there is one. |
79 | if [[ "${base}" == "Profiles" ]]; then | 91 | if [[ "${base}" == "Profiles" ]]; then |
80 | touch PmWiki/${base}/${file}.md | 92 | dest="unsorted" |
81 | ln -sfr PmWiki/${base}/${file}.md unsorted/${file}_pm.md | 93 | realURL=${dest}/${file} |
82 | ln -sfr PmWiki/${base}/${file}.md.md unsorted/${file}_pm.md.md | 94 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}_pm\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md |
83 | rm PmWiki/${base}/${file}.md | 95 | touch ${ogWiki}/${base}/${file}.md |
96 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_pm.md | ||
97 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_pm.md.md | ||
98 | rm ${ogWiki}/${base}/${file}.md | ||
84 | fi | 99 | fi |
85 | 100 | ||
86 | # TODO - groups are PmWiki/Onefang and PmWiki/Tiki | 101 | # TODO - groups are PmWiki/Onefang and PmWiki/Tiki |
87 | 102 | ||
88 | # pandoc -f markdown -t commonmark_x --self-contained PmWiki//${base}/${file}.MD >PmWiki/${base}/${file}.md | 103 | # pandoc -f markdown -t commonmark_x --self-contained ${ogWiki}//${base}/${file}.MD >${ogWiki}/${base}/${file}.md |
89 | # pandoc -f html -t commonmark_x --self-contained PmWiki//${base}/${file}.HTM >PmWiki/${base}/${file}.md | 104 | # pandoc -f html -t commonmark_x --self-contained ${ogWiki}//${base}/${file}.HTM >${ogWiki}/${base}/${file}.md |
90 | fi | 105 | fi |
91 | done | 106 | done |
92 | 107 | ||
@@ -12,6 +12,8 @@ Syntax highlighting in code blocks. | |||
12 | 12 | ||
13 | Other colour shenanigans. | 13 | Other colour shenanigans. |
14 | 14 | ||
15 | - There's a couple more "make this red" scattered around. | ||
16 | |||
15 | Might be useful to automatically convert anything looking like a URL into a linky. | 17 | Might be useful to automatically convert anything looking like a URL into a linky. |
16 | 18 | ||
17 | Check 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 | Check the timestamps on the files, only update if source is newer than destination. Meh, it's already 600 times faster than the pandoc version. |
@@ -40,7 +42,7 @@ Bugs - | |||
40 | 42 | ||
41 | - /users/dunno/Devuan Cluster.HTML A very lengthy and complex document, I'll likely miss something, but chip away at the obvious. Lots of colour shenanigans. | 43 | - /users/dunno/Devuan Cluster.HTML A very lengthy and complex document, I'll likely miss something, but chip away at the obvious. Lots of colour shenanigans. |
42 | - unsorted/JensKorte/DevuanReleases_fos.HTML the header sorting links and colours on the table look tricky to unravel. Especially the extra header row for Daedalus, just to change it's colour. | 44 | - unsorted/JensKorte/DevuanReleases_fos.HTML the header sorting links and colours on the table look tricky to unravel. Especially the extra header row for Daedalus, just to change it's colour. |
43 | - unsorted/Debdog_pm.HTML several tables of links encoded as code blocks, but they linkyness gets dropped, likely by pandoc. | 45 | - unsorted/Debdog_pm.HTML several tables of links encoded as code blocks, but there linkyness gets dropped, likely by pandoc. |
44 | 46 | ||
45 | ## Try out | 47 | ## Try out |
46 | 48 | ||
diff --git a/default.template b/default.template index 9c5765f..f9a2746 100644 --- a/default.template +++ b/default.template | |||
@@ -7,61 +7,97 @@ | |||
7 | <link rel="icon" type="image/png" href="$favicon$" /> | 7 | <link rel="icon" type="image/png" href="$favicon$" /> |
8 | <style> | 8 | <style> |
9 | a:hover {color: red;} | 9 | a:hover {color: red;} |
10 | body {height: 100vh; width: 100vw; font-family: sans-serif; margin: 0; padding: 0; border: none;} | 10 | body { |
11 | height: 100vh; width: 100vw; | ||
12 | margin: 0; padding: 0; border: none; | ||
13 | background-image: linear-gradient($onefangPurple$, $karenPurple$); | ||
14 | color: white; | ||
15 | font-family: sans-serif; | ||
16 | } | ||
11 | menu {list-style-type: none;} | 17 | menu {list-style-type: none;} |
12 | pre { | 18 | pre { |
13 | background-color: $onefangPurple$; | 19 | background-color: $onefangPurple$; |
14 | overflow-x: auto; | 20 | overflow-x: auto; |
15 | width: 84vw; | 21 | width: 99%; |
16 | margin: 2px; | 22 | margin: 2px; |
17 | } | 23 | } |
18 | table, td, th {border-collapse: collapse;border: 2px solid grey;} | 24 | table, td, th {border-collapse: collapse;border: 2px solid grey;} |
19 | 25 | ||
26 | .toolTip { | ||
27 | border: 2px solid fuchsia; | ||
28 | } | ||
20 | 29 | ||
21 | .boxWrapper { | 30 | .boxWrapper { |
22 | height: 100vh; width: 100vw; | 31 | height: 100%; width: 100%; |
23 | background-image: linear-gradient($onefangPurple$, $karenPurple$); | ||
24 | color: white; | ||
25 | display: grid; | 32 | display: grid; |
26 | // grid-template-areas: | 33 | // grid-template-areas: |
27 | // "logo trail" | 34 | // "logo0 trail" |
28 | // "logo head" | 35 | // "logo1 head" |
29 | // "menu body" | 36 | // "menu body" |
30 | // "history foot"; | 37 | // "history foot"; |
31 | grid-template-columns: auto 1fr auto; | 38 | grid-template-columns: auto 1fr auto; |
32 | grid-template-rows: auto auto 1fr auto; | 39 | grid-template-rows: auto auto 1fr auto; |
33 | grid-auto-columns: minmax(auto, auto); | 40 | // grid-auto-columns: minmax(auto, auto); |
34 | grid-auto-rows: minmax(auto, auto); | 41 | // grid-auto-rows: minmax(auto, auto); |
35 | overflow-x: auto; overflow-y: auto; | 42 | overflow-x: auto; overflow-y: auto; |
36 | } | 43 | } |
37 | .boxLogo {grid-area: logo; grid-column: 1 / 1; grid-row: 1 / 2; height: min-content;} | 44 | .boxLogo0 {grid-area: logo0; grid-column: 1 / 3; grid-row: 1 / 1; height: min-content; margin: 0; padding: 0; border: none;} |
38 | .boxTrail {grid-area: trail; grid-column: 2 / 2; grid-row: 1 / 1; height: min-content;} | 45 | .boxLogo1 {grid-area: logo1; grid-column: 1 / 3; grid-row: 2 / 2; height: min-content; margin: 0; padding: 0; border: none;} |
39 | .boxCheck {grid-area: head; grid-column: 2 / 2; grid-row: 2 / 2; height: min-content;} | 46 | .boxHead {grid-area: head; grid-column: 2 / 4; grid-row: 1 / 1; height: min-content; margin: 0; padding: 0; border: none; text-align: right;} |
40 | .boxHead {grid-area: head; grid-column: 2 / 2; grid-row: 2 / 2; height: min-content; text-align: right;} | 47 | .boxTrail {grid-area: trail; grid-column: 2 / 4; grid-row: 2 / 2; height: min-content; margin: 0; padding: 0; border: none;} |
41 | .boxMenu {grid-area: menu; grid-column: 1 / 1; grid-row: 3 / 3; height: min-content; vertical-align: top; padding: 4px;} | 48 | .boxMenu {grid-area: menu; grid-column: 1 / 1; grid-row: 3 / 3; height: min-content; width: min-content; vertical-align: top; padding: 4px;} |
42 | .boxBody {grid-area: body; grid-column: 2 / 2; grid-row: 3 / 3; vertical-align: top; | 49 | .boxBody {grid-area: body; grid-column: 2 / 4; grid-row: 3 / 3; vertical-align: top; |
43 | height: 100%; width: 100%; | 50 | height: 100%; width: 100%; |
44 | background: black; color: white; | 51 | background: black; color: white; |
45 | } | 52 | } |
46 | .boxHistory {grid-area: history; grid-column: 1 / 1; grid-row: 4 / 4; height: min-content;} | 53 | .boxBody a:active {color: red;} |
47 | .boxFoot {grid-area: foot; grid-column: 2 / 2; grid-row: 4 / 4; height: min-content; text-align: right;} | 54 | .boxBody a:link {color: orange;} |
55 | .boxBody a:visited {color: $onefangGreen$;} | ||
56 | .boxBody a:hover {color: red;} | ||
57 | .boxHistory {grid-area: history; grid-column: 1 / 1; grid-row: 4 / 4; height: min-content; margin: 0; padding: 0; border: none;} | ||
58 | .boxFoot {grid-area: foot; grid-column: 2 / 4; grid-row: 4 / 4; height: min-content; margin: 0; padding: 0; border: none; text-align: right;} | ||
48 | 59 | ||
49 | /* Hide the toggle checkbox */ | 60 | #modeToggleBody {display: none;} |
50 | #mode-toggle {display: none;} | 61 | #modeToggleMenu {display: none;} |
51 | #mode-btn {color: white; display: inline-block;} | 62 | #modeBtn {color: white; display: inline-block;} |
52 | #mode-btn:checked {color: black;} | 63 | #modeToggleBody:checked ~ .modeBtn {color: black;} |
53 | #mode-toggle:checked ~ .boxBody {background: white; color: black;} | 64 | #modeToggleBody:checked ~ .boxBody {background: white; color: black;} |
65 | #modeToggleBody:checked ~ .boxBody a:active {color: $devuanDevuanalink$;} | ||
66 | #modeToggleBody:checked ~ .boxBody a:link {color: $devuanDevuanlink$;} | ||
67 | #modeToggleBody:checked ~ .boxBody a:visited {color: $devuanDevuanvlink$;} | ||
68 | #modeToggleBody:checked ~ .boxBody a:hover {color: $devuanDevuanhlink$;} | ||
69 | #modeToggleMenu:checked ~ .boxLogo0 {display: none;} | ||
70 | #modeToggleMenu:checked ~ .boxHead {display: none;} | ||
71 | #modeToggleMenu:checked ~ .boxTrail {display: none;} | ||
72 | #modeToggleMenu:checked ~ .boxMenu {display: none;} | ||
73 | #modeToggleMenu:checked ~ .boxHistory {display: none;} | ||
74 | #modeToggleMenu:checked ~ .boxFoot {display: none;} | ||
54 | </style> | 75 | </style> |
55 | </head> | 76 | </head> |
56 | <body alink="red" link="yellow" vlink="yellowgreen"> | 77 | <body alink="red" link="orange" vlink="$onefangGreen$"> |
57 | <div class="boxWrapper"> | 78 | <div class="boxWrapper"> |
58 | <div class="boxLogo"><header><nav><a href="$home$"><img src="$logo$" alt="Not (Yet) (Another / A) Wiki." title="Not (Yet) (Another / A) Wiki."/></a></nav></header></div> | 79 | <div class="boxLogo1"><header><nav> |
59 | <div class="boxTrail"><header><nav> 👣 $trail$</nav></header></div> | 80 | <b class="toolTip" title="🍔 hides or shows the left menu. |
60 | <div class="boxHead"><header><nav>$header$ login register </nav></header></div> | 81 | 🕶 switches between dark and light themes. |
61 | <input type="checkbox" id="mode-toggle" /><div class="boxBody"><main>$body$<br/></main></div> | 82 | 🪵 will be for logging in, when I have written that bit. |
62 | <div class="boxMenu"><nav>$menu$<label for="mode-toggle" id="mode-btn">🕶</label></nav></div> | 83 | 🔍 will be the search, when I have written that bit. |
84 | 👣 is a trail of the steps to get here.">❓</b> | ||
85 | <b class="toolTip"><label for="modeToggleMenu" class='modeBtn'>🍔</label></b> | ||
86 | <b class="toolTip"><label for="modeToggleBody" class='modeBtn'>🕶</label></b> | ||
87 | <b class="toolTip">🪵</b> | ||
88 | <b class="toolTip">🔍</b> | ||
89 | </nav></header></div> | ||
90 | <input type="checkbox" id="modeToggleMenu"/> <div class="boxMenu"><nav><p><b>$menu$</b></p></nav></div> | ||
91 | <input type="checkbox" id="modeToggleBody"/> <div class="boxBody"><main>$body$<br/></main></div> | ||
92 | <div class="boxLogo0"><header><nav> | ||
93 | <a href="$home$"><img src="$logo$" alt="Not (Yet) (Another / A) Wiki." title="Not (Yet) (Another / A) Wiki."/></a> | ||
94 | </nav></header></div> | ||
95 | <div class="boxHead"><header><nav><b>$header$</b> </nav></header></div> | ||
96 | <div class="boxTrail"><header><nav><b> 👣 $trail$ </b></nav></header></div> | ||
63 | <div class="boxHistory"><footer>$history$</footer></div> | 97 | <div class="boxHistory"><footer>$history$</footer></div> |
64 | <div class="boxFoot"><footer>$footer$</footer></div> | 98 | <div class="boxFoot"><footer><p>$footer$</footer> |
99 | <p><sub>No cookies or scripts where harmed in the making of this web site. May contain low fat CSS.<sub/></p> | ||
100 | </div> | ||
65 | </div> | 101 | </div> |
66 | </body> | 102 | </body> |
67 | </html> | 103 | </html> |
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua index 4207905..29ed9fb 100755 --- a/notYetAnotherWiki.lua +++ b/notYetAnotherWiki.lua | |||
@@ -25,7 +25,7 @@ local GlobalMetaData = { | |||
25 | -- <body> has alink, link, vlink; CSS has active, link, visited, and hover. | 25 | -- <body> has alink, link, vlink; CSS has active, link, visited, and hover. |
26 | devuanDevuanalink = '#03a4ff', devuanDevuanlink = '#0076b6', devuanDevuanvlink = '#6aa4db', devuanDevuanhlink = '#03a4ff', | 26 | devuanDevuanalink = '#03a4ff', devuanDevuanlink = '#0076b6', devuanDevuanvlink = '#6aa4db', devuanDevuanhlink = '#03a4ff', |
27 | devuanSDevuanalink = '#98c3db', devuanSDevuanlink = '#ffffff', devuanSDevuanvlink = '#ffffff', devuanSDevuanhlink = '#98c3db', | 27 | devuanSDevuanalink = '#98c3db', devuanSDevuanlink = '#ffffff', devuanSDevuanvlink = '#ffffff', devuanSDevuanhlink = '#98c3db', |
28 | karenPurple = '#8800ff', onefangPurple = '#cc00ff', | 28 | karenPurple = '#8800ff', onefangPurple = '#cc00ff', onefangGreen = '#42ff00', |
29 | PinkFloyd = '#AA00AA', DeepPurple = '#220022', -- From an ancient site of mine, which went from PinkFloyd to DeepPurple as a background gradient. | 29 | PinkFloyd = '#AA00AA', DeepPurple = '#220022', -- From an ancient site of mine, which went from PinkFloyd to DeepPurple as a background gradient. |
30 | favicon = 'nYAW_icon.png', logo = 'nYAW.png', | 30 | favicon = 'nYAW_icon.png', logo = 'nYAW.png', |
31 | footer = 'Powered by <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/about/">notYetAnotherWiki</a> version 0.0. ', | 31 | footer = 'Powered by <a href="https://sledjhamr.org/cgit/notYetAnotherWiki/about/">notYetAnotherWiki</a> version 0.0. ', |
@@ -155,6 +155,49 @@ end | |||
155 | 155 | ||
156 | 156 | ||
157 | 157 | ||
158 | local readMdMd = function(name, metadata) | ||
159 | local h1 = io.open(name .. '.md') | ||
160 | if nil == h1 then | ||
161 | -- print('Could not open ' .. name .. '.md') | ||
162 | return {} | ||
163 | else | ||
164 | for l in h1:lines() do | ||
165 | for k, v in string.gmatch(l, "(%w+)%s*=%s*(.+)") do | ||
166 | if nil == v then | ||
167 | print(name .. ' ' .. k) | ||
168 | else | ||
169 | metadata[k] = v | ||
170 | end | ||
171 | end | ||
172 | end | ||
173 | end | ||
174 | return metadata | ||
175 | end | ||
176 | |||
177 | |||
178 | |||
179 | local commonLinky = function(l, body, u, url, beg, en, beg0, en0, bump) | ||
180 | if nil == url then | ||
181 | -- print('OOPS! unknown linky - @' .. l .. '\t\t\t' .. string.sub(body, beg - 9, en) .. ' ' .. string.sub(body, en + 1, en0)) | ||
182 | else | ||
183 | local md = readMdMd(url, {}) | ||
184 | -- if nil ~= md then | ||
185 | if nil ~= md.realURL then url = md.realURL end | ||
186 | -- end | ||
187 | body = string.sub(body, 1, beg - bump) .. url .. string.sub(body, en0 + 1) | ||
188 | here = here + string.len(url) | ||
189 | end | ||
190 | if 1 == bump then | ||
191 | here = here + 1 | ||
192 | beg, en = RE.find(body, [['https://fos.wiki.devuan.org/']], here) | ||
193 | else | ||
194 | beg, en = RE.find(body, [["'https://wiki.devuan.org/"]], here) | ||
195 | end | ||
196 | return beg, en, body, here | ||
197 | end | ||
198 | |||
199 | |||
200 | |||
158 | --------------------------------------------------------------------------------- | 201 | --------------------------------------------------------------------------------- |
159 | -- Actually start doing things. | 202 | -- Actually start doing things. |
160 | 203 | ||
@@ -166,12 +209,25 @@ else | |||
166 | print("Can't open everything.md for writing.") | 209 | print("Can't open everything.md for writing.") |
167 | end | 210 | end |
168 | 211 | ||
169 | |||
170 | -- Scan the subdirectories looking for our files. | 212 | -- Scan the subdirectories looking for our files. |
171 | local Directory = arg[1] | 213 | local Directory = arg[1] |
172 | toSub('') | 214 | toSub('') |
173 | if nil == Directory then Directory = '.' end | 215 | if nil == Directory then Directory = '.' end |
174 | 216 | ||
217 | -- Sort out realURL for symlinked .md.md files. | ||
218 | for l in io.popen('find -L ' .. Directory .. ' -name "*.md.md" -xtype l -printf "%P\n"'):lines() do | ||
219 | local metadata = readMdMd(string.sub(l, 1, -4), {}) | ||
220 | -- FIXME - if this already exists, compare the timestamps, most recent wins. | ||
221 | metadata.realURL = string.sub(l, 1, -7) | ||
222 | local a, e = io.open(l, 'w') | ||
223 | if nil == a then print('Could not open ' .. l .. ' - ' .. e) else | ||
224 | for k, v in pairs(metadata) do | ||
225 | a:write(k .. '=' .. v .. '\n') | ||
226 | end | ||
227 | a:close() | ||
228 | end | ||
229 | end | ||
230 | |||
175 | for l in io.popen('find -L ' .. Directory .. ' -name "*.HTM" -type f,l -printf "%P\n"'):lines() do | 231 | for l in io.popen('find -L ' .. Directory .. ' -name "*.HTM" -type f,l -printf "%P\n"'):lines() do |
176 | -- print('pandoc converting ' .. l .. ' -> ' .. string.sub(l, 1, -4) .. 'md') | 232 | -- print('pandoc converting ' .. l .. ' -> ' .. string.sub(l, 1, -4) .. 'md') |
177 | -- Open the HTM files and do the initial cleanups, then pandoc them. | 233 | -- Open the HTM files and do the initial cleanups, then pandoc them. |
@@ -203,11 +259,37 @@ for l in io.popen('find -L ' .. Directory .. ' -name "*.HTM" -type f,l -printf " | |||
203 | {'rel="nofollow"'} -> blank / {"rel='nofollow'"} -> blank / | 259 | {'rel="nofollow"'} -> blank / {"rel='nofollow'"} -> blank / |
204 | {"target='_blank'"} -> blank / | 260 | {"target='_blank'"} -> blank / |
205 | {"</div>" ([%nl])* } -> blank / | 261 | {"</div>" ([%nl])* } -> blank / |
206 | {'style="' ([^"])+ '"'} -> '' / {"style='" ([^'])+ "'"} -> '' / | 262 | -- {'style="' ([^"])+ '"'} -> blank / {"style='" ([^'])+ "'"} -> blank / |
207 | . | 263 | . |
208 | )* ~}]], { blank = function(a) return '' end } ):match(body) | 264 | )* ~}]], { blank = function(a) return '' end } ):match(body) |
209 | body = result | 265 | body = result |
210 | -- body = RE.gsub(body, [=[{"<!-- ".*"-->"}]=], '') -- FIXME | 266 | -- body = RE.gsub(body, [=[{"<!-- ".*"-->"}]=], '') -- FIXME |
267 | local here = 1 | ||
268 | beg, en = RE.find(body, [['https://fos.wiki.devuan.org/']], here) | ||
269 | while nil ~= beg do | ||
270 | here = beg + 1 | ||
271 | local beg0, en0 | ||
272 | local url = nil | ||
273 | if '"' == string.sub(body, beg - 1, beg - 1) then | ||
274 | beg0, en0 = RE.find(body, [['"']], en) | ||
275 | url = string.sub(body, en + 1, en0 - 1) | ||
276 | end | ||
277 | if "'" == string.sub(body, beg - 1, beg - 1) then | ||
278 | beg0, en0 = RE.find(body, [["'"]], en) | ||
279 | url = string.sub(body, en + 1, en0) | ||
280 | end | ||
281 | |||
282 | if nil ~= url then | ||
283 | if ('pub/' == string.sub(url, 1, 4)) then | ||
284 | -- FIXME? - evil hack? | ||
285 | url = 'Foswiki/' .. url | ||
286 | else | ||
287 | url = nil | ||
288 | end | ||
289 | end | ||
290 | beg, en, body, here = commonLinky(l, body, 'https://fos.wiki.devuan.org/', url, beg, en, beg0, en0, 1) | ||
291 | end | ||
292 | |||
211 | writeString(l .. '_NEW', body) | 293 | writeString(l .. '_NEW', body) |
212 | elseif 'PmWiki' == string.sub(l, 1, 6) then | 294 | elseif 'PmWiki' == string.sub(l, 1, 6) then |
213 | local beg, en = RE.find(body, [['<!--PageText-->']]) if nil ~= beg then body = string.sub(body, en + 2) end | 295 | local beg, en = RE.find(body, [['<!--PageText-->']]) if nil ~= beg then body = string.sub(body, en + 2) end |
@@ -230,11 +312,30 @@ for l in io.popen('find -L ' .. Directory .. ' -name "*.HTM" -type f,l -printf " | |||
230 | {"class='wikilink'"} -> blank / | 312 | {"class='wikilink'"} -> blank / |
231 | {'rel="nofollow"'} -> blank / {"rel='nofollow'"} -> blank / | 313 | {'rel="nofollow"'} -> blank / {"rel='nofollow'"} -> blank / |
232 | {"target='_blank'"} -> blank / | 314 | {"target='_blank'"} -> blank / |
233 | {'style="' ([^"])+ '"'} -> '' / {"style='" ([^'])+ "'"} -> '' / | 315 | -- {'style="' ([^"])+ '"'} -> blank / {"style='" ([^'])+ "'"} -> blank / |
234 | {"<span class='hlt " {([a-z])+} "'></span><pre" } -> "<pre class='%2'" / | 316 | {"<span class='hlt " {([a-z])+} "'></span><pre" } -> "<pre class='%2'" / |
235 | . | 317 | . |
236 | )* ~}]], { blank = function(a) return '' end } ):match(body) | 318 | )* ~}]], { blank = function(a) return '' end } ):match(body) |
237 | body = result | 319 | body = result |
320 | here = 1 | ||
321 | beg, en = RE.find(body, [["'https://wiki.devuan.org/"]], here) | ||
322 | while nil ~= beg do | ||
323 | here = beg + 1 | ||
324 | local beg0, en0 = RE.find(body, [["'"]], en) | ||
325 | -- FIXME? - This might be working around a bug elsewhere. | ||
326 | if "'" == string.sub(body, en0, en0) then en0 = en0 - 1 end | ||
327 | local url = string.sub(body, en + 1, en0) | ||
328 | if '?n=' == string.sub(url, 1, 3) then | ||
329 | url = string.sub(url, 4):gsub('[%a]+%.([%a-]+)', '%1_pm.HTML') | ||
330 | elseif ("'" == url) or ('uploads/' == string.sub(url, 1, 8)) then | ||
331 | -- FIXME - evil hack? Yep, evil hack, need to know the depth of the source, which isn't here. | ||
332 | url = 'PmWiki/' .. url | ||
333 | else | ||
334 | url = nil | ||
335 | end | ||
336 | beg, en, body, here = commonLinky(l, body, "'https://wiki.devuan.org/", url, beg, en, beg0, en0, 0) | ||
337 | end | ||
338 | |||
238 | writeString(l .. '_NEW', body) | 339 | writeString(l .. '_NEW', body) |
239 | end | 340 | end |
240 | end | 341 | end |
@@ -278,18 +379,8 @@ for name, file in pairs(Files) do | |||
278 | 379 | ||
279 | if '.md' == string.sub(name, -3, -1) then | 380 | if '.md' == string.sub(name, -3, -1) then |
280 | -- This is a metadata only file, no content, stash the matadata. | 381 | -- This is a metadata only file, no content, stash the matadata. |
281 | local h1 = io.open(name .. '.md') | 382 | |
282 | if nil == h1 then print('Could not open ' .. name .. '.md') else | 383 | metadata = readMdMd(name, metadata) |
283 | for l in h1:lines() do | ||
284 | for k, v in string.gmatch(l, "(%w+)%s*=%s*(.+)") do | ||
285 | if nil == v then | ||
286 | print(name .. ' ' .. k) | ||
287 | else | ||
288 | metadata[k] = v | ||
289 | end | ||
290 | end | ||
291 | end | ||
292 | end | ||
293 | if '.md' == name then toSub(path, 'metadata', metadata) | 384 | if '.md' == name then toSub(path, 'metadata', metadata) |
294 | elseif '/.md' == string.sub(name, -4, -1) then toSub(path, 'metadata', metadata) | 385 | elseif '/.md' == string.sub(name, -4, -1) then toSub(path, 'metadata', metadata) |
295 | -- else toFile(string.sub(name, 1, -4), 'metadata', metadata) | 386 | -- else toFile(string.sub(name, 1, -4), 'metadata', metadata) |
@@ -367,6 +458,7 @@ local linkFrom = function(source, dest) | |||
367 | -- Evil hacks! | 458 | -- Evil hacks! |
368 | if 'Profiles' == dest then dest = 'PmWiki/Profiles' end | 459 | if 'Profiles' == dest then dest = 'PmWiki/Profiles' end |
369 | if 'Onefang' == dest then dest = 'PmWiki/Onefang' end | 460 | if 'Onefang' == dest then dest = 'PmWiki/Onefang' end |
461 | if 'Tiki' == dest then dest = 'PmWiki/Tiki' end | ||
370 | 462 | ||
371 | if source == dest then return '' end | 463 | if source == dest then return '' end |
372 | local depth = 0 | 464 | local depth = 0 |
@@ -532,17 +624,11 @@ local LunamarkOpts = { | |||
532 | escaped_line_breaks=true, -- Pandoc-style escaped hard line breaks | 624 | escaped_line_breaks=true, -- Pandoc-style escaped hard line breaks |
533 | } | 625 | } |
534 | local Writer = Lunamark.writer.html5.new(LunamarkOpts) | 626 | local Writer = Lunamark.writer.html5.new(LunamarkOpts) |
535 | |||
536 | -- Can override the various writer functions, there's something for each of the basic HTML elements. | 627 | -- Can override the various writer functions, there's something for each of the basic HTML elements. |
537 | local Context = {} -- Coz can't otherwise pass context through to the deeper Lunamark functions I'm overriding. | 628 | local Context = {} -- Coz can't otherwise pass context through to the deeper Lunamark functions I'm overriding. |
538 | -- Fix up the links. | 629 | local lunaLinky = function(url) -- Fix up the links. |
539 | local OgWriterLink = Writer.link -- So we can call the original from within mine, we are just changing the URL. | ||
540 | function Writer.link(lab, url, tit) | ||
541 | if ('https://wiki.devuan.org/' ~= url) and ('https://fos.wiki.devuan.org/' ~= url) then | 630 | if ('https://wiki.devuan.org/' ~= url) and ('https://fos.wiki.devuan.org/' ~= url) then |
542 | local label = lab | 631 | 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 |
543 | local uri = url | ||
544 | if 'string' ~= type(lab) then label = type(lab) end | ||
545 | for i, p in ipairs{'https://wiki.devuan.org/?n=', 'https://wiki.devuan.org?n=', 'https://fos.wiki.devuan.org/'} do | ||
546 | if p == string.sub(url, 1, #p) then | 632 | if p == string.sub(url, 1, #p) then |
547 | local ur = string.sub(url, #p + 1) | 633 | local ur = string.sub(url, #p + 1) |
548 | -- TODO - could probably replace some of this mess with RE.gsub() and friends. Meh, it works. | 634 | -- TODO - could probably replace some of this mess with RE.gsub() and friends. Meh, it works. |
@@ -551,22 +637,50 @@ function Writer.link(lab, url, tit) | |||
551 | local u = string.sub(ur, 1, f4 - 1) | 637 | local u = string.sub(ur, 1, f4 - 1) |
552 | ur = u | 638 | ur = u |
553 | end | 639 | end |
640 | local md | ||
641 | if ('fos' == string.sub(p, 9, 11)) or ('Fos' == string.sub(p, 1, 3)) then | ||
642 | md = readMdMd('Foswiki/' .. ur .. '.md', {}) | ||
643 | else | ||
644 | md = readMdMd('PmWiki/' .. string.gsub(ur, '%.', '/', 1) .. '.md', {}) | ||
645 | end | ||
646 | if (nil ~= md) and (nil ~= md.realURL) then url = md.realURL end | ||
647 | |||
648 | local xlnk = xLinks[string.gsub(ur, '%..*', '', 1)] | ||
554 | if nil == Context.path then | 649 | if nil == Context.path then |
555 | url = string.gsub(ur, '%.', '/', 1) | 650 | url = string.gsub(ur, '%.', '/', 1) |
556 | else | 651 | else |
557 | local xlnk = xLinks[string.gsub(ur, '%..*', '', 1)] | 652 | if nil == xlnk then xlnk = string.gsub(string.gsub(ur, '%..*', '', 1), '/.*', '', 1) end |
558 | if nil == xlnk then xlnk = string.gsub(ur, '%..*', '', 1) end | ||
559 | if '' ~= Context.path then xlnk = linkFrom(Context.path, xlnk) end | 653 | if '' ~= Context.path then xlnk = linkFrom(Context.path, xlnk) end |
560 | if '/' == string.sub(xlnk, 1, 1) then xlnk = string.sub(xlnk, 2) end | 654 | if '/' == string.sub(xlnk, 1, 1) then xlnk = string.sub(xlnk, 2) end |
561 | if ('' ~= xlnk) and ('/' ~= string.sub(xlnk, -1)) then xlnk = xlnk .. '/' end | 655 | if ('' ~= xlnk) and ('/' ~= string.sub(xlnk, -1)) then xlnk = xlnk .. '/' end |
562 | if 'DUNNO/' == xlnk then print('OOPS! Page not found - ' .. Context.path .. ' / ' .. Context.bit .. ' ' .. url .. ' -> ' .. xlnk .. ' ' .. string.gsub(ur, '.*%.', '', 1) .. '.HTML') end | 656 | if 'DUNNO/' == xlnk then print('OOPS! page not found - @' .. Context.path .. ' / ' .. Context.bit .. '\t' .. url .. ' -> ' .. xlnk .. ' ' .. string.gsub(ur, '.*%.', '', 1) .. '.HTML') end |
563 | url = xlnk .. string.gsub(ur, '.*%.', '', 1) .. '.HTML' | 657 | end |
658 | -- if (nil ~= md) and (nil ~= md.realURL) then url = md.realURL | ||
659 | -- else | ||
660 | url = xlnk .. string.gsub(ur, '.*%.', '', 1) | ||
661 | -- end | ||
662 | if 'PmWiki/uploads/' == p then | ||
663 | url = '../' .. p .. string.gsub(ur, '%.', '.', 1) | ||
664 | elseif 'Foswiki/pub/' == p then | ||
665 | url = '../' .. p .. ur | ||
666 | else | ||
667 | url = url .. '.HTML' | ||
564 | end | 668 | end |
565 | end | 669 | end |
566 | end | 670 | end |
567 | end | 671 | end |
568 | return OgWriterLink(lab, url, tit) | 672 | return url |
673 | end | ||
674 | |||
675 | local OgWriterLink = Writer.link -- So we can call the original from within mine, we are just changing the URL. | ||
676 | function Writer.link(lab, url, tit) | ||
677 | return OgWriterLink(lab, lunaLinky(url), tit) | ||
569 | end | 678 | end |
679 | local OgWriterImage = Writer.image | ||
680 | function Writer.image(lab, url, tit) | ||
681 | return OgWriterImage(lab, lunaLinky(url), tit) | ||
682 | end | ||
683 | |||
570 | local Parse = Lunamark.reader.markdown.new(Writer, LunamarkOpts) | 684 | local Parse = Lunamark.reader.markdown.new(Writer, LunamarkOpts) |
571 | 685 | ||
572 | 686 | ||
diff --git a/testing/index.md b/testing/index.md index ca62e7f..5129b43 100644 --- a/testing/index.md +++ b/testing/index.md | |||
@@ -34,6 +34,8 @@ Test ~~strike~~ --out--. Needs the extension. | |||
34 | 34 | ||
35 | [untalenz](https://untalenz.rocks/) | 35 | [untalenz](https://untalenz.rocks/) |
36 | 36 | ||
37 | [nope.example.com](http://nope.example.com/) | ||
38 | |||
37 | https://sledjhamr.org/ | 39 | https://sledjhamr.org/ |
38 | 40 | ||
39 | # Lists | 41 | # Lists |