Update
[less_retarded_wiki.git] / make_html.sh
blobc1b14337075129eebb8ffd45338ba64e3a0bb3a8
1 #!/bin/sh
2 # Creates HTML version of the wiki.
4 echo "making HTML"
6 ./make_stats.sh
8 rm -rf html
9 mkdir html
11 cp report.html html
12 cp pimp_my_lrs.html html
13 cp ./*.css ./html/
15 DATE=`date +"%D"`
16 FILECOUNT=`ls *.md | wc -l`
17 FILELIST="wiki_pages"
18 RANDPAGE="random_page"
19 HEADER1="<html><head><link rel=\"stylesheet\" href=\"style.css\"><title> LRS Wiki: "
20 HEADER2="</title></head><body><h1>less_retarded_wiki</h1><span class=\"nav\"><a href=\"main.html\">main page</a>, <a class=\"notdead\" href=\"$FILELIST.html\">file list ($FILECOUNT)</a>, <a class=\"notdead\" href=\"https://git.coom.tech/drummyfish/less_retarded_wiki/archive/master.zip\">source</a>, <a class=\"notdead\" href=\"lrs_wiki.7z\">all in md+txt+html+pdf</a>, <a class=\"notdead\" href=\"https://git.coom.tech/drummyfish/less_retarded_wiki.atom\">commit RSS feed</a>, <a class=\"notdead\" href=\"report.html\">report abuse</a>, <a class=\"notdead\" href=\"wiki_stats.html\">stats</a>, <a class=\"notdead\" href=\"$RANDPAGE.html\">random article</a>, <a class=\"notdead\" id=\"fancylink\" href=\"pimp_my_lrs.html?p=main.html&s=style_fancy.css\">consoomer version</a></span><hr />"
21 FOOTER="<hr /><p> Powered by nothing. All content available under <a class=\"notdead\" href=\"https://creativecommons.org/publicdomain/zero/1.0/\">CC0 1.0</a> (public domain). Send comments and corrections to drummyfish at disroot dot org. </p></body></html>"
23 rm $RANDPAGE.md
25 ls *.md > tmp.txt
26 ls *.md >> tmp.txt
27 ls *.md >> tmp.txt
28 cat tmp.txt | shuf > tmp2.txt
30 printf "# Random Article\n\nPlease kindly click random link.\n\n" >> $RANDPAGE.md
32 while read f; do
33 echo "[*]($f)" >> $RANDPAGE.md
34 done <tmp2.txt
36 rm tmp.txt tmp2.txt
38 printf "# Wiki Files\n\nThis is an autogenerated page listing all pages.\n\n" > $FILELIST.md
40 firstFile=true
42 for f in *.md; do
43 fname=$(echo "$f" | sed "s/\.md//g")
44 if [ "$firstFile" = true ] ; then
45 firstFile=false
46 else
47 printf " -- " >> $FILELIST.md
50 printf "**[$fname]($f)** ($(cat $f | wc -l))" >> $FILELIST.md
51 done
53 for f in *.md; do
54 fname=$(echo "$f" | sed "s/\.md//g")
55 f2="html/${fname}.html"
56 echo "$HEADER1 $fname $HEADER2" > $f2
57 cmark-gfm -e table $f | sed "s/\.md\"/.html\"/g" >> $f2
58 echo $FOOTER >> $f2
59 done
61 # this uses a C program to mark dead links, you can optionally remove this
62 gcc -O3 mark_dead_links.c -o mark_dead_links
63 cd html
64 cp ../mark_dead_links .
66 for f in *.html; do
67 cat $f | ./mark_dead_links > tmp
68 mv tmp $f
69 done
71 rm mark_dead_links
72 cd ..
73 # mark dead links end
75 echo "$HEADER1 redirect $HEADER2<a href="main.html">Go to main page.</a>$FOOTER" >> html/index.html
77 echo "</ul> $FOOTER" >> html/$FILELIST
79 ./make_html_single.sh
81 cp ./lrs_wiki.html html/lrs_wiki_full.html
83 echo "done"