ljsdev-ssg

Source code for https://ljs.dev
Log | Files | Refs

generate-article-list.sh (1757B)


      1 #!/bin/sh
      2 
      3 echo "Building openbsd index"
      4 echo "<ul>" >> dst/openbsd.html
      5 
      6 for file in src/openbsd/*.html;
      7   do
      8 	 article=`ls "$file" | sed 's|^src/openbsd/||'`;
      9 	 title=`head -n 1 "$file" |  sed -e 's/<h1>\(.*\)<\/h1>/\1/'`
     10 	 echo "<li><a href=\"openbsd/$article\">$title</a></li>" >> dst/openbsd.html;
     11 done
     12 
     13 echo "</ul>" >> dst/openbsd.html
     14 
     15 echo "Building essays index"
     16 echo "<ul>" >> dst/essays.html
     17 
     18 for file in src/essays/*.html;
     19   do
     20 	 article=`ls "$file" | sed 's|^src/essays/||'`;
     21 	 title=`head -n 1 "$file" |  sed -e 's/<h1>\(.*\)<\/h1>/\1/'`
     22 	 echo "<li><a href=\"essays/$article\">$title</a></li>" >> dst/essays.html;
     23 done
     24 
     25 echo "</ul>" >> dst/essays.html
     26 
     27 echo "Building dev-notes index"
     28 echo "<ul>" >> dst/dev-notes.html
     29 
     30 for file in src/dev-notes/*.html;
     31   do
     32 	 article=`ls "$file" | sed 's|^src/dev-notes/||'`;
     33 	 title=`head -n 1 "$file" |  sed -e 's/<h1>\(.*\)<\/h1>/\1/'`
     34 	 echo "<li><a href=\"dev-notes/$article\">$title</a></li>" >> dst/dev-notes.html;
     35 done
     36 
     37 echo "</ul>" >> dst/dev-notes.html
     38 
     39 echo "Building oldblog index"
     40 echo "<ul>" >> dst/oldblog.html
     41 
     42 for file in src/oldblog/*.html;
     43   do
     44 	 article=`ls "$file" | sed 's|^src/oldblog/||'`;
     45 	 title=`head -n 1 "$file" |  sed -e 's/<h1>\(.*\)<\/h1>/\1/'`
     46 	 echo "<li><a href=\"oldblog/$article\">$title</a></li>" >> dst/oldblog.html;
     47 done
     48 
     49 echo "</ul>" >> dst/oldblog.html
     50 
     51 # TODO: handle <code> blocks, use proper parser or skip files with <code>...
     52 # echo "Minifying HTML..."
     53 # 
     54 # for file in ./{dst/,dst/openbsd/,dst/oldblog/,dst/essays/,dst/dev-notes/}*.html;
     55 # do
     56 # 	cat $file | tr "\n" " " > "$file.concat";
     57 # 	mv "$file.concat" $file;
     58 # done
     59 
     60 echo "Generating browsable source code..."
     61 cd /var/www/ljs.dev/htdocs/src/
     62 stagit /home/git/ljsdev-ssg.git
     63 cp -f log.html index.html
     64 
     65