# HG changeset patch # User HIROSE Yuuji # Date 1437838897 -32400 # Node ID 9f4e85181d409cb473f2891279c17f2fa1813ec6 # Parent 916d81b9c4fc875545c95353bf3fbcfed238ab57 Add new articles digest diff -r 916d81b9c4fc -r 9f4e85181d40 s4-funcs.sh --- a/s4-funcs.sh Sat Jul 25 23:00:58 2015 +0900 +++ b/s4-funcs.sh Sun Jul 26 00:41:37 2015 +0900 @@ -408,9 +408,13 @@ u=`sqlquote ${1:-$user}` #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') + then coalesce( + (select val from user_s where name=$u and key='gecos'), + $u) when (select gname from grp where gname=$u) is not null - then (select val from grp_s where gname=$u and key='gecos') + then coalesce( + (select val from grp_s where gname=$u and key='gecos'), + $u) else $u end;" query "$sql" @@ -1178,6 +1182,7 @@ esac err ShowHome: uname=$uname gecos=`gecos "$uname"` +err SH:gecos=$gecos GF_VIEWONLY=1 cond="gname in (select gname from grp_mem where user='$uname')" if [ x"$user" = x"$uname" ]; then @@ -1192,6 +1197,18 @@ -D_GROUPS_="`listgroupbytable $formdir/grp.def $cond`" \ $layout/html.m4.html $layout/home.m4.html + if [ x"$user" = x"$uname" ]; then + cond="where 新着 > 0 order by 新着 desc,ctime desc limit 10" + new10=`DT_CHLD=article:blogid \ + DT_VIEW=replyblog dumptable html blog "ctime title gecos" "$cond"` + cont=`echo "$new10"|grep "^"|wc -l` + cont=$((cont-1)) +err newcount=$cont + if [ $cont -gt 0 ]; then + echo "全体の新着記事${cont}傑" | html h2 + echo "$new10" + fi + fi # # Record access log [ -n "$1" ] && [ x"$1" != x"$user" ] && acclog user $1 @@ -1441,7 +1458,7 @@ `cgi_hidden owner $grp` EOF - cond="where a.id in (select id from blog_s where key='owner' and val='$grp') order by ctime desc" + cond="where a.id in (select id from blog_s where key='owner' and val=$qgrp) order by ctime desc" DT_CHLD=article:blogid \ DT_VIEW=replyblog dumptable html blog 'ctime title heading' "$cond" @@ -1683,8 +1700,8 @@ and val > coalesce((select time from acclog where \ user='$user' and tbl='$2' and rowid=a.rowid),\ '1970-01-01'))" - cnt="$cntnew||'/'||$cntall as '新着/総数'," - dt_class=" td2r" + cnt="$cntnew as '新着', $cntall as '総数'," + dt_class=" td2r td3r" fi # Construct join expression eav="" scols="" @@ -1693,6 +1710,8 @@ substr=${substr:-val} for col in ${3:-`gettbl_s_cols $2`}; do case $col in + gecos) scols="$scols${scols:+, }${col#}" + continue ;; # built-in column name *:*) col=${col%:*} as=${col#*:} ;; *) as=${col} ;; esac @@ -1703,8 +1722,13 @@ sql="select \ a.rowid as ID,\ $cnt\ -$scols from $2 a left join (select $pk,$eav from ${2}_s group by $pk) b on a.$pk=b.$pk $4;" -err SQL="$sql" +$scols from $2 a left join\ + (select $pk,$eav, + max(case key when 'owner' + then coalesce((select val from user_s us + where us.key='gecos' and us.name=c.val), val) end) as gecos + from ${2}_s c group by $pk) b on a.$pk=b.$pk $4;" +err SQL=`echo "$sql"` cat<\)\([1-9][0-9]*\),\1$elink$dvlink,"