($sz)
EOF
)
}
mksnap() {(
tmp1=00000001.jpg tmp2=00000002.jpg
dir=`dirname "$1"`
base=`basename "$1"`
root=`expr "$base" : '\(.*\)\..*'`
snap="sn_$root.jpg"
(cd "$dir"
mplayer -frames 1 -vo jpeg $base
rm -f $tmp2
mv -f $tmp1 $snap) > /dev/null 2>&1
echo "$dir/$snap"
)}
# Check img2www.txt
if [ -n "$annotate" -a -s $annotate ]; then
echo Reading $annotate... 1>&2
# Use temporary file because eval in pipeline takes no effect to
# the current shell environment
trap "finalize" INT TERM
getannotate > $anntmp
trap INT TERM
. $anntmp
rm -f $anntmp
echo Done
else
getalt() {
echo Photo
}
getcomment() {
echo 'この行を消してここにコメント
左寄せが良ければ に変える' \
| sed -e 's/^//' | $tojis
}
fi
getalt() {(
f=`echo $1|sed -e 's/\..*//' -e 's/-/_/'`
# echo eval "echo \$alt$f" 1>&2
eval "alt=\"\$alt$f\""
echo "${alt:-Photo}" | $tojis
)}
getcomment() {(
f=`echo $1|sed -e 's/\..*//' -e 's/-/_/'`
eval "cmt=\"\$cmt$f\""
if [ "$cmt" ]; then
echo $cmt
else
echo 'この行を消してここにコメント
左寄せが良ければ
に変える' \
| sed -e 's/^//'
fi | $tojis
)}
htmlname() {(
b=`basename $1|sed 's/\(.*\)\..*/\1/'`
echo `dirname $1`"/$b.html"
)}
[ x"$usejs" = x"" ] || {
jsinit=" onload=\"init();\""
jsstage=" onMouseOver=\"stage(event);\""
}
do_file() {(
i="$1"
prev="$2"
next="$3"
minibase=`basename $i|sed 's/\(.*\)\..*/\1/'`
minifile=`dirname $i`"/tn_${minibase}.jpg"
html=`dirname $i`"/$minibase.html"
imglink=`basename $i`
# echo mini=$minibase, mf=$minifile
alt=`getalt $i`
if [ "$alt" = "" ]; then
title=`readcomment $i`
if [ "$title" = "" ]; then
title="$i"
fi
else
title=`readcomment $i`
if [ x"$title" = x"" ]; then
title="$alt"
else
title="$title - $alt"
fi
fi
# get image size in pixel
size=`catimg $i|pnmfile -| \
sed 's/[^0-9]*\([1-9][0-9]*\) by \([0-9]*\).*/width="\1" height="\2"/'`
origx=`expr "$size" : '.*width=\"\([0-9]*\)".*'`
origy=`expr "$size" : '.*height=\"\([0-9]*\)".*'`
newx=$TH_X
if [ ! -f $minifile -o $nomini -eq 0 ]; then
##newx=`expr "$size" : 'width="\([0-9]*\)" .*'`
## catimg $i | pnmscale $SCALE | ppmquant 128 |\
catimg $i | pnmscale -xsize $newx | ppmquant 128 2>/dev/null |\
$CJPEG -progressive > $minifile
fi
#minisize=`$DJPEG $minifile|pnmfile -| \
# sed 's/[^0-9]*\([1-9][0-9]*\) by \([0-9]*\).*/width="\1" height="\2"/'`
minix=$xsize
miniy=`echo $xsize \* $origy / $origx | bc -l | sed 's/\..*//'`
minisize="width=\"$minix\" height=\"$miniy\""
if [ "$TABLE" ]; then
echo "
" >&$iout
echo " " >&$iout
fi
echo "$TABLE" >&$aout
echo "$TABLE &$aout
echo "$TABLE $minisize$thumclass>" >&$aout
if [ "$TABLE" ]; then
echo " | " >&$iout
CNT=`expr $CNT + 1`
echo " " >&$iout
if [ "$formhead" ]; then
echo " $i" >&$iout
else
echo " $title " >&$iout
echo " コメントその$CNT"|$tojis>&$iout
fi
echo " | " >&$iout
echo "
" >&$iout
fi
case "$imglink" in
sn_*)
mkmovlink "$mov" "$minifile" >&$iout
;;
esac
echo "" >$html
echo "$title" >>$html
echo "" >>$html
echo "${usejs:+}" >>$html
echo "" >>$html
echo "" >>$html
(
link=" ${usejs:+ }"
if [ "$prev" ]; then
phtml=`htmlname $prev`
link="PREV${usejs:+(S-Left)}"
fi
echo -n "$link | "
echo -n "INDEX | "
link=" ${usejs:+ }"
if [ "$next" ]; then
nhtml=`htmlname $next`
link="NEXT${usejs:+(S-Right)}"
fi
echo -n "${link}"
echo "${usejs:+ || S-Dwn(shrink) S-UP(enlarge)}"
echo -n " "
echo ""
) >>$html
echo "" >>$html
echo "
" >>$html
echo "
" >>$html
getcomment $i >>$html
echo "
" >>$html
echo "" >>$html
echo "" >>$html
)}
set $files
previ=''
for i
do
nexti="$2"
case $i in
# *.gif) # No more GIF!!
# cat=giftopnm ;; # No more Unisys!!!
tn_*|*mini*)
echo "Skipping $i"
continue ;;
sn_*) ;; # skip snapshot
*.mov|*.avi|*.mpg|*.rm)
mov="$i"
i=`mksnap $i` ;;
*.jpg|*.jpeg)
cat=djpeg ;;
esac
do_file $i "$previ" "$nexti"
previ="$i"
shift
done
cssfile="`dirname $i`/$cssfile"
mkcss() {
bptop="${usejs:+25}0px"
index="${usejs:+inde}x"
itop="${usebs:+0px}"
itop="${itop:-${TH_Y}px}"
pemx=`expr ${TH_X} + 15`
pemy=`expr ${TH_Y} + 15`
#body {overflow: hidden; padding-top: $bptop;}
#html > body {overflow: auto; padding-top: 0;}
cat>$cssfile < div#stage {position: fixed;}
div#$index {
position: static; height: 100%; padding-top: $itop;
overflow: auto;
background: #ffc0cb; /* =pink */
z-index: 1;
}
body>div#$index {position: absolute; padding-top: 0; top: $itop; height: auto;}
img {vertical-align: top;}
p.c {text-align: center;}
EOF
}
mkcss
: <$jsfile<<\EOF
MSIE = navigator.userAgent.indexOf("MSIE")!=-1;
document.onkeypress = keyExec;
self.focus();
function getKEYCODE(e){
if (document.getElementById && !MSIE )
return e.charCode||e.keyCode;
else if(document.all) return event.keyCode;
else if(document.layers) return e.which;
}
function getimg() {
return document.getElementById("x");
}
function replMag(link, mag) {
if (!link) return;
var orig = link.getAttribute("href");
var argp = orig.indexOf("?");
if (argp != -1) orig = orig.substring(0, argp);
link.setAttribute("href", orig+"?"+pcnt+"%25");
}
function setImgSize() {
var obj = getimg();
obj.style.width = imgx*pcnt/100;
obj.style.height = imgy*pcnt/100;
// Update PREV/NEXT Links
replMag(document.getElementById("prev"), pcnt);
replMag(document.getElementById("next"), pcnt);
var info = document.getElementById("info");
if (!info) return;
var mg = document.getElementById("mag");
mg.innerHTML = pcnt+"% "
}
function setClickHandler(obj, hdString) {
obj.setAttribute("onclick", hdString);
if (MSIE) obj.onclick = new Function(hdString);
}
function createBTN() {
var sp = document.getElementById("resizebtn");
if (sp)
return sp;
var mag = document.createElement("span");
mag.setAttribute("id", "mag");
mag.innerHTML = pcnt+"% "
var b1 = document.createElement("button");
setClickHandler(b1, "fitWin();")
b1.innerHTML = "fitToWindow";
var b2 = document.createElement("button");
setClickHandler(b2, "setWidth(400);")
b2.innerHTML = "400";
var b3 = document.createElement("button");
setClickHandler(b3, "setWidth(640);")
b3.innerHTML = "640";
var b4 = document.createElement("button");
setClickHandler(b4, "setWidth(800);")
b4.innerHTML = "800";
var b5 = document.createElement("button");
setClickHandler(b5, "set100();")
b5.innerHTML = "100%";
sp = document.createElement("span");
sp.setAttribute("id", "resizebtn")
sp.appendChild(mag);
sp.appendChild(b1);
sp.appendChild(b2);
sp.appendChild(b3);
sp.appendChild(b4);
sp.appendChild(b5);
return sp;
}
function frameWidth() {
return document.getElementsByTagName("body")[0].offsetWidth;
// setWidth(window.innerWidth);
}
function frameHeight() {
return window.height ||
(document.body&&document.body.clientHeight) ||
(document.documentElement&&document.documentElement.clientHeight) ||
480;
}
function setWidth(x) {
var r = 100*x/imgx;
pcnt = Math.floor(r);
setImgSize();
}
function setHeight(y) {
var r = 100*y/imgy;
pcnt = Math.floor(r);
setImgSize();
}
function fitWin() {
var img = getimg()
var w = frameWidth();
var h = frameHeight()-(img.offsetTop||60);
if (1.2 * getimg().getAttribute("width") > w)
setWidth(w);
if (getimg().getAttribute("height") > h)
setHeight(h);
}
function shrink() {
init();
if (pcnt > 10) {
pcnt -= 10;
setImgSize();
if (MSIE) window.scrollTo(0, 0);
}
}
function set100() {
pcnt=100;
setImgSize();
}
function enlarge() {
init();
if (pcnt < 100) {
pcnt += 10;
setImgSize();
}
}
function moveHrefID(id) {
var cur = location.pathname;
var file = cur.substring(cur.lastIndexOf("/")+1);
var next = document.getElementById(id);
if (!next) return;
next = next.getAttribute("href");
//alert(next);
if (pcnt != 100 && next.indexOf("?") == -1)
next = next + "?"+pcnt+"%";
location.replace(next);
//location.href = next;
img = getimg();
img.setAttribute("onLoad", "init();");
img.onload = "init();"
return;
alert(pcnt);
//setImgSize();
obj = getimg();
obj.style.width = imgx*pcnt/100;
obj.style.height = imgy*pcnt/100;
}
function keyExec(e) {
key = getKEYCODE(e);
mods = null;
// if (!MSIE) mods = e.shiftKey|e.ctrlKey|e.altKey;
//alert(e.shiftKey)
if (!MSIE) mods = e.shiftKey|e.ctrlKey|e.altKey;
//d=new Date();
// alert(e.type+", "+d.getSeconds())
switch (key) {
case 40: case 63233: // down
if (e.shiftKey)
shrink();
break;
case 38: case 63232: // up
if (e.shiftKey) enlarge();
break;
case 37: case 63234: // left
if (e.shiftKey) moveHrefID("prev");
break;
case 39: case 63235: // right
if (e.shiftKey) moveHrefID("next");
break;
default:
numericarg = 0;
}
return;
}
function removeAllChild(obj) {
cs = obj.childNodes;
var element_node = obj.nodeType;
var i=0;
while (i indexHeight) {
idx.style.height = height-stageHeight;
}
}
*/
function getCSSproperty(element, prop) {
// http://www.quirksmode.org/dom/getstyles.html
if (element.currentStyle)
return element.currentStyle[prop];
if (window.getComputedStyle)
return document.defaultView.getComputedStyle(element, null).getPropertyValue(prop);
return null;
}
var lastelement, lastY;
function stage(ev) {
me = MSIE ? ev.srcElement : ev.target;
if (me == lastelement || lastY == ev.screenY) return;
var src = me.getAttribute("src");
var stg = document.getElementById("stage");
var stx = stg.style.width || parseInt(getCSSproperty(stg, "width")) ||
/* There's no way to get effective element's width on `Safari 1.3'.
* So use offsetWidth for Safari.
* -20 is ugly workaround for padding */
stg.offsetWidth-20 || 320;
var sty = parseInt(getCSSproperty(stg, "height") || stx*.75);
removeAllChild(stg);
var newst = stg.appendChild(me.cloneNode(true));
var ox = me.getAttribute("width");
var oy = me.getAttribute("height");
newst.style.height=sty;
newst.style.width= oy ? sty/oy*ox : stx;
lastelement = me;
lastY = ev.screenY;
/* adjIdx(); */
//document.getElementById("index").style.height = "auto";
}
var imgx=0, imgy;
var pcnt = 100;
function init() {
if (imgx == 0) {
var img=getimg();
imgx = parseInt(img.width);
imgy = parseInt(img.height);
// alert(location.href)
if (!document.getElementById("button")) {
var info = document.getElementById("info");
if (info) info.appendChild(createBTN());
}
if (MSIE) {
var b = document.getElementsByTagName("body")[0];
b.onkeydown = new Function("keyExec(event);");
}
if (location.href.match(/(.*)\?(\d+)%/) && imgx > frameWidth()) {
pcnt = parseInt(RegExp.$2);
setImgSize();
} else {
fitWin();
}
}
}
EOF
}
[ "$usejs" ] && mkjs
##mkorder function
mk_order () {
perl=`which perl`
if [ -x /usr/lib/sendmail ]; then
sendmail=/usr/lib/sendmail
elif [ -x /usr/sbin/sendmail ]; then
sendmail=/usr/sbin/sendmail
else
sendmail=sendmail
fi
tojis=`which nkf`
while [ "$toaddress" = "" ]; do
echo -n "注文を受ける人のemailアドレス: "
read toaddress
done
while [ "$maintainer" = "" ]; do
echo -n "このページの管理者(多分あなた)のemailアドレス: "
read maintainer
done
cat>order.pl<Accepted";
if (\$mailto) {
open(MAIL, "|\$tojis | sendmail \$mailto");
print MAIL "To: \$mailto
From: Photo Ordering System <\$mailtainer>
Subject: Confirmation of your order
Reply-to: \$replyto
以下の写真注文を受理しました。以下のリストであっているかどうか確認し、
これで良ければ、このメイル全体を引用して \$replyto にご返送ください。
";
print MAIL join("\n", @list);
close(MAIL);
print "注文リストを送信しますので合っているかどうか確認してください。";
} else {
print "メイルアドレスは必ず入れてください。";
}
print "\n";
EOF
chmod +x order.pl
}
if [ "$noindex" -eq 0 ]; then
if [ "$TABLE" ]; then
echo "