All pastes #432102 Raw Edit

Mine

public text v1 · immutable
·published 2007-04-10 01:43 UTC
rendered paste body
#!/bin/bash
REVISION_DAY=`date '+%d'`
REVISION_MONTH=`date '+%B'`
REVISION_YEAR=`date '+%Y'`
HOST_NAME="manpagesfr.free.fr"
MANDIR="man"

if [ $REVISION_DAY == "01" ]
then
  REVISION_DAY_STRING=1er
elif [ $REVISION_DAY == "02" ]
then
  REVISION_DAY_STRING=2
elif [ $REVISION_DAY == "03" ]
then
  REVISION_DAY_STRING=3
elif [ $REVISION_DAY == "04" ]
then
  REVISION_DAY_STRING=4
elif [ $REVISION_DAY == "05" ]
then
  REVISION_DAY_STRING=5
elif [ $REVISION_DAY == "06" ]
then
  REVISION_DAY_STRING=6
elif [ $REVISION_DAY == "07" ]
then
  REVISION_DAY_STRING=7
elif [ $REVISION_DAY == "08" ]
then
  REVISION_DAY_STRING=9
elif [ $REVISION_DAY == "09" ]
then
  REVISION_DAY_STRING=9
else
  REVISION_DAY_STRING=$REVISION_DAY
fi

if [ ! -e "$1" ]
then
  echo "Le fichier $1 n'existe pas"
  exit 1
fi

# si c'est une page secondaire,
if [[ $(grep ".so man" $1) ]]
then
  # si la version html existe, l'effacer
  if [ -e "$1.html" ]
  then
    rm -rf $1.html
  fi
  # ajouter une redirection au fichier .htaccess
  cat $1 | sed -e "
s|\.so \(man[[:digit:]]\)/\(.*\)|RedirectPermanent /$MANDIR/\1/$1\.html http://$HOST_NAME/$MANDIR/\1/\2.html|
" \
  >> .htaccess
  exit 0
fi

# si la pge html existe déjà
if [ -e "$1.html" ]
then
  # et qu'elle est plus récente que la page de man
  if [ "$1" -ot "$1.html" ]
  then
    # alors on ne fait rien
    exit 0
  fi
fi
cat $1 | \
sed "# supprime la ligne vierge précédant .SH
s/^$\n\(\.SH.*$\)/\1/
" | \
man2html | sed -e "
# supprime les lignes vides
#/^$/d
# supprime la ligne contenant Content-type: text
/^Content-type: text\/html$/d
# Traduction du nom de la page html
s/<TITLE>\(Manpage of \)\([[:alnum:]]*\)<\/TITLE>/<TITLE>Page manuel de \2<\/TITLE>/
# Typo française
s/Section:/Section :/
# Création du lien vers la page Index.?.html
s/\(Section : [^(]*\)(\([[:digit:]]\))/\1(<A HREF=\"http:\/\/$HOST_NAME\/$MANDIR\/man\2\/Index\.\2\.html\">\2<\/A>)/
# Traduction de la mise à jour
s/Updated: \([[:digit:]]\{1,2\}\) \([[:alpha:]]*\) \([[:digit:]]\{4\}\)/Mise à jour de la version anglaise : \1 \2 \3/
s/Time: .*$/  <div id=\"modification\"\>\n    <p>Dernière mise à jour : $REVISION_DAY_STRING $REVISION_MONTH $REVISION_YEAR<\/p>\n  <\/div>/
/This document was created by/,/using the manual pages/{d}
s/<\/HEAD>/  <link rel=\"stylesheet\" href=\"..\/manpage.css\" type=\"text\/css\"\/>\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=UTF-8\"\/><\/head>/
# modif des liens entre pages manuel
s|<A HREF=\"http://localhost/cgi-bin/man/man2html?\([[:digit:]]\)+\([[:alnum:]_-\.]*\)\">[[:alnum:]_-\.]*</A>|<A HREF=\"http://$HOST_NAME/$MANDIR/man\1/\2\.\1\.html\">\2<\/A>|
# modif des liens vers l'index
s|<A HREF=\"http://localhost/cgi-bin/man/man2html\">Return to Main Contents</A>|<A HREF=\"http://$HOST_NAME/consulter\.html\">Menu principal</A>|
# ajout de div page
s/<BODY>/<BODY>\n<div id=\"page\">/
s/<\/body>/<\/div>\n<\/body>/
# supprime la balise <HR>
s/<HR>//
s///
s///" \
	 > $1.tmp

if [ ! -e $1.html ]
then
  cp -p $1.tmp $1.html
fi

diff -u $1.html $1.tmp > $1.htmldiff

if [ -s "$1.htmldiff" ]
then
#  echo $1.htmldiff n\'est pas vide
  rm -f $1.html
  mv $1.tmp $1.html
else
#  echo $1.revdiff est vide
#  rm -f $1.htmldiff
  rm -f $1.tmp
fi
rm -f $1.htmldiff

exit 0