cvs commit: www/hints genlist.sh

jeroen at linuxfromscratch.org jeroen at linuxfromscratch.org
Mon Sep 15 11:25:09 PDT 2003


jeroen      03/09/15 12:25:09

  Added:       hints    genlist.sh
  Log:
  Add genlist.sh, a script contributed by Olivier Peres to generate the hints' list.html from a fresh CVS checkout.
  
  Revision  Changes    Path
  1.1                  www/hints/genlist.sh
  
  Index: 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)
  
  HINTS=`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 $HINTS
  do
      DATE=`echo \`grep -h "DATE:" $HINT | cut -f2 -d:\``
      SYNOPSIS=`echo \`grep -h "SYNOPSIS:" $HINT | cut -f2 -d:\``
      AUTHORS=`echo \`grep -h "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
  
  
  
  



More information about the website mailing list