($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/-/_/'g`
# echo eval "echo \$alt$f" 1>&2
# eval "alt=\"\$alt$f\""
if type alt$f >/dev/null 2>&1; then
#eval "alt=\"`alt$f`\""
alt$f
else
#echo "${alt:-Photo}" | $tojis
echo Photo
fi # | $tojis
)
getcomment() (
f=`echo $1|sed -e 's/\..*//' -e 's/-/_/g'`
eval "cmt=\"\$cmt$f\"" # set by autoimg
if type cmt$f >/dev/null 2>&1; then
cmt$f
#eval "cmt=\"`cmt$f`\""
elif [ "$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=${usest:+" 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`
if [ "$noow" -a -f $html -a -f $minifile ]; then
echo Skipping $i
return
fi
# 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]*\)".*'`
if [ $origx -gt $origy ]; then # Landscape
scaleopt="-xsize"
minix=$xsize
miniy=`echo $minix \* $origy / $origx | bc -l | sed 's/\..*//'`
minisize="width=\"$minix\" height=\"$miniy\""
else # Portrait
scaleopt="-ysize"
# miniy=$xsize # set height to width of landscape
miniy=$ysize # set height to the same as landscape
minix=`echo $miniy \* $origx / $origy | bc -l | sed 's/\..*//'`
minisize="width=\"$minix\" height=\"$miniy\""
fi
if [ ! -f $minifile -o $nomini -eq 0 ]; then
newx=$TH_X
catimg $i | $pnmscale $scaleopt $newx |\
eval $tnquant |\
$CJPEG -progressive > $minifile
fi
#minisize=`$DJPEG $minifile|pnmfile -| \
# sed 's/[^0-9]*\([1-9][0-9]*\) by \([0-9]*\).*/width="\1" height="\2"/'`
if [ "$TABLE" ]; then
echo "
" >&$iout
echo " " >&$iout
fi
echo "$TABLE" >&$aout
echo "$TABLE&$aout
echo "$TABLE $minisize$thumbclass>" >&$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
cat>$html<
$title
${usejs:+}
EOF
(
link=" ${usejs:+ }"
if [ "$prev" ]; then
phtml=`htmlname $prev`
link="PREV${usejs:+(S-Left)}"
fi
printf '%s' "$link | "
printf '%s' "INDEX | "
link=" ${usejs:+ }"
if [ "$next" ]; then
nhtml=`htmlname $next`
link="NEXT${usejs:+(S-Right)}"
fi
printf '%s' "${link}"
echo "${usejs:+ || S-Dwn(shrink) S-UP(enlarge)}"
printf '%s' " "
echo "
"
) >>$html
cat>>$html<
`getcomment $i`
`mkjheadtable $imglink`
EOF
)
set $files
previ=''
nfiles=$#
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|*.mp4|*.rm)
mov="$i"
i=`mksnap $i` ;;
*.jpg|*.jpeg|*.JPG)
cat=djpeg ;;
esac
do_file $i "$previ" "$nexti"
if [ "$progress" ]; then
nfiles=`expr $nfiles - 1`
printf "$nfiles "
fi
previ="$i"
shift
done
cssfile="`dirname $i`/$cssfile"
mkcss() {
bptop="${usest+25}0px"
index="${usest:+inde}x"
itop="${usest:+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;
z-index: 1;
}
body>div#$index {position: absolute; padding-top: 0; top: $itop; height: auto;}
img {vertical-align: top;}
p.c {text-align: center;}
table.exif {float: left;}
table.exif, table.exif * {
font-size: 95%; border: 1px solid black; border-collapse: collapse;
margin-right: 1em; background: #eef;
}
table.exif th {text-align: left;}
table.exif td {padding: 0.1ex 0.5ex;}
table.exif+p+* {clear: both;}
img.thumbnail {border: silver 3px outset;}
/* サムネイルを影つき写真の場合はコレ p class="shadow" で括ればよい。 */
img.shadow, *.shadow img {
border: white 3px solid; box-shadow: black 3px 3px 3px;
margin-right: 3px; margin-bottom: 3px;
}
EOF
}
mkcss
: <$jsfile<<\EOF
MSIE = navigator.userAgent.indexOf("MSIE")!=-1;
Safari = navigator.userAgent.indexOf("Safari")!=-1;
document.onkeypress = keyExec;
if (Safari) document.onkeydown = 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%";
var b6 = document.createElement("button");
setClickHandler(b6, "shrink();")
b6.innerHTML = "-10%";
var b7 = document.createElement("button");
setClickHandler(b7, "enlarge();")
b7.innerHTML = "+10%";
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);
sp.appendChild(b6);
sp.appendChild(b7);
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, lastX;
function stage(ev) {
me = MSIE ? ev.srcElement : ev.target;
if (me == lastelement || lastX == ev.screenX) 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);
stg.style.display = 'block';
removeAllChild(stg);
climg = document.createElement("img");
climg.setAttribute("src", me.getAttribute("src"));
var newst = stg.appendChild(climg);
var ox = me.getAttribute("width");
var oy = me.getAttribute("height");
newst.style.height=sty;
newst.style.width= oy ? sty/oy*ox : stx;
lastelement = me;
lastX = ev.screenX;
/* 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();
}
}
}
window.addEventListener("load", function(event) {
var touchStartX;
var touchMoveX;
var swThreshold=3*window.screen.width/5;
if (! "ontouchstart" in window) return;
var stg = document.getElementById("stage");
if (stg) {
var body = document.getElementsByTagName("body")[0];
var usage = document.getElementById("usage");
var eusage = document.getElementById("eusage");
body.addEventListener("touchstart", function(event) {
stg.style.display = "none";
if (usage) usage.innerHTML =
"サムネイルをタップすると画像単独表示へ。\
単独表示で画像を大きく左(右)にスワイプすると次(前)の画像に移ります。"
if (eusage) eusage.innerHTML =
"Tap thumbnail to show large image. \
In large-image mode, swipe image left(right) widely to go to the \
next(previous) image."
}, false)
return;
}
var img = getimg();
if (img == null) return;
img.addEventListener("touchstart", function(event) {
touchStartX = event.touches[0].screenX;
}, false);
// touchmove event
img.addEventListener("touchmove", function(event) {
if (event.changedTouches.length > 1) {
touchStartX = null;
return;
}
touchMoveX = event.changedTouches[0].screenX;
}, false);
// touchEnd
img.addEventListener("touchend", function(event) {
if (!touchStartX) return;
if (touchStartX > touchMoveX) {
if (touchStartX > (touchMoveX + swThreshold)) {
// from RIGHT to LEFT
img.style.opacity = 0.3;
moveHrefID('next');
}
} else if (touchStartX < touchMoveX) {
if ((touchStartX + swThreshold) < touchMoveX) {
// from LEFT to RIGHT
img.style.opacity = 0.3;
moveHrefID('prev');
}
}
}, false);
}, false);
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
printf "注文を受ける人のemailアドレス: "
read toaddress
done
while [ "$maintainer" = "" ]; do
printf "このページの管理者(多分あなた)のemailアドレス: "
read maintainer
done
cat>order.pl<Accepted";
if (\$mailto) {
open(MAIL, "|\$tojis | sendmail \$mailto");
print MAIL "To: \$mailto
From: Photo Ordering System <\$maintainer>
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 "