Mercurial > hgrepos > hgweb.cgi > s4
changeset 391:554dc6669027
Icon cache'ing refined
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Tue, 29 Nov 2016 13:18:47 +0859 |
parents | 5a40f38d7daf |
children | be955399aec9 |
files | s4-funcs.sh |
diffstat | 1 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/s4-funcs.sh Mon Nov 28 19:04:20 2016 +0859 +++ b/s4-funcs.sh Tue Nov 29 13:18:47 2016 +0859 @@ -1608,6 +1608,7 @@ whos="$keycond AND key='profimg' AND type LIKE 'file:image%' ORDER BY rowid DESC LIMIT 1" [ -d "$dir" ] || mkdir -p "$dir" + tmpf=$tmpd/imgsrc_cache.$$ case "$4" in [Ss]) size=S ;; [Oo]) size=O ;; @@ -1631,13 +1632,16 @@ cacheimg_O=$dir/$filename cacheimg=$dir/${size}_$filename sumfile="$dir/$filename.sum" - tmpf=$tmpd/imgsrc_cache.$$ sum=`query "$sql1" | tee $tmpf | encode` # encode() is maybe sha1 - if test -s "$sumfile" && [ x"`cat $sumfile`" = x"$sum" ]; then - # if cache is fresh, + if test -s "$sumfile" && [ x"`cat \"$sumfile\"`" = x"$sum" ] \ + && test -s "$cacheimg_S" && test -s "$cacheimg_M" ; then + # if cache is fresh and has the same checksum, echo "<img src=\"$cacheimg\">" else - fifo=$tmpd/fifo; mkfifo $fifo + fifo=`mktemp "$tmpf.fifo.XXXXXXX"` + rm -f $fifo # Safe, because $tmpf is in mktemp dir. + fifo2=$fifo.2 + mkfifo $fifo $fifo2 fmt=${filename##*.} ## [[ NOTE ]] ## a. convert oldimage newimage @@ -1647,12 +1651,13 @@ | tee $fifo \ | convert -define ${fmt}:size=${iconxy_M}x${iconxy_M} \ -resize ${iconxy_M}x${iconxy_M}'>' - ${fmt}:- \ + | tee $fifo2 \ | convert - "$cacheimg_M" & cat $fifo | convert -define ${fmt}:size=${iconxy_S}x${iconxy_S} \ -resize ${iconxy_S}x${iconxy_S}'>' - ${fmt}:- \ | convert - "$cacheimg_S" & printf '%s' "<img src=\"data:${filetype}," - cat $tmpf | sed 's/\(..\)/%\1/g' + hexize "$fifo2" |sed 's/\(..\)/%\1/g' # Use medium as pre-cached image echo '">' echo "$sum" > $sumfile fi @@ -2013,6 +2018,7 @@ echo $pnbtn ## err ListEntry: `echo "$sql"\;` +# sq $db here??? 2016-11-28 query "$sql limit $limit ${offset:+offset $offset};" \ | while IFS='|' read id lnk name qname icon gecos tag ownerp type; do err name=$name owner=$ownerp lnk=$lnk @@ -2022,7 +2028,7 @@ echo "<div class=\"iconlist xy$thumbxy $type\"> <p class=\"tag _$tag\">$tag</p>" \ | _m4 $tagconv - if [ -z "NOSPEEDUP" ]; then + if [ -n "$NOSPEEDUP" ]; then files=`getvalbyid $tbl profimg $id $icondir` if [ -n "$files" ]; then icon=`echo "$files"|tail -1` @@ -2031,7 +2037,7 @@ iconhref "$dir/$deficon" "$hrb+$lnk" "$gecos" fi elif [ -n "$icon" -a -s "$icon" ]; then - iconhref2 "./$icon" "$hrb+$lnk" "$gecos" + iconhref2 "$icon" "$hrb+$lnk" "$gecos" else cond="$nm=$qname" # err imgsrc_cache "$dir/list" ${tbl}_m "$cond" S @@ -2040,7 +2046,7 @@ # err "img=[$img]" if [ -n "$img" ]; then echo "<a href=\"$hrb+$lnk\">" - imgsrc_cache "$dir/list" ${tbl}_m "$nm=$qname" S + imgsrc_cache "$icondir" ${tbl}_m "$nm=$qname" S echo "</a>" else iconhref2 "$dir/$deficon" "$hrb+$lnk" "$gecos" @@ -3324,9 +3330,11 @@ prompt='' # Remove prompt ;; [Aa][Uu][Tt][Hh][Oo][Rr]) + [ -n "$GF_VIEWONLY" ] && continue form="<input type=\"hidden\" name=\"author\" value=\"$user\">" prompt="" ;; [Oo][Ww][Nn][Ee][Rr]) + [ -n "$GF_VIEWONLY" ] && continue val=${GF_OWNER:-$val} val=${val:-$user} form="<input type=\"hidden\" name=\"owner\" value=\"$val\">" @@ -3343,6 +3351,7 @@ val="" ;; [Ss][Ee][Rr][Ii][Aa][Ll]|[Ss][Tt][Aa][Mm][Pp]) + [ -n "$GF_VIEWONLY" ] && continue if [ -z "$rowid" ]; then val=`genserial` fi