script to dynamically generate the hints list

Olivier Pérès olivier.peres at laposte.net
Mon Sep 15 10:52:36 PDT 2003


>  > All 4 fields can never be empty, if they are they will not be
>  > committed to the site.
> 
> Can you take care of this? Thanks!
> 

    I'm not quite sure who said what to whom. If you are asking me to change the 
script to conform to Tushar's last two messages, then remove the 
check_and_report function and the lines that call it, and also the line that 
computes a value for UNDATEDHINTS and the reference to it in the for loop. I 
don't have my Linux box right here, but I think the result should be:

-- beginning of file genlist.sh --

#!/bin/sh

# genlist.sh
# Script to automatically generate a list of LFS hints
# by Olivier Pérès (Olivier Peres if your terminal cannot print accents)
# Modified by Jeroen Coumans to conform to the LFS template
# email: olivier dot peres at laposte dot net
# Last updated September 15th, 2003
# This version now expects the hint files to be valid
#   (fields DATE, AUTHOR, LICENSE and SYNOPSIS must not be empty)
#   since this is checked when hints are submitted.
# License: GPL.

# Usage: run in the hints/ subdirectory.

#   Limitations
#   ===========
#
# * hint file names must not contain colons, spaces, or any control characters.



# the file to which to write

OUTPUTFILE="list.html"

function output
{
     # echoes its argument to OUTPUTFILE

     echo $1 >> $OUTPUTFILE
}


function htmlclean
{
     # replaces '<' and '>' with the corresponding entities so that they
     # can appear in documents (useful for the authors' email addresses).

     echo `echo $1 | sed -e 's/>/\>/' -e 's/</\</'`
}

# HINTS = list of all the files in reverse chronological order.
#         (sorted according to their DATE fields, not to the file ages)

DATEDHINTS=`grep -H "DATE:" downloads/files/* | sort -fbi -r -k3 -t: \
            | cut -f1 -d:`

# initialise output file

cat list-top.html > $OUTPUTFILE # The top of the list.

# write hints

for HINT in $DATEDHINTS
do
     DATE=`echo \`grep -h "DATE:" $HINT | cut -f2 -d:\``
     SYNOPSIS=`echo \`grep -h "SYNOPSIS:" $HINT | cut -f2 -d:\``
     AUTHORS=`echo \`grep "AUTHOR:" $HINT | \
         cut -f2 -d: | sed 's/$/,/'\` | sed 's/,$//'`
     LICENSE=`echo \`grep -h "LICENSE:" $HINT | cut -f2 -d:\``

     output "<li><h4><a href=\"$HINT\" title=\"$HINT\">$SYNOPSIS</a></h4>"
     output "<dl>"
     output "<dt>Author(s):</dt>"
     output "<dd>`htmlclean "$AUTHORS"`</dd>"
     output "<dt>Date Last Updated:</dt>"
     output "<dd>$DATE</dd>"
     output "<dt>License:</dt>"
     output "<dd>$LICENSE</dd>"
     output "</dl>"
     output "</li>"
done


# finalise output file

cat list-bottom.html >> $OUTPUTFILE

-- end of file genlist.sh --

    Olivier.




More information about the website mailing list