s4
changeset 2:7aa52f9874ae
.hgignore added
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 18 Jul 2015 09:54:00 +0900 |
parents | 5bafa0d981e0 |
children | 95cebd686c97 |
files | .hgignore se-blog.sh se-funcs.sh |
diffstat | 3 files changed, 79 insertions(+), 20 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/.hgignore Sat Jul 18 09:54:00 2015 +0900 1.3 @@ -0,0 +1,2 @@ 1.4 +syntax: glob 1.5 +*
2.1 --- a/se-blog.sh Thu Jul 16 23:03:51 2015 +0900 2.2 +++ b/se-blog.sh Sat Jul 18 09:54:00 2015 +0900 2.3 @@ -47,7 +47,7 @@ 2.4 # blog_m: *article 2.5 2.6 err "SELECT id from $tbl where rowid=$rowid" 2.7 - id=`sq $db "select id from $tbl where rowid=$rowid"` 2.8 + id=`query "select id from $tbl where rowid=$rowid;"` 2.9 err id=$id 2.10 err "select val from $ts where key='title' and id='$id';" 2.11 2.12 @@ -60,11 +60,14 @@ 2.13 2.14 href="<a href=\"?editheading+$rowid\"> 編集 </a>" 2.15 href2="<a href=\"?lshandout+$rowid\"> 提出状況 </a>" 2.16 + href3="(<a href=\"?gethandout+$rowid\">ファイル取得</a>)" 2.17 cat<<EOF | sq -html $db \ 2.18 | sed -e "s|\(<TR><TD>\),e,|\1 $href |" \ 2.19 - -e "s|,s,\(</TD>\)|$href2\1|" 2.20 + -e "s|,s,\(</TD>\)|$href2$href3\1|" 2.21 -- select val from $ts where key="title" and id="$id"; 2.22 -select ",e,"||val||" " 2.23 +select 2.24 + coalesce((select ",e," from blog where rowid=$rowid and author='$user'),'') 2.25 +||val||" " 2.26 ||case (select val from $ts where key="mode" and id="$id") 2.27 when 'report-closed' then "レポート提出用(自身のファイルのみ参照可),s," 2.28 when 'report-open' then "レポート提出用,s," 2.29 @@ -117,11 +120,10 @@ 2.30 arts=`query "select rowid,id,author from $at where blogid='$id';"` 2.31 err arts="[$arts]" 2.32 number=0 2.33 + hrefhome0="<a href=\"?home" 2.34 for a in $arts; do 2.35 arid=${a%%|*} aid=`echo "$a"|cut -d'|' -f2` author=${a##*|} imgs="" 2.36 ### err a=$a, aid=$aid, author=$author 2.37 - getgecos="coalesce((select val from user_s \ 2.38 - where name='$author' and key='gecos'), '$author')" 2.39 # name='' # Get gecos?? 2.40 td=$(echo $tmpd/`echo $a|md5`) 2.41 val=`getvalbyid article image $arid $td` 2.42 @@ -151,12 +153,17 @@ 2.43 ### number=$((number+1)) 2.44 # reply="<input type=\"radio\" name=\"parent\" class=\"replybtn\" \ 2.45 # value=\"$number\">" 2.46 + getgecos="(select rowid from user where name='$author')||':'||\ 2.47 + coalesce((select val from user_s \ 2.48 + where name='$author' and key='gecos'), '$author')||',[/a],'" 2.49 href="$myname?editart+$arid+$rowid" 2.50 link="<a href=\"$href\">編集</a>" 2.51 cat<<EOF | sq -html $db \ 2.52 - | sed -e 's/,n,/<br>/g' -e "s|,i,|$imgs|" \ 2.53 + | sed -e "s|,n,\([0-9]*\):|,n,$hrefhome0+\1\">|" \ 2.54 + -e 's|,\[/a\],|</a>|' \ 2.55 + -e 's/,n,/<br>/g' -e "s|,i,|$imgs|" \ 2.56 -e "s|<TR>\(<TD>\)|<TR id=\"$aid\">\1|" \ 2.57 - -e "s|\(<TR.*>\)\(<TD>\),e,|\1\2 $link|" 2.58 + -e "s|\(<TR.*>\)\(<TD>\),e,|\1\2$link|" 2.59 select 2.60 coalesce((select ",e," from article where id='$aid' and author='$user'),"") 2.61 || 2.62 @@ -191,15 +198,22 @@ 2.63 time=`getvalbyid blog ctime $1|colrm 11` 2.64 owner=`getvalbyid blog owner $1` 2.65 title=`getvalbyid blog title $1` 2.66 + ge=`gecos $owner` 2.67 lshandoutsub $owner "$@" \ 2.68 |m4 -D_TITLE_="提出状況" \ 2.69 - -D_SUBTITLE_="$time [$title]@$owner" -D_DIARY_="" \ 2.70 - -D_FORM_="include(/dev/stdin)" -D_BLOGS_= -D_DUMPTABLE_= \ 2.71 + -D_SUBTITLE_="$time [$title]@${ge:-$owner}" -D_DIARY_="" \ 2.72 + -D_FORM_="syscmd(cat)" -D_BLOGS_= -D_DUMPTABLE_= \ 2.73 $layout/html.m4.html $layout/diary.m4.html 2.74 } 2.75 lshandoutsub() { 2.76 # $1=owner $2=rowid of blog 2.77 - sql="with arts as (select id,author from article \ 2.78 + if isgroup $1; then 2.79 + sample="(select user from grp_mem where gname='$1')" 2.80 + else 2.81 + sample="(select distinct author as user from arts)" 2.82 + echo "<p>(集計は板への投稿者のみ)</p>" 2.83 + fi 2.84 + sql="with arts as (select id,author from article \ 2.85 where blogid=(select id from blog where rowid=$2))\ 2.86 select (select rowid from user where name=c0.user)||' '|| \ 2.87 coalesce((select val from user_s where name=c0.user \ 2.88 @@ -209,7 +223,7 @@ 2.89 as 'コメント記入',\ 2.90 sum(case when c2.key is not null then 1 else 0 end)\ 2.91 as 'ファイルの提出'\ 2.92 - from (select user from grp_mem where gname='$owner') c0\ 2.93 + from $sample c0 \ 2.94 left join (select id,author from arts) a\ 2.95 on c0.user=a.author\ 2.96 left join (select id,key from article_s where key='text') c1\ 2.97 @@ -222,6 +236,40 @@ 2.98 | sed -e "s,\(<TR><TD>\)\([^ ]*\) \(.*\)</TD>,\1$hrb\2\">\3</TD>," -e 's,<TD>0</TD>,<TD class="warn">0</TD>,' 2.99 echo '</table>' 2.100 } 2.101 +gethandout() { 2.102 + # $1=rowid of blog 2.103 + i=0 2.104 + bd=$tmpd/archive.$$ 2.105 + mkdir $bd 2.106 + query "select m.rowid,author,m.val from article a join article_m m\ 2.107 + on a.id=m.id where blogid=(select id from blog where rowid=$1)\ 2.108 + and m.key in ('image', 'document', 'binary');" \ 2.109 + | while IFS='|' read rowid author filename; do 2.110 + # err isfilereadable $user article_m $1 2.111 + isfilereadable $user article_m $1 || continue 2.112 + err ok 2.113 + i=$((i+1)) 2.114 + dir=`printf $bd/%03d $i` 2.115 + mkdir $dir 2.116 + query "select quote(bin) from article_m where rowid=$rowid;" \ 2.117 + | xxd -r -p > $dir/$filename 2.118 + done 2.119 + if [ ! -d $bd/001 ]; then 2.120 + contenttype; echo 2.121 + echo "<p>取得できるファイルがありませんでした。</p>" 2.122 + return 2.123 + fi 2.124 + (cd $bd 2.125 + err cdto$bd; (pwd; ls -lFa) 1>&3 2.126 + tar zcf .archive.tar.gz * && mv .archive.tar.gz archive.tar.gz 2.127 + ) 2.128 + arc=$bd/archive.tar.gz 2.129 + echo "Content-type: application/x-gzip" 2.130 + echo "Content-Length: `cat $arc|wc -c`" 2.131 + echo "Content-Disposition: filename=\"archive.tar.gz\"" 2.132 + echo 2.133 + cat $arc 2.134 +} 2.135 2.136 listblog() ( 2.137 # $1=user
3.1 --- a/se-funcs.sh Thu Jul 16 23:03:51 2015 +0900 3.2 +++ b/se-funcs.sh Sat Jul 18 09:54:00 2015 +0900 3.3 @@ -7,8 +7,9 @@ 3.4 bindir=`(cd $mydir/bin; pwd)` 3.5 PATH=/usr/local/sqlite3/bin:$PATH:$bindir 3.6 tmpdir=${TMPDIR:-tmp} 3.7 +dbdir=${DBDIR:-db} 3.8 tmpfiles="" 3.9 -db=${DB:-$tmpdir/cgi.sq3} 3.10 +db=${DB:-$dbdir/cgi.sq3} 3.11 admin=wwwadmin@gentei.org 3.12 layout=templ/default 3.13 formdir=templ/form 3.14 @@ -36,10 +37,12 @@ 3.15 グループへの一斉送信機能は付いたが表に出てない(7/6) 3.16 ひとつのarticleをheadingにして新規ツリーを作成、あるといいかも。 3.17 3.18 -7/17 個人blogに「レポート提出用」がついたとき 3.19 +7/18 ○書込著者からホームへのリンク 3.20 + 締切設定 3.21 一斉送信 3.22 - 添付ファイル回収 3.23 - imgcacheは別ディレクトリにしないと + .htaccess 3.24 +7/17 ○個人blogに「レポート提出用」がついたときの挙動 3.25 + ○添付ファイル回収 3.26 + ○imgcacheは別ディレクトリにしないと + .htaccess 3.27 7/15 ○レポート提出モードの表示を付ける 3.28 管理者権限での削除? → まだいいか 3.29 3.30 @@ -372,8 +375,14 @@ 3.31 } 3.32 gecos() ( 3.33 u=${1:-$user} 3.34 - gecos=`query "select val from user_s where name='$u' and key='gecos';"` 3.35 - echo "${gecos:-$u}" 3.36 + #gecos=`query "select val from user_s where name='$u' and key='gecos';"` 3.37 + sql="select case when (select name from user where name='$u') is not null 3.38 + then (select val from user_s where name='$u' and key='gecos') 3.39 + when (select gname from grp where gname='$u') is not null 3.40 + then (select val from grp_s where gname='$u' and key='gecos') 3.41 + else '$u' 3.42 + end;" 3.43 + query "$sql" 3.44 ) 3.45 getpar() { 3.46 err getpar: "select val from par where var='$1' and sessid='$session' $2;" 3.47 @@ -545,7 +554,7 @@ 3.48 query "select quote(bin) from $cond and val=\"$fn\";" \ 3.49 | xxd -r -p > $file 3.50 echo ${type#file:} > $file.content-type 3.51 -err TTTTTTTTTTTTTTTT: $type 3.52 +# err TTTTTTTTTTTTTTTT: $type 3.53 case $type in 3.54 *:[Ii]mage*) mogrify -geometry $thumbxy $file ;; 3.55 *:[Aa]pplication*) 3.56 @@ -932,7 +941,7 @@ 3.57 type='file'; k=${k%:filename} 3.58 case `file --mime-type $tmpdir/$v|cut -d' ' -f2` in 3.59 [Ii]mage/*) 3.60 - mogrify -resize $maximagexy $tmpdir/$v 3.61 + mogrify -resize $maximagexy'>' $tmpdir/$v 3.62 ;; 3.63 esac 3.64 ;; 3.65 @@ -1391,7 +1400,7 @@ 3.66 fi 3.67 tbl=${1%.def} 3.68 tbl=${tbl##*/} 3.69 - if [ -n "$rowid" ]; then 3.70 + if [ -n "$rowid" ]; then # Modify existing entry 3.71 if [ x"$tbl" = x"user" ]; then 3.72 rowowner=`query "select name from $tbl where rowid=$rowid;"` 3.73 elif [ x"$tbl" = x"grp" ]; then