#
# Copyright (c) 2002 Juan F. Codagnone <juam@users.sourceforge.net> 
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# URL: http://embryos.homeip.net/~juam/licq/genindex.sh

# directory with the patch information
juamdir=mine
# last cvs date of modification
fCVS=`cat lastcvs`

getFiles()
{
	grep ^F: "$1" |
	sed  -e 's/^F://g' -e 's/$CVSDATE/'$fCVS/g -e 's/ *//g'
}


diff2html()
{

     grep '^'$1: "$2" | sed  -e 's/^'$1'://g'| 
     sed -e 's/[>]/\&gt;/g'  -e 's/[<]/\&lt;/g'|
     awk '
     nada == 1 && NF == 0 { print "<br><br>"; next;}
     {   if( !nada ) nada = 1; print "   "$0 }'
} 

commitable()
{
	grep '^Y:' "$1" | sed -e 's/^Y:.*/Y/g'
}

getDescription()
{
	diff2html "D" "$1"
}

getWorkAs()
{
	echo $fCVS
}

getDate()
{
 	grep ^T: "$1"| sed  -e 's/^T://g'
}

getChanges()
{
	diff2html "C" "$1"
}

generateTable()
{
	cat <<EOF
 <center>
 <table border="1" summary=""> 
  <tr> 
     <td align="center"> <tt>  File </tt> </td>
     <td align="center"> <tt> Description </tt> </td>
     <td align="center"> <tt> Synced to CVS </tt> </td>
     <td align="center"> <tt> Last Change  Date </tt> </td>
     <td align="center"> <tt> Comments </tt> </td>
  </tr>

EOF
list=`grep -H ^T: $1/*|sort -nr -k 2 |cut -d: -f1`
for i in $list
do
	name=`getFiles $i`

	C="`commitable $i`"
	if [[ $C == "Y" ]];then
		color='bgcolor="#FFFF00"'
	else
		color=""
	fi

	cat << EOF
	  <tr>
	    <td $color align=center >
	      <a name="`basename $name`"></a>
	      <center><a href="$name">`basename $name`</a></center> </td> 
	    <td> `getDescription "$i"` </td>
	    <td align=center> `getWorkAs "$i"` </td>
	    <td align=center> `getDate "$i"` </td>
	    <td> `getChanges "$i"` </td>
	  </tr>
EOF
	done
	cat << EOF
 </table>
 </center>
EOF
}



cat << EOF
  Last Generation Date: `date -R`
 <H1> Licq Patches </H1>
 <H2> Tools </H2>
 <ul>
   <li>
     I use this script to resync patches: <a href="syncpatch">syncpatch</a>.
     (and of course, solve posibles conflicts by hand)
     Sugestions?
   </li>
   <li> 
     <a href="sidclean.sh">sidclean.sh</a> cleans the licq config files so it
     downloads the whole server list and upload the local user list.
     Make backups before useit. note that the script also do backups (~).
   </li>
   <li> 
     This page (and the tables) is staticly generated using
     <a href="genindex.sh">this</a> script. The futureof php :).
     (<a href="mine/onemodal">sample</a> of input file)
   </li>
 </ul>
 <H2> Other peoples patches </H2>
 <ul>
  <li> <a href="http://gene.wins.uva.nl/~talerven/licq/"> Tim's patches </a></li>
  <li> <a href="http://www.aucs.org/licq-patches/"> Edwin's patches </a> </li>
  <li> <a href="http://sector17.tvand.net/licq/"> Christian Thalinger's patches</a></li>
 </ul>

 <H2> my pending patches </h2>
 <p> Raw <a href="diff/">directory</a> </p>
 <p> The ones with yellow background are the one i would like to see inside
 licq official tree </p>
EOF

generateTable $juamdir

cat << EOF

 <h2> licq-devel lossy patches </h2>
  <p> Some patches that are not commited. Note that these are not the
  originals patches. I resync them against cvs. </p>

`generateTable list`

<p> You can go to my <a href="..">homepage</a> </p>
EOF

