#!/bin/sh

# from 1600x1200 jpegs, 1024x768 ones, 30% ones and 15% ones are created,
# with symlinked .xvpics directories

# Jenik Hollan, N. Copernicus Observatory and Planetarium in Brno, April 2002

# to make the index files, sed is to be installed in unix (a must anyway)

#  date_hp315_jpgs
 
if [ -d fit ]
 then 
  cd fit
  index_thumb
#  the images are still large, so index with thumbnails is created  
 else
  cd fit 
fi

if [ -d third ]
 then
  cd third
  index_tab
fi

if [ -d sixth ]
 then
  cd sixth
  index_plain
#  index with just all images themselves is created, simply filling the page   
 else
  cd sixth 
fi

if [ ! -d thumb ]
 then
  mkdir thumb
  for F in *.jpg 
  do convert -geometry 60% $F thumb/$F
   touch -r $F thumb/$F 
#  this gives the smaller file the original timestamp
  done
  cd thumb
 # ln -s ../.xvpics ./
  index_plain
#  index with just all images themselves is created, simply filling the page   
 else
  cd thumb
  index_plain
fi

cd ../.. ; ln -s sixth/thumb thumb  
cd .. ; ln -s third/sixth/thumb thumb    
cd .. ; ln -s fit/third/sixth/thumb thumb

  index_thumb
#  the images are very large, so index with just thumbnails is created  
  if [ ! -a list.htm ]
   then 
# renaming the output of index_thumb back to list.htm
   mv index.htm list.htm
  fi
  if [ ! -d fullsize ]
   then
    mkdir fullsize
    cd fullsize
    ln -s ../*.jpg ./
    cd ..
  fi

#if [ (du -sS | sed "s/[[:blank:]]\(.*\)//")  \
#    < (df ./ | sed  -n "2 s/ \+/ /gp" | cut -d ' ' -f 4) ] 
# then
#  ls 
#fi

cd fit/third

zgv 
# here the user is assumed to press u to create thumbnails 
# and then exit sometimes later
