Mercurial > hgrepos > hgweb.cgi > s4
diff s4-funcs.sh @ 69:d10f98c2b192
form+dump
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Fri, 31 Jul 2015 16:15:31 +0900 |
parents | 7380bcf19078 |
children | 3a157da0801d |
line wrap: on
line diff
--- a/s4-funcs.sh Fri Jul 31 10:35:04 2015 +0900 +++ b/s4-funcs.sh Fri Jul 31 16:15:31 2015 +0900 @@ -468,6 +468,13 @@ mktempd() { TMPDIR=$tmpd mktemp -d -t $session } +getcachedir() { # $1=maintable + if [ -n "$imgcached" ]; then + echo $tmpdir/$imgcached/$(echo ${1:-hoge}|md5)/$thumbxy + else + echo $tmpd/$thumbxy + fi +} getval() { # $1=table $2=col $3(optional)=condition case `gettbl_coltype "/$1/$2"` in @@ -1306,7 +1313,7 @@ coalesce(b.gecos, a.$nm) as name, b.tag, case when a.$nm in (select user from grp_adm - where gname=$getgrp) then '(管理者)' -- from group mode + where gname=$getgrp) then '(管理者)' when '$user' in (select user from grp_adm where gname=a.$nm) then '(ADMIN)' when '$iamowner' = '' then '' @@ -1351,7 +1358,7 @@ EOF fi - err ListEntry: `echo $sql\;` + err ListEntry: `echo "$sql"\;` query "$sql limit $limit ${offset:+offset $offset};" \ | while IFS='|' read id lnk name gecos tag ownerp; do @@ -2011,13 +2018,15 @@ <span>ほんとうに消しますよ(確認)! <input name="confirm" type=checkbox value="yes">はい</span>' fi + # Image Cache dir + td=`getcachedir $2` while IFS=: read prompt name keytype type args; do [ -z "${prompt%%\#*}" ] && continue # skip comment line(#) sp="${args:+ }" form="" val="" if [ -n "$rowid" ]; then - val=`getvalbyid $2 $name $rowid $tmpd` -err genform3a: getvalbyid $2 $name $rowid $tmpd + val=`getvalbyid $2 $name $rowid $td` +err genform3a: getvalbyid $2 $name $rowid $td err genform3b: val="[$val]" fi if [ -n "$GF_VIEWONLY" ]; then @@ -2026,11 +2035,11 @@ case "$type" in text*) cgiform=cgi_multi_$type - if [ -s $tmpd/$name.count ]; then - form=`$cgiform $name $tmpd` + if [ -s $td/$name.count ]; then + form=`$cgiform $name $td` val=$(echo "$val"| while read fn; do - echo "<tr><td>`cat $tmpd/$fn`</td></tr>$nl" + echo "<tr><td>`cat $td/$fn`</td></tr>$nl" done) val="<table>$nl$val$nl</table>" else @@ -2055,19 +2064,20 @@ form="$fh$form</select>" ;; [Ii][Mm][Aa][Gg][Ee]|[Dd][Oo][Cc][Uu][Mm][Ee][Nn][Tt]|[Bb]inary) - if [ -s $tmpd/$name.count ]; then - form=`cgi_multi_file $name $tmpd "$args"` + if [ -s $td/$name.count ]; then + form=`cgi_multi_file $name $td "$args"` if [ -n "$val" ]; then hrfb="$myname?showattc+$2_m" val=$(echo "$val" \ | while read fn; do - data=`percenthex $tmpd/$fn` - #ct=`cat $tmpd/$fn.content-type` - ct=`file --mime-type $tmpd/$fn|cut -d' ' -f2` - ri=`cat $tmpd/$fn.rowid` -## err fn=$fn, name=$name, ri=$ri; ls -lF $tmpd 1>&3 - imgsrc="<img src=\"data:$ct,$data\">" - echo "<a href=\"$hrfb+$ri\">$imgsrc</a><br>" + data=`percenthex $td/$fn` + #ct=`cat $td/$fn.content-type` + ct=`file --mime-type $td/$fn|cut -d' ' -f2` + ri=`cat $td/$fn.rowid` +## err fn=$fn, name=$name, ri=$ri; ls -lF $td 1>&3 + #imgsrc="<img src=\"data:$ct,$data\">" + #echo "<a href=\"$hrfb+$ri\">$imgsrc</a><br>" + iconhref $td/$fn "$hrfb+$ri" "" done) fi else @@ -2075,7 +2085,7 @@ if [ -n "$val" ]; then imgs=$(echo "$val"\ |while read fn;do - data=`percenthex $tmpd/$fn` + data=`percenthex $td/$fn` echo "<img src=\"data:image/png,$data\">$fn<br>" done) form=$form"<br>$imgs" @@ -2176,11 +2186,15 @@ if [ -n "$vcol" ]; then par2table $1 fi - DT_VIEW="edittable+$tbl" dumptable html $tbl "$cols" \ - | m4 -D_TITLE_="$tbl" \ - -D_FORM_="`genform $1`" \ - -D_DUMPTABLE_="syscmd(cat)" \ - $layout/html.m4.html $layout/form+dump.m4.html + ### DT_VIEW="edittable+$tbl" dumptable html $tbl "$cols" \ + ## DT_VIEW="edittable+$tbl" dumptable html $tbl "name memo file" \ + query "select rowid from $tbl order by rowid desc;" \ + | while read rowid; do + viewtable $1 $tbl $rowid + done | m4 -D_TITLE_="$tbl" \ + -D_FORM_="`genform $1`" \ + -D_DUMPTABLE_="syscmd(cat)" \ + $layout/html.m4.html $layout/form+dump.m4.html } showattc() { # $1=table_m $2=rowid $3=val @@ -2193,6 +2207,7 @@ # tmpfiles=$tmpfiles"${tmpfiles+ }$idir" bin=$idir/$myname-$$.bin sql="select quote(bin) from $1 where rowid='$2';" +err showattc: sql: $sql sq $db "$sql" | unhexize > $bin tv=`query "select type,val from $1 where rowid='$2';"` type=${tv%\|*} fn=${tv#*\|}