s4
changeset 60:9f4e85181d40
Add new articles digest
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sun, 26 Jul 2015 00:41:37 +0900 |
parents | 916d81b9c4fc |
children | 8b2cf4d9ba00 |
files | s4-funcs.sh |
diffstat | 1 files changed, 31 insertions(+), 7 deletions(-) [+] |
line diff
1.1 --- a/s4-funcs.sh Sat Jul 25 23:00:58 2015 +0900 1.2 +++ b/s4-funcs.sh Sun Jul 26 00:41:37 2015 +0900 1.3 @@ -408,9 +408,13 @@ 1.4 u=`sqlquote ${1:-$user}` 1.5 #gecos=`query "select val from user_s where name='$u' and key='gecos';"` 1.6 sql="select case when (select name from user where name=$u) is not null 1.7 - then (select val from user_s where name=$u and key='gecos') 1.8 + then coalesce( 1.9 + (select val from user_s where name=$u and key='gecos'), 1.10 + $u) 1.11 when (select gname from grp where gname=$u) is not null 1.12 - then (select val from grp_s where gname=$u and key='gecos') 1.13 + then coalesce( 1.14 + (select val from grp_s where gname=$u and key='gecos'), 1.15 + $u) 1.16 else $u 1.17 end;" 1.18 query "$sql" 1.19 @@ -1178,6 +1182,7 @@ 1.20 esac 1.21 err ShowHome: uname=$uname 1.22 gecos=`gecos "$uname"` 1.23 +err SH:gecos=$gecos 1.24 GF_VIEWONLY=1 1.25 cond="gname in (select gname from grp_mem where user='$uname')" 1.26 if [ x"$user" = x"$uname" ]; then 1.27 @@ -1192,6 +1197,18 @@ 1.28 -D_GROUPS_="`listgroupbytable $formdir/grp.def $cond`" \ 1.29 $layout/html.m4.html $layout/home.m4.html 1.30 1.31 + if [ x"$user" = x"$uname" ]; then 1.32 + cond="where 新着 > 0 order by 新着 desc,ctime desc limit 10" 1.33 + new10=`DT_CHLD=article:blogid \ 1.34 + DT_VIEW=replyblog dumptable html blog "ctime title gecos" "$cond"` 1.35 + cont=`echo "$new10"|grep "^<TR>"|wc -l` 1.36 + cont=$((cont-1)) 1.37 +err newcount=$cont 1.38 + if [ $cont -gt 0 ]; then 1.39 + echo "全体の新着記事${cont}傑" | html h2 1.40 + echo "$new10" 1.41 + fi 1.42 + fi 1.43 # 1.44 # Record access log 1.45 [ -n "$1" ] && [ x"$1" != x"$user" ] && acclog user $1 1.46 @@ -1441,7 +1458,7 @@ 1.47 <label>`cgi_text kwd`という語を含むコメントを検索</label> 1.48 `cgi_hidden owner $grp` 1.49 EOF 1.50 - cond="where a.id in (select id from blog_s where key='owner' and val='$grp') order by ctime desc" 1.51 + cond="where a.id in (select id from blog_s where key='owner' and val=$qgrp) order by ctime desc" 1.52 DT_CHLD=article:blogid \ 1.53 DT_VIEW=replyblog dumptable html blog 'ctime title heading' "$cond" 1.54 1.55 @@ -1683,8 +1700,8 @@ 1.56 and val > coalesce((select time from acclog where \ 1.57 user='$user' and tbl='$2' and rowid=a.rowid),\ 1.58 '1970-01-01'))" 1.59 - cnt="$cntnew||'/'||$cntall as '新着/総数'," 1.60 - dt_class=" td2r" 1.61 + cnt="$cntnew as '新着', $cntall as '総数'," 1.62 + dt_class=" td2r td3r" 1.63 fi 1.64 # Construct join expression 1.65 eav="" scols="" 1.66 @@ -1693,6 +1710,8 @@ 1.67 substr=${substr:-val} 1.68 for col in ${3:-`gettbl_s_cols $2`}; do 1.69 case $col in 1.70 + gecos) scols="$scols${scols:+, }${col#}" 1.71 + continue ;; # built-in column name 1.72 *:*) col=${col%:*} as=${col#*:} ;; 1.73 *) as=${col} ;; 1.74 esac 1.75 @@ -1703,8 +1722,13 @@ 1.76 sql="select \ 1.77 a.rowid as ID,\ 1.78 $cnt\ 1.79 -$scols from $2 a left join (select $pk,$eav from ${2}_s group by $pk) b on a.$pk=b.$pk $4;" 1.80 -err SQL="$sql" 1.81 +$scols from $2 a left join\ 1.82 + (select $pk,$eav, 1.83 + max(case key when 'owner' 1.84 + then coalesce((select val from user_s us 1.85 + where us.key='gecos' and us.name=c.val), val) end) as gecos 1.86 + from ${2}_s c group by $pk) b on a.$pk=b.$pk $4;" 1.87 +err SQL=`echo "$sql"` 1.88 cat<<EOF | sed "s,\(<TR><TD>\)\([1-9][0-9]*\)</TD>,\1$elink$dvlink</TD>," 1.89 <div class="dumptable"> 1.90 <table class="b$dt_class">