diff s4-funcs.sh @ 67:3b70f847277e

Rearrangement
author HIROSE Yuuji <yuuji@gentei.org>
date Fri, 31 Jul 2015 10:04:14 +0900
parents 3229b05617a3
children 7380bcf19078
line wrap: on
line diff
--- a/s4-funcs.sh	Thu Jul 30 11:13:53 2015 +0900
+++ b/s4-funcs.sh	Fri Jul 31 10:04:14 2015 +0900
@@ -14,17 +14,17 @@
 dbdir=${DBDIR:-db}
 tmpfiles=""
 db=${DB:-$dbdir/cgi.sq3}
-admin=wwwadmin@gentei.org
+admin=${ADMIN:-wwwadmin@gentei.org}
 templ=${TEMPL:-templ}
-layout=$templ/default
-formdir=$templ/form
-imgdir=img
+layout=${LAYOUT:-$templ/default}
+formdir=${FORMDIR:-$templ/form}
+imgdir=${IMGDIR:-img}
 url=${URL:-"${REQUEST_SCHEME:-http${HTTPS:+s}}://$HTTP_HOST$REQUEST_URI"}
 urlbase=${url%%\?*}
 msg=$templ/msg
 timeout="+2 days"
 dumpcollen=20
-thumbxy=120x120
+#thumbxy=120x120
 thumbxy=96x96
 maximagexy=1600x1600
 ### maximagexy=400x400
@@ -289,13 +289,6 @@
   # ./args.rb -cmd ".timeout 3000" "$@"
   sqlite3 -cmd 'PRAGMA foreign_keys=ON' -cmd ".timeout 3000" "$@"
 }
-####XXXXXXXXXXXXXXXXXXXXXX 場所移動
-sqi=/tmp/sqi.$$
-sqo=/tmp/sqo.$$
-mkfifo $sqi $sqo
-tail -f $sqi | sq $db &
-sq3pid="`jobs -p` $!"
-
 query() {
   cat<<EOF > $sqi
 .once $sqo
@@ -303,11 +296,6 @@
 EOF
   cat $sqo
 }
-exec 3>> $tmpdir/debug.out
-exec 2>> $tmpdir/error.out
-err() {
-  echo "$@" 1>&3
-}
 
 _m4() {
   
@@ -488,7 +476,7 @@
     stamp|datetime)
       date "+%F %T" ;;
     serial)
-      (s=`getpar serial`
+      (s=`getpar $2`
        if [ -n "$s" ]; then echo $s; else echo "`date +%s`x$$"; fi) ;;
     *)
       getpar "$2" "$3";;
@@ -966,6 +954,18 @@
     showlogin			# and EXIT
   fi
 }
+
+# Do instant jobs here
+
+[ -d $tmpdir ] || mkdir -m 1777 $tmpdir
+[ -d $dbdir ] || mkdir -m 1775 $dbdir
+sqi=$tmpdir/sqi.$$
+sqo=$tmpdir/sqo.$$
+mkfifo $sqi $sqo
+tail -f $sqi | sq $db &
+sq3pid="`jobs -p` $!"
+exec 2>> $tmpdir/error.out
+exec 3>> $tmpdir/debug.out
 cleanup() {
   echo .quit > $sqi
   kill $sq3pid
@@ -973,6 +973,10 @@
   rm -f $sqo $sqi
   rm -rf $tmpfiles
 }
+err() {
+  echo "$@" 1>&3
+}
+
 trap cleanup INT HUP EXIT
 # trap cleanup INT HUP
 cgiinit() {
@@ -1386,7 +1390,7 @@
 	 m4 -D_TITLE_="グループ $grp" \
 	    -D_FORM_="syscmd(\`cat')" \
 	    -D_DUMPTABLE_="" \
-	    $layout/groupman.m4.html
+	    $layout/form+dump.m4.html
   else				# if $grp is removed at par2table
     listgroup
   fi
@@ -1559,7 +1563,7 @@
 	| m4 -D_TITLE_="グループ[$grp]参加メンバーに対する操作" \
 	     -D_SUBTITLE_="チェック後操作ボタン" \
 	     -D_FORM_="syscmd(cat)" -D_DUMPTABLE_="" \
-	     $layout/groupman.m4.html
+	     $layout/form+dump.m4.html
 <div class="fold">
 `cgi_radio rm send id="sendmsg"`<label
  for="sendmsg">下でチェックした人にメッセージを送信する</label>
@@ -2108,7 +2112,9 @@
 	;;
       [Ss][Ee][Rr][Ii][Aa][Ll]|[Ss][Tt][Aa][Mm][Pp])
 	val=$((($(date +%s)-1433084400)/10))c$$
-	form="<input type=\"hidden\" name=\"serial\" value=\"$val\">"
+##	form="<input type=\"hidden\" name=\"serial\" value=\"$val\">"
+##	2015-07-31
+	form="<input type=\"hidden\" name=\"$name\" value=\"$val\">"
 	prompt="" ;;
       [Ss][Ee][Ss][Ss][Ii][Oo][Nn])
 	prompt=""
@@ -2159,3 +2165,19 @@
 viewtable() {
   GF_VIEWONLY=1 genform "$@"
 }
+default0() {	# $1=def-file
+  tbl=`basename $1`
+  tbl=${tbl%.def}
+  cols="`grep :text $1|cut -d: -f2`"
+  col=`echo "$cols"|head -1`
+  vcol=`getpar $col`
+  err default0: \$1=$1 col=$col cols="[$cols]" vcol=$vcol
+  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
+}

yatex.org