Mercurial > hgrepos > hgweb.cgi > s4
diff s4-funcs.sh @ 397:e9e8b4d40220
Add feature of `frozen state' of the blog board
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Tue, 27 Dec 2016 08:41:10 +0859 |
parents | cacd961d3405 |
children | f50d4df067b5 |
line wrap: on
line diff
--- a/s4-funcs.sh Sun Dec 25 11:55:51 2016 +0859 +++ b/s4-funcs.sh Tue Dec 27 08:41:10 2016 +0859 @@ -2198,9 +2198,10 @@ `cgi_hidden owner $grp` EOF cond="where a.id in (select id from blog_s where key='owner' and val=$qgrp) order by ctime desc" + colstate="state:稼動状態:frozen=rowclass=凍結" DT_CHLD=article:blogid \ DT_VIEW=replyblog dumptable html blog \ - "ctime team title heading$colmd" "$cond" + "ctime team title heading$colmd $colstate" "$cond" getgname="(select gname from grp where rowid=$rowid)" c="group by a.name having a.name in (select user from grp_mem where gname=$getgname)" @@ -2895,6 +2896,26 @@ showgroup $grid done } +dt_rowhack() { + # From: <TR> + # .... + # <TD>rowclass=foo</TD> + # </TR> + # To: <TR class="foo">....<TD>foo</TD></TR> + sed -e ' + /^<TR>/ { + :loop + s/\n// + N + /<\/TR>/ { + s/\n// + s,^<TR>\(.*\)<TD>rowclass=\(.*\)\(</TD></TR>\),<TR class="\2">\1<TD>\2\3, + n + } + $p + b loop + }' +} dumptable() { # $1=mode $2=Table $3=column-list-of-*_s(defaults to *) $4=conditions(if any) # textのフィールドだけ全てダンプにしたほうがいいか @@ -2923,16 +2944,28 @@ # Construct join expression eav="" scols="" pk=`gettblpkey $2` - substr=${dumpcollen:+"substr(val, 0, $dumpcollen)"} - substr=${substr:-val} + substr=${dumpcollen:+"substr(%s, 0, $dumpcollen)"} + substr=${substr:-%s} for col in ${3:-`gettbl_s_cols $2`}; do + valvar=val case $col in gecos) scols="$scols${scols:+, }${col#}" continue ;; # built-in column name - *:*) col=${col%:*} as=${col#*:} ;; + *:*) as=${col#*:} # as can be 稼動状態:frozen=凍結中 + col=${col%%:*} # stage:稼動状態:frozen=凍結中 -> stage + case "$as" in + *:*=*) cnd=${as#*:} + h=${cnd%%=*} v=${cnd#*=} + h=`sqlquotestr "$h"` + v=`sqlquotestr "$v"` + valvar="CASE val WHEN $h THEN $v END" + as=${as%%:*} ;; + esac + ;; *) as=${col} ;; esac - eav=$eav${eav:+,}" max(case key when '$col' then $substr end) as $as" + ss=`printf "$substr" "$valvar"` + eav=$eav${eav:+,}" max(case key when '$col' then $ss end) as $as" scols="$scols${scols:+, }b.$as" done #case author when '$user' then a.rowid else '---' end as ID, @@ -2945,7 +2978,7 @@ then (SELECT gecos FROM gecoses WHERE name=val) END) as gecos from ${2}_s c group by $pk) b on a.$pk=b.$pk $4;"} ## err dt:SQL="`echo \"$presql$sql\"|tr -d '\n'`" - cat<<EOF | sed "s,\(<TR><TD>\)\([1-9][0-9]*\)\(#[0-9a-fxs]*\)*</TD>,\1$elink$dvlink</TD>," + cat<<EOF | sed "s,\(<TR><TD>\)\([1-9][0-9]*\)\(#[0-9a-fxs]*\)*</TD>,\1$elink$dvlink</TD>," | dt_rowhack <div> <!-- for folding by check button (s4-funcs.sh:dumptable()) --> <div class="dumptable"> <table class="b$dt_class">