s4
changeset 3:95cebd686c97
add templ/*
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 18 Jul 2015 23:44:21 +0900 |
parents | 7aa52f9874ae |
children | 6822f4362bf9 |
files | se-blog.sh se-funcs.sh |
diffstat | 2 files changed, 46 insertions(+), 43 deletions(-) [+] |
line diff
1.1 --- a/se-blog.sh Sat Jul 18 09:54:00 2015 +0900 1.2 +++ b/se-blog.sh Sat Jul 18 23:44:21 2015 +0900 1.3 @@ -340,7 +340,6 @@ 1.4 -D_DUMPTABLE_="`listblog $listing`" \ 1.5 $layout/html.m4.html \ 1.6 $layout/diary.m4.html 1.7 - 1.8 } 1.9 1.10 blog_reply() {
2.1 --- a/se-funcs.sh Sat Jul 18 09:54:00 2015 +0900 2.2 +++ b/se-funcs.sh Sat Jul 18 23:44:21 2015 +0900 2.3 @@ -4,19 +4,21 @@ 2.4 myname=`basename ${SCRIPT_NAME:-$0}` 2.5 mydir=`dirname ${SCRIPT_FILENAME:-$0}` 2.6 myargs="$@" 2.7 -bindir=`(cd $mydir/bin; pwd)` 2.8 -PATH=/usr/local/sqlite3/bin:$PATH:$bindir 2.9 +#bindir=`(cd $mydir/bin; pwd)` 2.10 +# :$bindir 2.11 +PATH=/usr/local/sqlite3/bin:/usr/local/vim7/bin:/usr/local/ImageMagick/bin:$PATH 2.12 tmpdir=${TMPDIR:-tmp} 2.13 dbdir=${DBDIR:-db} 2.14 tmpfiles="" 2.15 db=${DB:-$dbdir/cgi.sq3} 2.16 admin=wwwadmin@gentei.org 2.17 -layout=templ/default 2.18 -formdir=templ/form 2.19 +templ=${TEMPL:-templ} 2.20 +layout=$templ/default 2.21 +formdir=$templ/form 2.22 imgdir=img 2.23 url=${URL:-"${REQUEST_SCHEME}://$HTTP_HOST$REQUEST_URI"} 2.24 urlbase=${url%%\?*} 2.25 -msg=templ/msg 2.26 +msg=$templ/msg 2.27 timeout="+2 days" 2.28 conftbl=_tblconf 2.29 dumpcollen=20 2.30 @@ -295,10 +297,14 @@ 2.31 cat $sqo 2.32 } 2.33 exec 3>> $tmpdir/debug.out 2.34 +exec 2>> $tmpdir/error.out 2.35 err() { 2.36 echo "$@" 1>&3 2.37 } 2.38 2.39 +_m4() { 2.40 + 2.41 +} 2.42 ismember() { 2.43 # $1=user, $2=group 2.44 err ismem: "select user from grp_mem where gname='$2' and user='$1';" 2.45 @@ -488,11 +494,10 @@ 2.46 vcount=1 # count(val) 2.47 if [ x"$2" = x"$c" ]; then 2.48 cond="$t where $pk=\"$key\" and key=\"$c\"" 2.49 - #####val=`query "select val from $cond;"` 2.50 - val=`query "select val from $cond;"` 2.51 - ##type=`sq $db "select type from $cond"` 2.52 - type=`query "select type from $cond;"` 2.53 -##err sq $db "select val from $cond" 2.54 + ###val=`query "select val from $cond;"` 2.55 + val=`query "select val from $cond limit 1;"` 2.56 + ###type=`query "select type from $cond;"` 2.57 + type=`query "select type from $cond limit 1;"` 2.58 if [ $kt = m ]; then 2.59 ###vcount=`sq $db "select count(val) from $cond"` 2.60 # Reset val to store filenames if type is string 2.61 @@ -504,12 +509,12 @@ 2.62 slice="order by rowid limit 1 offset $i" 2.63 i=$((i+1)) 2.64 fn=$c.$i 2.65 -### err td=$td, fn=$fn, type=$type, val="[$val]" 2.66 +##err td=$td, fn=$fn, type=$type, val="[$val]" 2.67 case $type in 2.68 file:*) 2.69 #file=$td/$val 2.70 file=$td/`query "select val from $cond $slice;"` 2.71 - [ -s $file -a -s $td/$fn.rowid ] && continue 2.72 +####tmp [ -s $file -a -s $td/$fn.rowid ] && continue 2.73 sq $db<<EOF | xxd -r -p > $file 2.74 .output $td/$fn.rowid 2.75 select rowid from $cond $slice; 2.76 @@ -520,7 +525,7 @@ 2.77 .output stdout 2.78 select quote(bin) from $cond $slice; 2.79 EOF 2.80 - ##err i=$((i+1)) - file=$file rowid=`cat $td/$fn.rowid` 2.81 + ## err i=$i - file=$file rowid=`cat $td/$fn.rowid` 2.82 ln $td/$fn.rowid $file.rowid 2>&3 # for convenience 2.83 case $type in 2.84 *:[Ii]mage*) mogrify -geometry $thumbxy $file ;; 2.85 @@ -768,11 +773,11 @@ 2.86 fi 2.87 ) 2.88 } 2.89 -expire() { 2.90 - (at="${1:-$timeout}" 2.91 - FMT="${2:-%F %T}" 2.92 - TZ=GMT date -d "$at" +"$FMT") 2.93 -} 2.94 +expire() ( 2.95 + at="${1:-$timeout}" 2.96 + FMT="${2:-%F %T}" 2.97 + TZ=GMT date -d "$at" +"$FMT" 2.98 +) 2.99 addsession() { 2.100 # expireをセット 2.101 # loginの先にどの画面に行くかの状態遷移表書式を決める 2.102 @@ -783,12 +788,12 @@ 2.103 now=`expire now` 2.104 sq $db "delete from session where expire < '$now'" 2.105 } 2.106 -gencookie() { 2.107 - (for kv; do 2.108 - expire="`expire '' '%a, %d-%b-%Y %H:%M:%S GMT'`" 2.109 - echo "Set-Cookie: $kv; expires=$expire" 2.110 - done) 2.111 -} 2.112 +gencookie() ( 2.113 + for kv; do 2.114 + expire="`expire '' '%a, %d-%b-%Y %H:%M:%S GMT'`" 2.115 + echo "Set-Cookie: $kv; expires=$expire" 2.116 + done 2.117 +) 2.118 contenttype() { 2.119 echo "Content-type: ${1:-text/html; charset=utf-8}" 2.120 contenttype() {} # Only need to work once 2.121 @@ -799,17 +804,16 @@ 2.122 putfooter() { 2.123 m4 -D_TITLE_="${TITLE:-$myname}" $layout/footer.m4.html 2.124 } 2.125 -getcookie() { 2.126 +getcookie() ( 2.127 for kv in `echo $HTTP_COOKIE|sed 's/[;, ]/ /g'`; do 2.128 k="${kv%%=*}" 2.129 v="`echo ${kv#*=}|nkf -Ww -mQ|sed -e 's/\"/\"\"/g'`" 2.130 - sq $db "replace into cookie values('$session', '$k', 'string', \"$v\")" 2.131 + query "replace into cookie values('$session', '$k', 'string', \"$v\");" 2.132 done 2.133 -} 2.134 +) 2.135 genrandom() { 2.136 # $1=columns (default: 10) 2.137 - col=${1:-10} 2.138 - dd if=/dev/urandom count=1 2>/dev/null|nkf -MB|fold -w$col|sed -n 10p 2.139 + dd if=/dev/urandom count=1 2>/dev/null|nkf -MB|fold -w${1:-10}|sed -n 10p 2.140 } 2.141 smail() { 2.142 # smail rcpt subj (file) 2.143 @@ -831,12 +835,11 @@ 2.144 done 2.145 IFS="$oifs" 2.146 } 2.147 -checkdomain() { 2.148 - # Check the validity of domain by referring DNS 2.149 - (item=$1 2.150 - host ${item#@*} >/dev/null 2>&1 2.151 - ) 2.152 -} 2.153 +checkdomain() ( 2.154 + # Check the validity of domain by referring DNS 2.155 + item=$1 2.156 + host ${item#@*} >/dev/null 2>&1 2.157 +) 2.158 pwcheck() { 2.159 # $1=passwd 2.160 dbpswd=`getpwfield $user pswd` 2.161 @@ -1075,11 +1078,12 @@ 2.162 <a href=\"?blog\">新規話題の作成</a>" 2.163 fi 2.164 . ./se-blog.sh 2.165 - m4 -D_BODYCLASS_=home -D_TITLE_="$gecos さん" \ 2.166 - -D_PROFILE_="`viewtable $formdir/user.def user $1`$conflink" \ 2.167 - -D_BLOGS_="`listblog $uname`" \ 2.168 - -D_GROUPS_="`listgroupbytable $formdir/grp.def $cond`" \ 2.169 - $layout/html.m4.html $layout/home.m4.html 2.170 + 2.171 + m4 -D_BODYCLASS_=home -D_TITLE_="$gecos さん" \ 2.172 + -D_PROFILE_="`viewtable $formdir/user.def user $1`$conflink" \ 2.173 + -D_BLOGS_="`listblog $uname`" \ 2.174 + -D_GROUPS_="`listgroupbytable $formdir/grp.def $cond`" \ 2.175 + $layout/html.m4.html $layout/home.m4.html 2.176 2.177 # 2.178 # Record access log 2.179 @@ -1111,8 +1115,8 @@ 2.180 iconhref() ( 2.181 # $1=icon-file, $2=Href $3=title $4...=anchor 2.182 data=`percenthex $1` 2.183 - ct=`file --mime-type $1` 2.184 -err \$3="$@" 2.185 + ct=`file --mime-type $1|cut -d' ' -f2` 2.186 +err iconhref: \$1=$1 \$2=$2 \$3="$@" 2.187 href=$2; title=$3; shift 3 2.188 echo "<a href=\"$href\"><img title=\"$title\" src=\"data:$ct,$data\">$@</a>" 2.189 )