less_retarded_wiki/make_html.sh

84 lines
2.7 KiB
Bash
Raw Permalink Normal View History

2021-11-03 21:47:50 +01:00
#!/bin/sh
# Creates HTML version of the wiki.
echo "making HTML"
2023-12-14 23:38:44 +01:00
./make_stats.sh
2021-11-03 21:47:50 +01:00
rm -rf html
mkdir html
2022-09-03 16:42:40 +02:00
cp report.html html
2024-01-29 23:38:34 +01:00
cp pimp_my_lrs.html html
2024-01-30 07:54:47 +01:00
cp ./*.css ./html/
2022-09-03 16:42:40 +02:00
2022-03-25 17:18:00 +01:00
DATE=`date +"%D"`
2023-08-14 20:16:37 +02:00
FILECOUNT=`ls *.md | wc -l`
2024-01-11 23:31:02 +01:00
FILELIST="wiki_pages"
2024-02-15 14:16:28 +01:00
RANDPAGE="random_page"
2024-03-04 23:14:06 +01:00
HEADER1="<html><head><link rel=\"stylesheet\" href=\"style.css\"><title> LRS Wiki: "
2024-08-31 14:44:45 +02:00
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 />"
2024-04-28 20:29:29 +02:00
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>"
2022-03-25 17:18:00 +01:00
2024-02-15 14:16:28 +01:00
rm $RANDPAGE.md
ls *.md > tmp.txt
ls *.md >> tmp.txt
ls *.md >> tmp.txt
cat tmp.txt | shuf > tmp2.txt
printf "# Random Article\n\nPlease kindly click random link.\n\n" >> $RANDPAGE.md
while read f; do
echo "[*]($f)" >> $RANDPAGE.md
done <tmp2.txt
rm tmp.txt tmp2.txt
2024-01-11 23:31:02 +01:00
printf "# Wiki Files\n\nThis is an autogenerated page listing all pages.\n\n" > $FILELIST.md
firstFile=true
2022-03-25 17:18:00 +01:00
2021-11-03 21:47:50 +01:00
for f in *.md; do
2024-08-27 22:53:54 +02:00
fname=$(echo "$f" | sed "s/\.md//g")
if [ "$firstFile" = true ] ; then
firstFile=false
else
printf " -- " >> $FILELIST.md
fi
printf "**[$fname]($f)** ($(cat $f | wc -l))" >> $FILELIST.md
2024-02-06 07:30:19 +01:00
done
2022-03-25 17:18:00 +01:00
2024-02-06 07:30:19 +01:00
for f in *.md; do
2024-08-27 22:53:54 +02:00
fname=$(echo "$f" | sed "s/\.md//g")
f2="html/${fname}.html"
echo "$HEADER1 $fname $HEADER2" > $f2
cmark-gfm -e table $f | sed "s/\.md\"/.html\"/g" >> $f2
echo $FOOTER >> $f2
2021-11-03 21:47:50 +01:00
done
2023-08-14 20:16:37 +02:00
# this uses a C program to mark dead links, you can optionally remove this
gcc -O3 mark_dead_links.c -o mark_dead_links
cd html
cp ../mark_dead_links .
for f in *.html; do
2024-08-27 22:53:54 +02:00
cat $f | ./mark_dead_links > tmp
mv tmp $f
2023-08-14 20:16:37 +02:00
done
rm mark_dead_links
cd ..
# mark dead links end
2024-03-04 23:14:06 +01:00
echo "$HEADER1 redirect $HEADER2<a href="main.html">Go to main page.</a>$FOOTER" >> html/index.html
2022-03-25 17:18:00 +01:00
echo "</ul> $FOOTER" >> html/$FILELIST
2022-06-29 21:10:15 +02:00
./make_html_single.sh
cp ./lrs_wiki.html html/lrs_wiki_full.html
2021-11-03 21:47:50 +01:00
echo "done"