#!/bin/bash
# source -- where to find the chat cmd files to be made into html
src_dir=~/.zinc/cmd
# destination -- where to put the output
dest_dir=~/edge/cannon
dest_ind=${dest_dir}/index
f_ext=.html
tstamp=$(date "+%B %d, %Y")
for n in ${src_dir}/*
do
if [ ! -f $n ]
then
continue
fi
echo $n
f_name=$(basename $n)
target=${dest_dir}/${f_name}
echo ${target}${f_ext}
head_1=""
awk \
'BEGIN{
FS=":"
}{
therest=substr($0, index($0,$3))
if ( substr($0,1,1) != "#" ){
print therest
}
}' $n | \
awk -v mod_time="${tstamp}" -v f_name="${f_name}" -v head_1="${head_1}" \
-v head_2="${head_2}" \
'{
ucnt=1
cnt=1
url_test=index($0,"http")
if ( url_test == 0 ){
next
}
while (cnt <= NF) {
if (cnt == 1 && $cnt != "#" && NF > 1) {
com=substr($0, 0, (index($0,"http")-1))
if (substr(com, length(com)-2) == " ->") {
com=substr(com, 1, length(com)-3)
}
}
if (substr($cnt,1,4)=="http") {
url[ucnt]=$cnt
ucnt++
}
cnt++
}
if ( 1 in url ){
huge=huge " "com"
\n"
for (i in url) {
tag=url[i]
gsub(/\//, "/ ",tag)
gsub(/\/ \/ /,"//",tag)
gsub(/=/," =",tag)
gsub(/\?/," ?",tag)
gsub(/\+/," +",tag)
gsub(/&/," &",tag)
gsub(/%/," %",tag)
huge=huge" "tag"
\n"
delete url[i]
}
huge=huge"
\n"
com=""
}
} END {
# print ""
print head_1
print head_2
print ""
print " "
print " "
print " the_link_cannon: " f_name ""
print " "
print " "
print " This is the \"" f_name "\" section of the \"link "
print " cannon\"."
print " Some folks asked me to post this collection of links.
"
print " The collection began as my own, but it has since been"
print " greatly augmented by the efforts of the \"regulars\" in"
print " the Yahoo! chat"
print " room \"Linux, FreeBSD, Solaris:1\"
"
print " The collection originated from custom user commands"
print " created for the chat client "
print " curfloo"
print " The conversion script used then was "
print " http://edge-op.org/files/curf-cannon
"
print " The author of the "
print " zinc"
print " chat client provides two handy perl scripts for"
print " converting from curfloo commands format to zinc commands"
print " format, and back.
"
print " Zinc"
print " allows the creation of multiple custom commands files"
print " in ~/.zinc/cmd/ , which makes it easy to create"
print " multiple HTML files from them.
"
print " The script used to produce this page is "
print " zinc-linker."
print " The zinc custom commands are in "
print " zinc-coms.tgz.
"
print " All software mentioned above is provided AS-IS, without"
print " warranty. Use at your own risk.
"
print " Broken links are a side-effect of a dynamic World Wide Web.
"
print "
Last updated: "mod_time"
"
print "
"
print huge
print " "
print ""
}' > ${target}${f_ext}
done
echo ${head_1} > ${dest_ind}
echo ${head_2} >> ${dest_ind}
echo "" >> ${dest_ind}
echo " " >> ${dest_ind}
echo " " >> ${dest_ind}
echo " the_link_cannon: " f_name "" >> ${dest_ind}
echo " " >> ${dest_ind}
echo " " >> ${dest_ind}
for n in ${dest_dir}/*.html
do
b_name=$(basename $n)
echo " "${b_name}"
" >> ${dest_ind}
done
echo " " >> ${dest_ind}
echo "" >> ${dest_ind}
mv ${dest_ind} ${dest_ind}.html