# Take the .jpeg images in a director and convert them
# into big and small images in subdirectories big and small.
# Then create a basic web page which incorporates the
# small images and links them to the big ones.
# $Id: Makefile,v 1.2 2002/12/22 02:44:18 grog Exp $

# The web page bits and things are here
DOCSRC?= /home/grog/Photos

# Web page name
PAGE?=	index.html

webpage: big small
	mkdir -p RCS
	if [ -f ${PAGE} ]; then \
	  mv -f ${PAGE} ${PAGE}~; \
	fi
	if [ -f RCS/${PAGE},v ]; then \
	  rcs -l ${PAGE}; \
	fi
	DIR=`pwd | sed 's:.*public_html/::'`; \
	DATE=`date '+%A, %e %B %Y'`; \
	sed < ${DOCSRC}/index-0.html "s:DIRECTORY:$$DIR:; s:DATE:$$DATE:" > ${PAGE}; \
	for i in *.jpeg; do sed < ${DOCSRC}/imgtemplate "s:IMAGE:$$i:;s:DIR:$$DIR:" >> ${PAGE}; done; \
	cat ${DOCSRC}/index-n.html >>${PAGE}; \
	PDIR=`pwd | sed 's:public_html.*:public_html:'`; \
	ci -m"Created by 'make webpage'" -t-"Basic web page for photos in this directory" -u ${PAGE}; \
	if [ $$PDIR != `pwd` ]; then \
	  DEST=$${PDIR}/`echo $$DIR | sed 's:/:-:g'`.html; \
	  echo cp -p ${PAGE} $${DEST}; \
	  rm -f $${DEST}; \
	  cp -p ${PAGE} $${DEST}; \
	  chmod +w $${DEST}; \
	fi

big:
	mkdir -p big
	for i in *.jpeg; do convert $$i big/$$i; done

small:
	mkdir -p small
	for i in *.jpeg; do convert -geometry 25% $$i small/$$i; done

clobber:
	if [ -d big ]; then \
	  rm -rf big small RCS; \
	fi
