changeset 69:d10f98c2b192

form+dump
author HIROSE Yuuji <yuuji@gentei.org>
date Fri, 31 Jul 2015 16:15:31 +0900
parents 7380bcf19078
children 7882917ecd33
files s4-blog.sh s4-funcs.sh s4.cgi
diffstat 3 files changed, 65 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/s4-blog.sh	Fri Jul 31 10:35:04 2015 +0900
+++ b/s4-blog.sh	Fri Jul 31 16:15:31 2015 +0900
@@ -44,15 +44,16 @@
 )
 blog_showentry() {
   # $1=table $2=rowid
-  if [ -n "$2" ]; then
-    if [ -n "$imgcached" ]; then
-      bstmpdir=$tmpdir/$imgcached/$thumbxy
-    else
-      bstmpdir=$tmpd
-      # tmpd=`mktempd`
-      # tmpfiles=$tmpfiles" $tmpd"
-    fi
-  fi
+  # if [ -n "$2" ]; then
+  #   if [ -n "$imgcached" ]; then
+  #     bstmpdir=$tmpdir/$imgcached/$thumbxy
+  #   else
+  #     bstmpdir=$tmpd
+  #     # tmpd=`mktempd`
+  #     # tmpfiles=$tmpfiles" $tmpd"
+  #   fi
+  # fi
+  td=`getcachedir article`
   tbl=${1%%[!A-Z0-9a-z_]*} rowid=${2%%[!A-Z0-9a-z_]*}
 err rowid=$rowid, '$2'=$2
   ts=${tbl}_s tm=${tbl}_m
@@ -145,25 +146,24 @@
     arid=${a%%\|*} aid=`echo "$a"|cut -d'|' -f2` author=${a##*\|} imgs=""
 err a=$a, aid=$aid, author=$author
     # name=''	# Get gecos??
-    td=$(echo $bstmpdir/`echo $a|md5`)
+    # td=$(echo $bstmpdir/`echo $at|md5`)
+err td=$td
     val=`getvalbyid article image "$arid" "$td"`
-err val="[$val]" and td as follows:
+    err val="[$val]" and td as follows:
     
-    if true; then
-      if [ -n "$val" ]; then
-	hrfb="$myname?showattc+article_m"
-	imgs="<br>"$(echo "$val"\
-		    |while read fn; do
+    if [ -n "$val" ]; then
+      hrfb="$myname?showattc+article_m"
+      imgs="<br>"$(echo "$val"\
+			|while read fn; do
 
-		       #data=`percenthex $td/$fn`
-		       #ct=`cat $td/$fn.content-type`
-		       sz=`cat $td/$fn.size`
-		       ri=`cat $td/$fn.rowid`
-err fn=$fn ct=$ct ri=$ri; ls -lF $td/ 1>&3
-			iconhref $td/$fn "$hrfb+$ri" "$fn" "$fn($sz)"
-		     done)
-	imgs=`echo "$imgs"|tr -d '\n'`	# kill newlines for sed
-      fi
+			   #data=`percenthex $td/$fn`
+			   #ct=`cat $td/$fn.content-type`
+			   sz=`cat $td/$fn.size`
+			   ri=`cat $td/$fn.rowid`
+	  err fn=$fn ct=$ct ri=$ri ls::: "`ls -lF $td/`"
+			   iconhref $td/$fn "$hrfb+$ri" "$fn" "$fn($sz)"
+			 done)
+      imgs=`echo "$imgs"|tr -d '\n'`	# kill newlines for sed
     fi
 
     ### number=$((number+1))
--- 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#*\|}
--- a/s4.cgi	Fri Jul 31 10:35:04 2015 +0900
+++ b/s4.cgi	Fri Jul 31 16:15:31 2015 +0900
@@ -77,7 +77,7 @@
     m4 -D_TITLE_="グループ作成" \
        -D_FORM_="$note`genform $formdir/grp.def`" \
        -D_DUMPTABLE_="`DT_VIEW=grp dumptable html grp 'gname gecos:DESC mtime:TIME' 'order by b.TIME desc'`" \
-       $layout/html.m4.html $layout/groupman.m4.html
+       $layout/html.m4.html $layout/form+dump.m4.html
     ;;
   "edittable")
     contenttype; echo
@@ -108,7 +108,7 @@
 	| m4 -D_DUMPTABLE_="syscmd(\`cat')" \
 	     -D_TITLE_="グループ関連操作" \
 	     -D_FORM_="<a href=\"?groupman\">新規グループ作成</a>" \
-	     $layout/groupman.m4.html
+	     $layout/form+dump.m4.html
 	
     ;;
   "grps2")
@@ -116,7 +116,7 @@
     m4 -D_TITLE_="グループ一覧" \
        -D_FORM_="`listgroup2 $formdir/grp.def`" -D_DUMPTABLE_= \
        $layout/html.m4.html \
-       $layout/groupman.m4.html
+       $layout/form+dump-whead.m4.html
     ;;
   "grp") # $2=group-rowid
     contenttype; echo

yatex.org