#!/bin/bash
chmod -R -f g+w .

rm lectures/*~
rm lectures/future/*~
rm *~

./h2rss.pl future ../rss2file

#./combine_external.pl

./combine_lectures.pl index advocate programming util system kernel network video security lectures1 lectures2 lectures3 lectures4 lectures5 lectures6 lectures7 lectures8 lectures9 lectures10 lectures11 lectures12 lectures13 lectures14 lectures15 lectures16 lectures17 lectures future sil

./combine_lectures.pl guy_keren hebrew/guy_keren orr_dunkelman hebrew/orr_dunkelman shlomi_fish hebrew/shlomi_fish alon_altman hebrew/alon_altman muli_ben-yehuda hebrew/muli_ben-yehuda eli_billauer hebrew/eli_billauer orna_agmon hebrew/orna_agmon ohad_lutzky hebrew/ohad_lutzky rami_rosen hebrew/rami_rosen
./combine_lectures.pl hebrew/index hebrew/advocate hebrew/programming hebrew/util hebrew/system hebrew/kernel hebrew/network hebrew/video hebrew/security hebrew/lectures1 hebrew/lectures2 hebrew/lectures3 hebrew/lectures4 hebrew/lectures5 hebrew/lectures6 hebrew/lectures7 hebrew/lectures8 hebrew/lectures9 hebrew/lectures10 hebrew/lectures11 hebrew/lectures12 hebrew/lectures13 hebrew/lectures14 hebrew/lectures15 hebrew/lectures16 hebrew/lectures17 hebrew/lectures hebrew/future hebrew/sil

./make_site.pl *.htm hebrew/*.htm
#index for the source directory
./gen_index.pl

mkdir -p ../hebrew


#mv hebrew files - do not move the whole directory
#because there may be links in the public hebrew directory,
#that we wish to preserve.
                                                                                
										\mv -f ./gen/hebrew/*.html ../hebrew
										\mv -f ./gen/*.html ../

# Eli, 13.1.13: Fix hebrew extremely dirty hack. Any .html file that
# isn't under source/ and has been modified during the last 60 minutes is
# mangled. Any line in these files that doesn't look like UTF-8 is translated
# into UTF-8 from windows-1255.
										
WWWPATH=/var/www/html
find $WWWPATH -iname \*.html -a -type f -a -mmin -60 \
     -a -not -path $WWWPATH/source/\* | \
  while read fixfile ; do
    ./fix-utf8.pl "$fixfile" > "$fixfile.utf8-tmp"
    mv -f "$fixfile.utf8-tmp" "$fixfile"
  done;

  # Extra cleanup, just to be sure
  rm -f `find $WWWPATH -name \*.utf8-tmp`

# End of dirty hack

# Eli, 25.1.13: Commended out make_friendly and chmod's, since they're not
# necessary anymore but produce error messages
#chmod -R -f g+w ..
#chmod -R -f a+rx ..
#chmod -R -f o-w ..
#chgrp -R haifux ../*

#changing directory to lectures directory!
#cd ../lectures/
#./make_friendly

