diff options
Diffstat (limited to 'SuckItFos')
-rwxr-xr-x | SuckItFos | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/SuckItFos b/SuckItFos new file mode 100755 index 0000000..4f824be --- /dev/null +++ b/SuckItFos | |||
@@ -0,0 +1,52 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | URL="https://devuan.daffodil.linuxoz.net" | ||
4 | |||
5 | filter=" | ||
6 | -name _default -prune -o \ | ||
7 | -name _empty -prune -o \ | ||
8 | -name System -prune -o \ | ||
9 | -name Trash -prune -o \ | ||
10 | -name TWiki -prune -o \ | ||
11 | " | ||
12 | |||
13 | find ../Foswiki/data ${filter} \ | ||
14 | -name "*.txt" -type f,l -printf "%P\n" | while read line | ||
15 | do | ||
16 | base=`echo "${line}" | cut -d '/' -f 1` | ||
17 | file=`echo "${line}" | cut -d '/' -f 2- | rev | cut -b 5- | rev` | ||
18 | mkdir -p Foswiki/$base | ||
19 | echo "Converting ${URL}/${base}/${file} -> Foswiki/${base}/${file}.md" | ||
20 | # pandoc -f html -t markdown --self-contained ${URL}/${base}/${file} >Foswiki/${base}/${file}.md | ||
21 | # TODO - try curl, to see what is actually downloaded, and maybe not download unchanged pages. curl to .HTM | ||
22 | # 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. | ||
23 | curl --silent --no-progress-meter ${URL}/${base}/${file} -o Foswiki/${base}/${file}.HTM | ||
24 | pandoc -f html -t commonmark_x --self-contained Foswiki//${base}/${file}.HTM >Foswiki/${base}/${file}.md | ||
25 | cp Foswiki/${base}/${file}.md Foswiki/${base}/${file}.md_ORIGINAL | ||
26 | |||
27 | # csplit -ks Foswiki/${base}/${file}.md '%::: foswikiTopic%' '/::: foswikiContentFooter/' | ||
28 | # if [ -f xx00 ]; then | ||
29 | # rm Foswiki/${base}/${file}.md | ||
30 | # mv xx00 Foswiki/${base}/${file}.md | ||
31 | # fi | ||
32 | |||
33 | # Attempt to clean things up, badly. | ||
34 | sed -i -E Foswiki/${base}/${file}.md \ | ||
35 | -e 's/\$/\$dlr\$/g' \ | ||
36 | -e 's/\{#.*\}//g' \ | ||
37 | -e 's/\{\.foswiki.*\}//g' \ | ||
38 | -e 's/\{\.foswiki.*//g' \ | ||
39 | -e 's/\{\.foswikiNewLink rel=“nofollow”\}//g' \ | ||
40 | -e 's/\{\.foswikiNewLink$//g' \ | ||
41 | -e 's/^\.foswiki.*\}//g' \ | ||
42 | -e 's/\{\.pattern.*\}//g' \ | ||
43 | -e 's/\{\.pattern.*//g' \ | ||
44 | -e 's/\{rel="nofollow"\}//g' \ | ||
45 | -e 's/^rel="nofollow"\}//g' \ | ||
46 | -e 's/rel=“nofollow”\}$//g' \ | ||
47 | -e '/^:::/d' | ||
48 | |||
49 | echo "<hr/><p><a href=\"${URL}/${base}/${file}\">Original page</a> where you can edit it.</p>" >> Foswiki/${base}/${file}.md | ||
50 | done | ||
51 | |||
52 | notYetAnotherWiki.lua | ||