#! /bin/csh -f # Last edited on 2001-05-14 01:00:01 by stolfi set usage = "$0 TITLE" # Creates an index page "index.html" for the MP004 homework hand-ins. # This version is specialized for animations. # Reads files # ras.txt : RA numbers of all registered students # aus.txt : RA numbers of absentees # For each student, expecs to find files # ${ra}/main.pov - Main POV-ray file (student's original) # ${ra}/movie.gif - Animated gif hand-in (rebuilt to standard size) # ${ra}/frame-0.5.gif - Sample frame (rebuilt to standard size) if ( $#argv != 1 ) then echo "usage: ${usage}"; exit 1 endif set title = "$1"; shift; set path = ( . /n/image/bin/ $path ) set rafile = "ras.txt" set abfile = "aus.txt" set ofile = "index.html" # Submitted files: set sbpovfile = "main.pov" set sbmoviefile = "main.gif" set sbstillfile = "main.gif" # Rebuilt files: set stillfile = "frame-0.5.gif" set moviefile = "movie.gif" set iconfile = "icon.gif" # Make sure absentees have a (static) gray file and thumbnail: if ( ! ( -d reject ) ) mkdir reject foreach ra ( `cat ${abfile} | egrep -v '^ *([#]|$)'` ) echo "${ra} absent" # Reject any submission: if ( ( -r ${ra}/${iconfile} ) && ( ! { cmp -s ${ra}/${iconfile} absent-s.gif } ) ) then /bin/rm -f ${ra}/${iconfile} endif set reject = 0 if ( -r ${ra}/${sbpovfile} ) then set reject = 1 endif if ( -r ${ra}/${sbmoviefile} ) then if ( { cmp -s ${ra}/${sbmoviefile} absent.gif } ) then /bin/rm -f ${ra}/${sbmoviefile} else set reject = 1 endif endif if ( -r ${ra}/${sbstillfile} ) then if ( { cmp -s ${ra}/${sbstillfile} absent.gif } ) then /bin/rm -f ${ra}/${sbstillfile} else set reject = 1 endif endif if ( ${reject} ) then if ( ! ( -d ${ra}/reject ) ) mkdir ${ra}/reject /n/gnu/bin/mv -avi ${ra}/*{.{inc,pov,gif,png},akefile} ${ra}/reject. endif # Provide icon, still file, and fake movie file for absentees: if ( ( ! -r ${ra}/${iconfile} ) ) then ( cd ${ra} && ln -s ../absent-s.gif ${iconfile} ) endif foreach f ( ${stillfile} ${moviefile} ${sbstillfile} ${sbmoviefile} ) if ( ( ! -r ${ra}/${f} ) ) then ( cd ${ra} && ln -s ../absent.gif ${f} ) endif end end # Process all students set ras = ( `cat ${rafile} | egrep -v '^ *([#]|$)'` ) if ( -e ${ofile} ) then /bin/mv ${ofile} ${ofile}~ endif cat <> ${ofile} ${title}

${title}

EOF @ n = 0 foreach ra ( ${ras} ) # Ckeck if the POV-ray source exists. # If so, re-build the movie and the still image if ( ! ( -r ${ra}/${sbpovfile} ) ) then set povname = "missing.pov" else set povname = "${ra}/${sbpovfile}" echo "=== (re)building ${moviefile} in ${ra} ====================" ( cd ${ra} && make movie still ; echo " " ) echo "=== done rebuilding ${ra} ==============================" endif # Check whether the still frame exists, and make a thumbnail # if needed. if ( ! ( -r ${ra}/${stillfile} ) ) then # Remove thumbnail, if any if ( -r ${ra}/${iconfile} ) /bin/rm -f ${ra}/${iconfile} set stlname = "missing.gif" set iconame = "missing-s.gif" else if ( { cmp -s ${ra}/${stillfile} absent.gif } ) then # An absentee, set stlname = "absent.gif" set iconame = "absent-s.gif" else # Remove bogus or outdated thumbnail if ( -r ${ra}/${iconfile} ) then if ( ( -z ${ra}/${iconfile} ) || { /n/gnu/bin/test ${ra}/${stillfile} -nt ${ra}/${iconfile} } ) then /bin/rm -f ${ra}/${iconfile} endif endif # Make sure the thumbnail does exist: if ( ! ( -r ${ra}/${iconfile} ) ) then echo "=== creating thumbnail image for ${ra}/${stillfile} ===" cat ${ra}/${stillfile} \ | giftopnm \ | pnmscale -ysize 60 \ | pnmdepth 255 \ | ppmquant 254 \ | ppmtogif > ${ra}/${iconfile} endif # Use the image itself: set stlname = "${ra}/${stillfile}" set iconame = "${ra}/${iconfile}" endif # Check whether the movie exists if ( ! ( -r ${ra}/${moviefile} ) ) then set movname = "missing.gif" else if ( { cmp -s ${ra}/${moviefile} absent.gif } ) then # Absentee, return gray movie set movname = "absent.gif" else # Use movie set movname = "${ra}/${moviefile}" endif # format the buttons if ( "${povname}" == "missing.pov" ) then set povbutt = "[×]" else set povbutt = '[fonte]' endif if ( "${stlname}" == "absent.gif" ) then set stlbutt = "[×]" else if ( "${stlname}" == "missing.gif" ) then set stlbutt = "[×]" else set stlbutt = '[quadro]' endif if ( "${movname}" == "absent.gif" ) then set movbutt = "[×]" else if ( "${movname}" == "missing.gif" ) then set movbutt = "[×]" else set movbutt = '[filme]' endif set picbutt = '' # Output the entry if ( ${n} == 0 ) then echo " " >> ${ofile} endif cat <> ${ofile} EOF @ n = ${n} + 1 if ( ${n} >= 4 ) then echo " " >> ${ofile} @ n = 0 endif end if ( ${n} > 0 ) then echo " " >> ${ofile} endif cat <> ${ofile}
${picbutt}
${ra}
 
${stlbutt}  
${movbutt}  
${povbutt}  
EOF