Subversion Repositories wimsdev

Rev

Rev 6955 | Rev 10454 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #! /bin/sh
  2. #
  3. # script to look at each example class and copy sheet in public_html/bases/sheet/$class_lang/$class_level/$class_number/
  4. # to be execute at before each realize of a wims package.
  5. #
  6. # authors : F. Guerimand
  7. # mail : fwguerima@free.fr
  8. # this script is launch by mkindex. Don't use it directly
  9. #
  10.  
  11. ## level, lang, supervisor, email are those of the class
  12. ## if information is in the file .sheet$i, take it
  13. ## if not, take the information in the file .sheets
  14. ## if not, make something by default
  15.  
  16. whome="$1"
  17. if [ -z "$whome" ]; then
  18.  echo "don't use this script directly. execute mkindex";
  19.  exit
  20. fi;
  21. target="$whome/public_html/bases/sheet";
  22. cd $whome/log/classes/;
  23. clist=`ls -d [0-9]*`;
  24. for cls in $clist; do
  25.  if [ $cls -lt 9000 ]; then
  26.   level=`awk -F'=' '$1=="!set class_level" {print $2; exit}' ./$cls/.def`;
  27.   slevel=`awk -F'=' '$1=="!set class_slevel" {print $2; exit}' ./$cls/.def`;
  28.   lang=`awk -F'=' '$1=="!set class_lang" {print $2; exit}' ./$cls/.def`;
  29.   sup=`awk -F'=' '$1=="!set class_supervisor" {print $2; exit}' ./$cls/.def`;
  30.   email=`awk -F'=' '$1=="!set class_email" {print $2; exit}' ./$cls/.def`;
  31.   domain=`awk -F'=' '$1=="!set class_domain" {print $2; exit}' ./$cls/.def`;
  32.   if [ -n "$level" -a -n "$lang" ]; then
  33.    cd $cls/sheets/;
  34.   # echo "--------------- $cls ; $level ; $lang"
  35.    slist=`ls .sheet[0-9]*`;
  36.    tmptarget="$target/$lang/$level/$cls";
  37.    mkdir -p $tmptarget;
  38.    for sh in $slist; do
  39.     num=${sh##.sheet};
  40.     # test if statut of sheet is non 0
  41.     statut=`awk -v no="$num" 'BEGIN{cpt=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){print($0);exit;}}' .sheets`;
  42.     if [ "$statut" != ":0" ]; then
  43.      entete=`awk '{a=substr($0,1,1); if(a==":")exit; else print($0);}' $sh`;
  44.      namesh=${sh##.};
  45.      if [ -n "$entete" ]; then
  46.       #First case : information is in file .sheet$i : keep it (but not title and desc)
  47.       # echo "$sh : direct copy";
  48.       title=`awk -v no="$num" 'BEGIN{cpt=0;l=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){l++;if(l==3){print($0);exit;}} }' .sheets`;
  49.       desc=`awk -v no="$num" 'BEGIN{cpt=0;l=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){l++;if(l==4){print($0);exit;}} }' .sheets`;
  50.       echo "$title
  51. $desc" >$tmptarget/$namesh.def;
  52.       awk 'FNR>2{print $0}' $sh >>$tmptarget/$namesh.def;
  53.      else
  54.       #second case : information not in file .sheet$i : make it with files .sheets and .def.
  55.       dt=`perl -e 'for (@ARGV) {@S=stat($_); print scalar(localtime($S[9]))}' $sh`
  56.       dt=${dt##* };
  57.       title=`awk -v no="$num" 'BEGIN{cpt=0;l=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){l++;if(l==3){print($0);exit;}} }' .sheets`;
  58.       desc=`awk -v no="$num" 'BEGIN{cpt=0;l=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){l++;if(l==4){print($0);exit;}} }' .sheets`;
  59.       keyword=`awk -v no="$num" 'BEGIN{cpt=0;l=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){l++;if(l==6){print($0);exit;}} }' .sheets`;
  60.       domain1=`awk -v no="$num" 'BEGIN{cpt=0;l=0;} {a=substr($0,1,1); if(a==":")cpt++; if(cpt==no){l++;if(l==5){print($0);exit;}} }' .sheets`;
  61.       ## if keyword is empty, take the level (only for H)
  62.       if [ ! -n "$keyword" ]; then
  63.        if [ -n "$slevel" ]; then
  64.         keyword=`echo "$slevel"`;
  65.        else
  66.         keyword=`echo "level$level"`;
  67.        fi ;
  68.       fi;
  69.      # echo "$sh : make presentation"; leave the empty line after email for description
  70.      # of the sheet in the search engine
  71.       echo "$title
  72. $desc
  73. ??,$dt
  74. 2
  75. $level
  76. $domain, $domain1
  77. $keyword
  78. $sup
  79. $email
  80.  
  81. " > $tmptarget/$namesh.def;
  82.       cat $sh >> $tmptarget/$namesh.def;
  83.      fi;
  84.    # else
  85.    #  echo "$sh : EMPTY sheet";
  86.     fi;
  87.    done;
  88.    cd ../..;
  89.  # else
  90.  # echo "-----------------------NOTHING ---------- $cls ; $level ; $lang";
  91.   fi;
  92.  fi;
  93. done;
  94.  
  95.  
  96.