#!/bin/bash
# destination -- where and what to write output to
targetfile=~/.zinc/cannon.html
# zinc cmd to curfloo commands
zinc_coms=~/.zinc/cmd
zinc_conv=~/src/zinc/zinc-1.0-preview14/scripts/zinc2floo.pl
zinc_curf=~/.zinc/commands
cat ${zinc_coms} | ${zinc_conv} > ${zinc_curf}
# curfloo commands to cannon.html
curf_coms=${zinc_curf}
# format i use in curfloo commands
# command:description -> url
if [ ! -f ${curf_coms} ]
then
echo "${curf_coms} is not a file"
exit
fi
tstamp=$(date "+%B %d, %Y")
sed 's/^\([[:alnum:]]*\-*\.*[[:alnum:]]*+*\)\(:*\)/\1 \2 /g' ${curf_coms} | \
# fields:
# where NF > 1,
# $1 is either # or the command used in curfloo
# $2 is either the section head (if $1 was #) or ':'
# $n may be a url, where 2 < n <= NF or
# $n may be a description of a url or
# $n may be a comment
awk -v modtime="${tstamp}" 'BEGIN{
hcnt=1
}
{
pretag=""
postag=""
head=""
ucnt=1
cnt=1
while (cnt <= NF) {
if (cnt == 1 && $cnt == "#" && NF > 1) {
pretag="
"
head=""$2""
postag="
"
hd[hcnt]=$2
hcnt++
}
if (cnt == 1 && $cnt != "#" && NF > 1) {
head=""
com=substr($0, index($0,$3), (index($0,"http")-1)-index($0,$3))
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 || pretag=="" ){
huge=huge " "pretag head postag"\n"
huge=huge " "com"
\n"
for (i in url) {
tag=url[i]
gsub(/\//, "/ ",tag)
gsub(/\/ \/ /,"//",tag)
huge=huge" "tag"
\n"
delete url[i]
}
huge=huge"
\n"
head=""
com=""
}
}
END {
print ""
print ""
print " "
print " "
print " the_link_cannon"
print " "
print " "
print " This is the \"link cannon\". Some folks asked me to post"
print " 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 room"
print " \"Linux, FreeBSD, Solaris:1\"
"
print " The collection originates from custom user commands created"
print " for a chat client program.
"
print " Conversion of the chat client"
print " curfloo"
print " commands file into this html page is not perfect, obviously."
print " The conversion script used is"
print " http://edge-op.org/files/curf-cannon
"
print " Conversion of the chat client"
print " zinc cmd file"
print " into curfloo commands format was done by using the"
print " zinc2floo.pl script written by \"mountainpenguin\" and"
print " included in the distribution of his"
print " zinc chat client.
"
print " See "
print " http://edge-op.org/files/zinc-link-cannon
"
print " (you will need to edit the variables to suit"
print " the locations of your files).
"
print "
Last updated: "modtime"
"
for (i in hd) {
print " [ "hd[i]" ] "
}
print huge
print " "
print ""
}' > ${targetfile}