Mercurial > hgrepos > hgweb.cgi > s4
changeset 462:e8bde2d9cb0b
New feature - show blog-seen time table, added
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Mon, 21 Aug 2017 20:05:37 +0859 |
parents | d7b23ad0e2e8 |
children | 4f0314630559 |
files | s4-blog.sh s4.cgi |
diffstat | 2 files changed, 64 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/s4-blog.sh Mon Aug 21 20:04:49 2017 +0859 +++ b/s4-blog.sh Mon Aug 21 20:05:37 2017 +0859 @@ -174,6 +174,7 @@ href3="(<a href=\"?gethandout+$rowid\" accesskey=\"f\" title=\"F\">ファイル取得</a>)" fi href4='<a href="#bottom" accesskey="b" title="B"> 末尾へ</a>' + href5="<a href=\"?blogseen+$rowid\" accesskey=\"s\" title=\"S\"> 読刻</a>" quizmodefile=$td/quiz; rm -f "$quizmodefile" # XXX: Global state query<<-EOF | @@ -192,7 +193,7 @@ EOF { IFS='|' read edit ctime hexhead blogtype cat<<-EOF - <tr><td>${edit:+$href }$ctime $blogtype $href2$href3 $href4</td></tr> + <tr><td>${edit:+$href }$ctime $blogtype $href2$href3 $href4 $href5</td></tr> <tr class="preface${frozen_class:+ }$frozen_class"> <td>`echo "$hexhead"|unhexize|hreflink|minitbl`</td></tr> </table> @@ -634,6 +635,66 @@ echo cat $arc } +blogseen() { # $1 = blogid + blogid=${1%%[!0-9]*} + if [ -z "$blogid" ]; then + echo "Invalid blog id" | html p; exit + fi + blog_writable "$blogid" "$user" + rc=$? # =0: writable, $BLOG_NOTMEM bit set => not member + if [ $((rc & $BLOG_NOTMEM)) -gt 0 ] ; then + echo "メンバー以外は利用できません。" | html p; return + fi + owner=`getvalbyid blog owner $rowid` + #qowner=`sqlquotestr "$owner"` + ge=`gecos "$owner"` + title=`getvalbyid blog title $rowid` + _m4 -D_TITLE_="アクセス時刻" $layout/html.m4.html + tmpf=$tmpd/header + echo "[title]@${ge:-$owner}" > $tmpf + warn=' class="warn"' + cat <<-EOF + <table class="b">' + <tr><th>メンバー</th><th>uname</th><th>最終閲覧時刻</th></tr> + EOF + query <<-EOF | + WITH grpmem as ( + SELECT user, (SELECT gecos FROM gecoses WHERE name=user) gecos + FROM grp_mem + WHERE gname=(SELECT val FROM blog_s + WHERE id=(select id from blog where rowid=16) + AND key='owner') + ), acctime AS ( + SELECT user, max(time) atime + FROM tblaccesses + WHERE tbl='blog' AND tblrowid=16 + GROUP BY user + ) + SELECT g.user, + (SELECT rowid FROM user u WHERE u.name=g.user), + hex(gecos), + atime + FROM grpmem g LEFT JOIN acctime t + ON g.user = t.user + GROUP BY t.user + ORDER BY atime DESC; + EOF + while IFS='|' read u uid hexge time; do + td=${time:+"<td>"} # If the variable time is set, td=<td> + td=${td:-"<td$warn>"} # else td=<td class="warn"> + cat <<-EOF + <tr> + <td><a href="?home+$uid">`echo "$hexge"|unhexize|htmlescape`</a></td> + <td>`echo ${u%%@*}|htmlescape`</td> + $td${time:----}</td></tr> + EOF + done + cat <<-EOF + </table> + <p><a href="?replyblog+$rowid">[$title]に戻る</a></p> + </html> + EOF +} lsmyfile() { # $1(optional)=SortBy case "$1" in ""|CTIME-DESC)
--- a/s4.cgi Mon Aug 21 20:04:49 2017 +0859 +++ b/s4.cgi Mon Aug 21 20:05:37 2017 +0859 @@ -79,9 +79,9 @@ echo "Refresh: 0; $newurl"; echo exit 0 ;; - lshandout|lshandoutall|gethandout|gethandoutcsv|gethandoutcsv2) + lshandout|lshandoutall|gethandout|gethandoutcsv|gethandoutcsv2|blogseen) case "$stage" in - lshandout*) contenttype; echo ;; + lshandout*|blogseen*) contenttype; echo ;; esac rowid=${2%%[!A-Z0-9a-z_]*} if [ -z "$rowid" ]; then