diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..a9b6ef7 --- /dev/null +++ b/.hgignore @@ -0,0 +1,2 @@ +syntax: glob +* diff --git a/se-blog.sh b/se-blog.sh index 7512994..435ae46 100644 --- a/se-blog.sh +++ b/se-blog.sh @@ -47,7 +47,7 @@ # blog_m: *article err "SELECT id from $tbl where rowid=$rowid" - id=`sq $db "select id from $tbl where rowid=$rowid"` + id=`query "select id from $tbl where rowid=$rowid;"` err id=$id err "select val from $ts where key='title' and id='$id';" @@ -60,11 +60,14 @@ href=" 編集 " href2=" 提出状況 " + href3="(ファイル取得)" cat<\),e,|\1 $href |" \ - -e "s|,s,\(\)|$href2\1|" + -e "s|,s,\(\)|$href2$href3\1|" -- select val from $ts where key="title" and id="$id"; -select ",e,"||val||" " +select + coalesce((select ",e," from blog where rowid=$rowid and author='$user'),'') +||val||" " ||case (select val from $ts where key="mode" and id="$id") when 'report-closed' then "レポート提出用(自身のファイルのみ参照可),s," when 'report-open' then "レポート提出用,s," @@ -117,11 +120,10 @@ arts=`query "select rowid,id,author from $at where blogid='$id';"` err arts="[$arts]" number=0 + hrefhome0="" + getgecos="(select rowid from user where name='$author')||':'||\ + coalesce((select val from user_s \ + where name='$author' and key='gecos'), '$author')||',[/a],'" href="$myname?editart+$arid+$rowid" link="編集" cat</g' -e "s|,i,|$imgs|" \ + | sed -e "s|,n,\([0-9]*\):|,n,$hrefhome0+\1\">|" \ + -e 's|,\[/a\],||' \ + -e 's/,n,/
/g' -e "s|,i,|$imgs|" \ -e "s|\(\)|\1|" \ - -e "s|\(\)\(\),e,|\1\2 $link|" + -e "s|\(\)\(\),e,|\1\2$link|" select coalesce((select ",e," from article where id='$aid' and author='$user'),"") || @@ -191,15 +198,22 @@ time=`getvalbyid blog ctime $1|colrm 11` owner=`getvalbyid blog owner $1` title=`getvalbyid blog title $1` + ge=`gecos $owner` lshandoutsub $owner "$@" \ |m4 -D_TITLE_="提出状況" \ - -D_SUBTITLE_="$time [$title]@$owner" -D_DIARY_="" \ - -D_FORM_="include(/dev/stdin)" -D_BLOGS_= -D_DUMPTABLE_= \ + -D_SUBTITLE_="$time [$title]@${ge:-$owner}" -D_DIARY_="" \ + -D_FORM_="syscmd(cat)" -D_BLOGS_= -D_DUMPTABLE_= \ $layout/html.m4.html $layout/diary.m4.html } lshandoutsub() { # $1=owner $2=rowid of blog - sql="with arts as (select id,author from article \ + if isgroup $1; then + sample="(select user from grp_mem where gname='$1')" + else + sample="(select distinct author as user from arts)" + echo "

(集計は板への投稿者のみ)

" + fi + sql="with arts as (select id,author from article \ where blogid=(select id from blog where rowid=$2))\ select (select rowid from user where name=c0.user)||' '|| \ coalesce((select val from user_s where name=c0.user \ @@ -209,7 +223,7 @@ as 'コメント記入',\ sum(case when c2.key is not null then 1 else 0 end)\ as 'ファイルの提出'\ - from (select user from grp_mem where gname='$owner') c0\ + from $sample c0 \ left join (select id,author from arts) a\ on c0.user=a.author\ left join (select id,key from article_s where key='text') c1\ @@ -222,6 +236,40 @@ | sed -e "s,\(\)\([^ ]*\) \(.*\),\1$hrb\2\">\3," -e 's,0,0,' echo '' } +gethandout() { + # $1=rowid of blog + i=0 + bd=$tmpd/archive.$$ + mkdir $bd + query "select m.rowid,author,m.val from article a join article_m m\ + on a.id=m.id where blogid=(select id from blog where rowid=$1)\ + and m.key in ('image', 'document', 'binary');" \ + | while IFS='|' read rowid author filename; do + # err isfilereadable $user article_m $1 + isfilereadable $user article_m $1 || continue + err ok + i=$((i+1)) + dir=`printf $bd/%03d $i` + mkdir $dir + query "select quote(bin) from article_m where rowid=$rowid;" \ + | xxd -r -p > $dir/$filename + done + if [ ! -d $bd/001 ]; then + contenttype; echo + echo "

取得できるファイルがありませんでした。

" + return + fi + (cd $bd + err cdto$bd; (pwd; ls -lFa) 1>&3 + tar zcf .archive.tar.gz * && mv .archive.tar.gz archive.tar.gz + ) + arc=$bd/archive.tar.gz + echo "Content-type: application/x-gzip" + echo "Content-Length: `cat $arc|wc -c`" + echo "Content-Disposition: filename=\"archive.tar.gz\"" + echo + cat $arc +} listblog() ( # $1=user diff --git a/se-funcs.sh b/se-funcs.sh index 8ce0ec7..eb91f96 100755 --- a/se-funcs.sh +++ b/se-funcs.sh @@ -7,8 +7,9 @@ bindir=`(cd $mydir/bin; pwd)` PATH=/usr/local/sqlite3/bin:$PATH:$bindir tmpdir=${TMPDIR:-tmp} +dbdir=${DBDIR:-db} tmpfiles="" -db=${DB:-$tmpdir/cgi.sq3} +db=${DB:-$dbdir/cgi.sq3} admin=wwwadmin@gentei.org layout=templ/default formdir=templ/form @@ -36,10 +37,12 @@ グループへの一斉送信機能は付いたが表に出てない(7/6) ひとつのarticleをheadingにして新規ツリーを作成、あるといいかも。 -7/17 個人blogに「レポート提出用」がついたとき +7/18 ○書込著者からホームへのリンク + 締切設定 一斉送信 - 添付ファイル回収 - imgcacheは別ディレクトリにしないと + .htaccess +7/17 ○個人blogに「レポート提出用」がついたときの挙動 + ○添付ファイル回収 + ○imgcacheは別ディレクトリにしないと + .htaccess 7/15 ○レポート提出モードの表示を付ける 管理者権限での削除? → まだいいか @@ -372,8 +375,14 @@ } gecos() ( u=${1:-$user} - gecos=`query "select val from user_s where name='$u' and key='gecos';"` - echo "${gecos:-$u}" + #gecos=`query "select val from user_s where name='$u' and key='gecos';"` + sql="select case when (select name from user where name='$u') is not null + then (select val from user_s where name='$u' and key='gecos') + when (select gname from grp where gname='$u') is not null + then (select val from grp_s where gname='$u' and key='gecos') + else '$u' + end;" + query "$sql" ) getpar() { err getpar: "select val from par where var='$1' and sessid='$session' $2;" @@ -545,7 +554,7 @@ query "select quote(bin) from $cond and val=\"$fn\";" \ | xxd -r -p > $file echo ${type#file:} > $file.content-type -err TTTTTTTTTTTTTTTT: $type +# err TTTTTTTTTTTTTTTT: $type case $type in *:[Ii]mage*) mogrify -geometry $thumbxy $file ;; *:[Aa]pplication*) @@ -932,7 +941,7 @@ type='file'; k=${k%:filename} case `file --mime-type $tmpdir/$v|cut -d' ' -f2` in [Ii]mage/*) - mogrify -resize $maximagexy $tmpdir/$v + mogrify -resize $maximagexy'>' $tmpdir/$v ;; esac ;; @@ -1391,7 +1400,7 @@ fi tbl=${1%.def} tbl=${tbl##*/} - if [ -n "$rowid" ]; then + if [ -n "$rowid" ]; then # Modify existing entry if [ x"$tbl" = x"user" ]; then rowowner=`query "select name from $tbl where rowid=$rowid;"` elif [ x"$tbl" = x"grp" ]; then