Subversion Repositories wimsdev

Rev

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