Wednesday, March 25, 2015

weechat log to html part deux

so. irclog2html thinks my logs are unimportant (heh i read the css). pretty no more.
cat does it.
 !/bin/bash  
 # parse logs to html  
 # remove hashes from names  
 # cat log content to html fie
 # create index from directory list  
   
 title="irc logs"  
 source=~/.weechat/logs  
 working=~/scratch  
 dest=~/public_html/logs  
   
 # copy source  
   
 cd $source  
 cp *.log $working  
   
 # rename  
   
 cd $working  
 rename -f 's/[^A-Za-z0-9._-]//g' *  
   
 # copy contents  
 cd $working  
   
 for i in * ; do  
     touch $i.html  
     echo "<html>" >> $i.html  
     echo "<title>$i</title>" >> $i.html  
     echo "<body>" >> $i.html  
     echo "<a href=index.html>$title</a><br><br>" >> $i.html  
     echo "<h3>$i</h3><pre>" >> $i.html  
     cat $i >> $i.html  
     echo "<br><br><br><br><br><br><a href=index.html>$title</a><br><br>" >> $i.html  
     echo "</pre></body></html>" >> $i.html  
     mv $i.html $dest  
 done  
   
 rm *.log  
   
 # create index  
   
 cd $dest  
   
     echo "<html>" > $dest/index.html  
     echo "<title>$title</title>" >> $dest/index.html  
     echo "<body>" >> $dest/index.html  
     echo "<h3>$title</h3>" >> $dest/index.html  
   
 ls $dest | grep -vE '(index.html|*core*)' | awk -F"." '{print "<a href=" $1 "." $2 "." $3 "." $4 ".html>" $1 "." $2 "." $3 "." $4 "</a><br>"}' \  
 >> $dest/index.html  
   
     echo "</body></html>" >> $dest/index.html  
   

No comments: