annotate s4-blog.sh @ 452:30ab12e54324

Ballon help for s4-WikiStyle added
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 14 Aug 2017 13:46:39 +0859
parents 8965bdad3172
children 512cb413228b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1 #
17
01f579d2c889 Rename to s4
HIROSE Yuuji <yuuji@gentei.org>
parents: 16
diff changeset
2 type cgiinit >/dev/null 2>&1 || . ./s4-funcs.sh
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
3
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
4 # Global error flags
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
5 BLOG_NOTMEM=1
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
6 BLOG_FROZEN=2
399
db25589d864c Add frozen tag to lshandoutall listings
HIROSE Yuuji <yuuji@gentei.org>
parents: 397
diff changeset
7 FROZEN_TAG='<span class="frozen">[凍結]</span>'
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
8
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
9 blog_genform() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
10 #
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
11 t=$1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
12 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
13
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
14 blog_writable() (
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
15 # $1=articleid $2=user
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
16 # Return: $?=0 - Writable
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
17 # =1 - NOT Writable because user is not a member
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
18 # =2 - NOT Writable because blog is frozen
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
19 blogowner=`getvalbyid blog owner "$1"`
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
20 state=`getvalbyid blog state "$1"`
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
21 rc=0
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
22 [ x"$blogowner" = x"$2" ] || isuser "$blogowner" || ismember "$2" "$blogowner" || rc=$((rc+$BLOG_NOTMEM))
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
23 [ "$state" = "frozen" ] && rc=$((rc+$BLOG_FROZEN))
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
24 return $rc
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
25 )
138
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
26 blog_readable() {
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
27 # $1=articleid $2=user
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
28 mode=`getgroupattr $grp regmode`
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
29 }
50
13f9b5e5df85 subshellize blog_notify_reply
HIROSE Yuuji <yuuji@gentei.org>
parents: 48
diff changeset
30 blog_notify_reply() (
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
31 # $1=blogid $2=ReplyingUser $3=WrittenText $4(optional)=Action
411
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
32 blogid="${1%%[!A-Z0-9a-z_]*}"
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
33 blogowner=`getvalbyid blog owner "$blogid"`
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
34 blogtitle=`getvalbyid blog title "$blogid"`
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
35 blogurl="$urlbase?replyblog+$blogid"
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
36 action=${4:-書き込み}
411
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
37 mode=`getvalbyid blog notify "$blogid"`
238
45b7facac49e Do not exclude submitting user from new article notification.
HIROSE Yuuji <yuuji@gentei.org>
parents: 222
diff changeset
38 ### EXCEPT=`sqlquote "$user"` ## User should receive to feal some annoyance
50
13f9b5e5df85 subshellize blog_notify_reply
HIROSE Yuuji <yuuji@gentei.org>
parents: 48
diff changeset
39 case $mode in
48
837c9a6bec02 Add notification modes
HIROSE Yuuji <yuuji@gentei.org>
parents: 42
diff changeset
40 admin)
55
7f9f7e898986 Do not send notification to the person-self
HIROSE Yuuji <yuuji@gentei.org>
parents: 54
diff changeset
41 if isgroup "$blogowner"; then
117
82e215e75468 Add moderated mode to grp
HIROSE Yuuji <yuuji@gentei.org>
parents: 81
diff changeset
42 emails=`getgroupadminmails $blogowner`
48
837c9a6bec02 Add notification modes
HIROSE Yuuji <yuuji@gentei.org>
parents: 42
diff changeset
43 else
837c9a6bec02 Add notification modes
HIROSE Yuuji <yuuji@gentei.org>
parents: 42
diff changeset
44 emails=`collectemail $blogowner`
837c9a6bec02 Add notification modes
HIROSE Yuuji <yuuji@gentei.org>
parents: 42
diff changeset
45 fi
170
45d6954af516 TEST: notifyto button added for evaluation
HIROSE Yuuji <yuuji@gentei.org>
parents: 168
diff changeset
46 notifyto=`getpar notifyto`
191
24e0f2b4d51b Variable name mistake fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 189
diff changeset
47 if [ -n "$notifyto" ]; then
170
45d6954af516 TEST: notifyto button added for evaluation
HIROSE Yuuji <yuuji@gentei.org>
parents: 168
diff changeset
48 emails=$emails" `email4groupbyuid \"$blogowner\" $notifyto`"
45d6954af516 TEST: notifyto button added for evaluation
HIROSE Yuuji <yuuji@gentei.org>
parents: 168
diff changeset
49 fi
48
837c9a6bec02 Add notification modes
HIROSE Yuuji <yuuji@gentei.org>
parents: 42
diff changeset
50 ;;
410
c1b4a9dba1c9 Direct reply notification fired by ">#NNN" in the first line
HIROSE Yuuji <yuuji@gentei.org>
parents: 409
diff changeset
51 no) emails="" ;;
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
52 *) team=`query "SELECT val FROM blog_s
411
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
53 WHERE id=(SELECT id FROM blog WHERE rowid=$blogid)
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
54 AND key='team';"`
411
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
55 # team cannot get `getvalbyid blog team "$blogid"` because it's not
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
56 # defined in blog.def. Yes, it is Illegal USE!!
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
57 emails=`TEAM=$team collectemail $blogowner` ;;
48
837c9a6bec02 Add notification modes
HIROSE Yuuji <yuuji@gentei.org>
parents: 42
diff changeset
58 esac
410
c1b4a9dba1c9 Direct reply notification fired by ">#NNN" in the first line
HIROSE Yuuji <yuuji@gentei.org>
parents: 409
diff changeset
59 ## 2017-0210 Respond to the direct reply mark such as: >#1234
413
933df1a150e0 replymark should be treated with utf-8
HIROSE Yuuji <yuuji@gentei.org>
parents: 412
diff changeset
60 replymark=`echo "$3"|nkf -w -Z0|grep '^ *>#'`
410
c1b4a9dba1c9 Direct reply notification fired by ">#NNN" in the first line
HIROSE Yuuji <yuuji@gentei.org>
parents: 409
diff changeset
61 authgecos=`gecos $2`
c1b4a9dba1c9 Direct reply notification fired by ">#NNN" in the first line
HIROSE Yuuji <yuuji@gentei.org>
parents: 409
diff changeset
62 if [ -z "$4" -a -n "$replymark" ]; then
c1b4a9dba1c9 Direct reply notification fired by ">#NNN" in the first line
HIROSE Yuuji <yuuji@gentei.org>
parents: 409
diff changeset
63 # If the action is new subscription($4="") and has ">#123" marks...
411
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
64 ids=`echo "$replymark"|sed 's/[^#0-9]*#\([0-9]*\)[^#0-9]*/\1 /g'`
421
d3bf2e95c0cc Multiple reply handling fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 420
diff changeset
65 ids=`echo $ids|tr -dc '[0-9 ]'|tr ' ' ','`
411
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
66 # -> 123,345,347
410
c1b4a9dba1c9 Direct reply notification fired by ">#NNN" in the first line
HIROSE Yuuji <yuuji@gentei.org>
parents: 409
diff changeset
67 unames=`query "SELECT distinct author FROM article \
c1b4a9dba1c9 Direct reply notification fired by ">#NNN" in the first line
HIROSE Yuuji <yuuji@gentei.org>
parents: 409
diff changeset
68 WHERE rowid in ($ids)\
411
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
69 AND blogid=(SELECT id FROM blog WHERE rowid=$blogid);"`
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
70 if [ -n "$unames" ]; then
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
71 emails=$emails" `email4group \"$blogowner\" $unames`"
412
a765ed027dbd Message for replymark should be the names of reply recipients
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
72 for e in $unames; do
a765ed027dbd Message for replymark should be the names of reply recipients
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
73 g=`gecos $e`
415
0d5d62b53cc3 Remove preceding comma
HIROSE Yuuji <yuuji@gentei.org>
parents: 414
diff changeset
74 whom=$whom"${whom:+,}${g:-$e}さん"
412
a765ed027dbd Message for replymark should be the names of reply recipients
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
75 done
a765ed027dbd Message for replymark should be the names of reply recipients
HIROSE Yuuji <yuuji@gentei.org>
parents: 411
diff changeset
76 action="${whom}への返信"
411
e30fe590a53e Allow replymark in other than the first line.
HIROSE Yuuji <yuuji@gentei.org>
parents: 410
diff changeset
77 fi
430
ce497c515996 Skip notify check when replymark is null and author=owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 429
diff changeset
78 else
ce497c515996 Skip notify check when replymark is null and author=owner
HIROSE Yuuji <yuuji@gentei.org>
parents: 429
diff changeset
79 [ x"$2" = x"$blogowner" ] && return # If author=blogowner, unnecessary
410
c1b4a9dba1c9 Direct reply notification fired by ">#NNN" in the first line
HIROSE Yuuji <yuuji@gentei.org>
parents: 409
diff changeset
80 fi
c1b4a9dba1c9 Direct reply notification fired by ">#NNN" in the first line
HIROSE Yuuji <yuuji@gentei.org>
parents: 409
diff changeset
81 test -z "$emails" && return
165
4040bb8b2038 quote search kwd. $SMAIL_TO controls To: header value.
HIROSE Yuuji <yuuji@gentei.org>
parents: 162
diff changeset
82 err notify: user=$user Admins=`getgroupadmins $blogowner` Mode=$mode Emails="[$emails]"
168
1dea78110c79 remove newline in to:
HIROSE Yuuji <yuuji@gentei.org>
parents: 167
diff changeset
83 SMAIL_TO="`echo "$blogowner" | nkf -jM | tr -d '\n'` readers <$admin>" \
165
4040bb8b2038 quote search kwd. $SMAIL_TO controls To: header value.
HIROSE Yuuji <yuuji@gentei.org>
parents: 162
diff changeset
84 smail "$emails" "${action}通知 $urlbase"<<EOF
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
85 [$blogtitle]板に${action}がありました。
432
99526bd0f2d1 Notify "Notification mail cannot be sent back".
HIROSE Yuuji <yuuji@gentei.org>
parents: 430
diff changeset
86 ※このメイルに返信しても通知者には伝わりません(管理者宛になる)。
99526bd0f2d1 Notify "Notification mail cannot be sent back".
HIROSE Yuuji <yuuji@gentei.org>
parents: 430
diff changeset
87 場所: $blogurl (返信先)
410
c1b4a9dba1c9 Direct reply notification fired by ">#NNN" in the first line
HIROSE Yuuji <yuuji@gentei.org>
parents: 409
diff changeset
88 所有: $blogowner
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
89 題目: $blogtitle
410
c1b4a9dba1c9 Direct reply notification fired by ">#NNN" in the first line
HIROSE Yuuji <yuuji@gentei.org>
parents: 409
diff changeset
90 筆者: $authgecos
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
91 内容:
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
92 `echo "$3"|sed 's/^/> /'`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
93 EOF
50
13f9b5e5df85 subshellize blog_notify_reply
HIROSE Yuuji <yuuji@gentei.org>
parents: 48
diff changeset
94 )
192
50e6195130b3 blog_showentry2() is now blog_showentry() (Old code removed)
HIROSE Yuuji <yuuji@gentei.org>
parents: 191
diff changeset
95
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
96 blog_showentry() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
97 # $1=table $2=rowid
69
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
98 # if [ -n "$2" ]; then
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
99 # if [ -n "$imgcached" ]; then
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
100 # bstmpdir=$tmpdir/$imgcached/$thumbxy
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
101 # else
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
102 # bstmpdir=$tmpd
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
103 # # tmpd=`mktempd`
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
104 # # tmpfiles=$tmpfiles" $tmpd"
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
105 # fi
d10f98c2b192 form+dump
HIROSE Yuuji <yuuji@gentei.org>
parents: 68
diff changeset
106 # fi
72
3dc3ddd2d3e5 getcachedir argument contains rowid
HIROSE Yuuji <yuuji@gentei.org>
parents: 69
diff changeset
107 td=`getcachedir "article/$2"`
291
1df64f0490ca `|col|col|...' like table conversion enabled
HIROSE Yuuji <yuuji@gentei.org>
parents: 288
diff changeset
108 [ -d "$td" ] || mkdir -p $td
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
109 tbl=${1%%[!A-Z0-9a-z_]*} rowid=${2%%[!A-Z0-9a-z_]*}
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
110 err blow_showentry: rowid=$rowid, '$2'=$2 user=$user
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
111 ts=${tbl}_s tm=${tbl}_m
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
112 at=article as=article_s am=article_m
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
113 serial=$(($(date +%s)-1420038000))s$$
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
114 blog_writable $rowid $user
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
115 rc=$?
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
116 if [ $rc = 0 ]; then
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
117 iswritable=true
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
118 ismem=true
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
119 else
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
120 iswritable=false
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
121 if [ $((rc & $BLOG_NOTMEM)) -gt 0 ]; then
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
122 ismem=false
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
123 else
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
124 ismem=true
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
125 fi
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
126 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
127 # This function grasps blog entry definiton directly.
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
128 # blog: id
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
129 # blog_s: title,ctime,heading
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
130 # blog_m: *article
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
131
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
132 blogowner=`getvalbyid blog owner "$2"`
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
133 isgroup "$blogowner" && isgroup=true || isgroup=false
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
134
138
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
135 # 2015-10-05 check readable
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
136 if ! $iswritable; then
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
137 # err blogowner=$blogowner
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
138 if $isgroup; then
138
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
139 regmode=`getgroupattr $blogowner regmode`
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
140 # err regmode=$regmode
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
141 if [ x"$regmode" = x"moderated" ]; then
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
142 # if ! ismember $user $blogowner; then
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
143 if ! $ismem; then
138
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
144 echo "加入してからどうぞ" | html p
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
145 return
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
146 fi
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
147 fi
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
148 fi
130114486d8c Blog of moderated group cannot be read by outsider.
HIROSE Yuuji <yuuji@gentei.org>
parents: 134
diff changeset
149 fi
170
45d6954af516 TEST: notifyto button added for evaluation
HIROSE Yuuji <yuuji@gentei.org>
parents: 168
diff changeset
150 case `getvalbyid blog notify "$2"` in # "all", "admin" or "no" (or NULL)
45d6954af516 TEST: notifyto button added for evaluation
HIROSE Yuuji <yuuji@gentei.org>
parents: 168
diff changeset
151 admin) notifyto=1 ;;
45d6954af516 TEST: notifyto button added for evaluation
HIROSE Yuuji <yuuji@gentei.org>
parents: 168
diff changeset
152 *) notifyto="" ;;
45d6954af516 TEST: notifyto button added for evaluation
HIROSE Yuuji <yuuji@gentei.org>
parents: 168
diff changeset
153 esac
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
154
335
a120ba2d719b Show link to the beginning of page at the bottom of page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 333
diff changeset
155 # err "SELECT id from $tbl where rowid=$rowid"
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
156 id=`query "select id from $tbl where rowid=$rowid;"`
335
a120ba2d719b Show link to the beginning of page at the bottom of page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 333
diff changeset
157 #err id=$id
a120ba2d719b Show link to the beginning of page at the bottom of page.
HIROSE Yuuji <yuuji@gentei.org>
parents: 333
diff changeset
158 #err "select val from $ts where key='title' and id='$id';"
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
159
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
160
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
161 #(1)Display root article
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
162 cat<<EOF
239
25e0b1eaf04d Degrade fixed: Explicit notify works again.
HIROSE Yuuji <yuuji@gentei.org>
parents: 238
diff changeset
163 <form class="replyblog" action="$myname?replyblog+${rowid}#bottom" method="POST" enctype="multipart/form-data">
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
164 <table class="bloghead">
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
165 EOF
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
166
341
bad68ea6c30a Add more accesskeys
HIROSE Yuuji <yuuji@gentei.org>
parents: 338
diff changeset
167 href="<a href=\"?editheading+$rowid\" accesskey=\"e\" title=\"E\"> 編集 </a>"
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
168 if $ismem; then
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
169 case `getvalbyid blog mode $rowid` in
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
170 *report*)
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
171 href2="<a href=\"?lshandout+$rowid\" accesskey=\"l\" title=\"L\"> 提出状況 </a>"
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
172 ;;
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
173 esac
341
bad68ea6c30a Add more accesskeys
HIROSE Yuuji <yuuji@gentei.org>
parents: 338
diff changeset
174 href3="(<a href=\"?gethandout+$rowid\" accesskey=\"f\" title=\"F\">ファイル取得</a>)"
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
175 fi
341
bad68ea6c30a Add more accesskeys
HIROSE Yuuji <yuuji@gentei.org>
parents: 338
diff changeset
176 href4='<a href="#bottom" accesskey="b" title="B"> 末尾へ</a>'
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
177 quizmodefile=$td/quiz; rm -f "$quizmodefile" # XXX: Global state
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
178
293
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
179 query<<-EOF |
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
180 SELECT coalesce((SELECT "yes" FROM blog
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
181 WHERE rowid=$rowid AND author='$user'),
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
182 ''),
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
183 max(CASE key WHEN 'ctime' THEN val END) ctime,
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
184 max(CASE key WHEN 'heading' THEN hex(val) END) heading,
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
185 CASE (SELECT val FROM $ts WHERE key="mode" AND id="$id")
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
186 WHEN 'report-closed' THEN 'レポート提出用(closed)'
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
187 WHEN 'report-open' THEN 'レポート提出用(open)'
442
14764da097ec Fix comment sentence
HIROSE Yuuji <yuuji@gentei.org>
parents: 441
diff changeset
188 WHEN 'quiz' THEN 'クイズ'
293
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
189 ELSE ''
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
190 END
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
191 FROM $ts WHERE id='$id' GROUP BY id;
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
192 EOF
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
193 { IFS='|' read edit ctime hexhead blogtype
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
194 cat<<-EOF
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
195 <tr><td>${edit:+$href }$ctime $blogtype $href2$href3 $href4</td></tr>
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
196 <tr class="preface${frozen_class:+ }$frozen_class">
293
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
197 <td>`echo "$hexhead"|unhexize|hreflink|minitbl`</td></tr>
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
198 </table>
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
199 EOF
446
39823dfee44f Display warning about quiz mode on the top of articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
200 case "$blogtype" in
39823dfee44f Display warning about quiz mode on the top of articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
201 "クイズ")
39823dfee44f Display warning about quiz mode on the top of articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
202 echo "クイズモードは本人と管理者の書き込みのみが表示されます。"
39823dfee44f Display warning about quiz mode on the top of articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
203 ;;
39823dfee44f Display warning about quiz mode on the top of articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
204 esac | html p 'class="warn"'
39823dfee44f Display warning about quiz mode on the top of articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
205 echo '<table class="blog_replies">'
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
206 if [ x"$blogtype" = x"クイズ" ]; then
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
207 if $isgroup; then
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
208 if ! isgrpowner "$user" "$blogowner"; then
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
209 qgrp=`sqlquote "$blogowner"`
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
210 cat<<-EOF > $quizmodefile
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
211 AND (author IN (SELECT user FROM grp_adm WHERE gname=$qgrp)
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
212 OR
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
213 author='$user')
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
214 EOF
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
215 fi
446
39823dfee44f Display warning about quiz mode on the top of articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
216 else # if user's blog
39823dfee44f Display warning about quiz mode on the top of articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
217 if [ x"$user" != x"$blogowner" ]; then
39823dfee44f Display warning about quiz mode on the top of articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
218 cat<<-EOF > $quizmodefile
39823dfee44f Display warning about quiz mode on the top of articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
219 AND author IN ('$blogowner', '$user')
39823dfee44f Display warning about quiz mode on the top of articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
220 EOF
39823dfee44f Display warning about quiz mode on the top of articles
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
221 fi
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
222 fi
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
223 fi
293
6c281c9899e5 Allow WikiStyle notation in blog heading
HIROSE Yuuji <yuuji@gentei.org>
parents: 291
diff changeset
224 }
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
225 lkhome="<a href=\"$myname?home" lke='">'
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
226 lkedit="<a href=\"$myname?editart"
263
ebd4af16c493 Old blog dumping code based on sq -html, removed entirely
HIROSE Yuuji <yuuji@gentei.org>
parents: 261
diff changeset
227 hlink="$myname?home" elink="$myname?editart"
ebd4af16c493 Old blog dumping code based on sq -html, removed entirely
HIROSE Yuuji <yuuji@gentei.org>
parents: 261
diff changeset
228 catlink="$myname?showattc+article_m"
ebd4af16c493 Old blog dumping code based on sq -html, removed entirely
HIROSE Yuuji <yuuji@gentei.org>
parents: 261
diff changeset
229 deficon="img/file-icon.png"
286
1c4f13f0813e Add newer article flag representing by time string decoration.
HIROSE Yuuji <yuuji@gentei.org>
parents: 283
diff changeset
230 # 2016-08-15 Newer flag introduced
1c4f13f0813e Add newer article flag representing by time string decoration.
HIROSE Yuuji <yuuji@gentei.org>
parents: 283
diff changeset
231 atime=`query "SELECT time FROM acclog
1c4f13f0813e Add newer article flag representing by time string decoration.
HIROSE Yuuji <yuuji@gentei.org>
parents: 283
diff changeset
232 WHERE tbl='blog' AND tblrowid=$rowid AND user='$user';"`
333
002cc900200a Nonexistent Icon cleaning is too heavy, put it after loop
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
233 iconcleaner=$tmpd/iconcleaner.$$
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
234 [ -s $quizmodefile ] && cond_qz=`cat $quizmodefile`
442
14764da097ec Fix comment sentence
HIROSE Yuuji <yuuji@gentei.org>
parents: 441
diff changeset
235 # *** DO NOT USE query(), use "sq $db" instead here ***
381
879d7f1cd676 More explanatory comment about previous commit.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
236 # because the next block in pipe line uses query() repeatedly.
380
b0d1b4914789 Revert to call "sq $db" instead of query() because of pipe error
HIROSE Yuuji <yuuji@gentei.org>
parents: 379
diff changeset
237 sq $db<<EOF |
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
238 WITH a_s AS (
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
239 SELECT id,
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
240 max(CASE key WHEN 'ctime' THEN val END) TIME,
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
241 max(CASE key WHEN 'text' THEN val END) TEXT
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
242 FROM article_s
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
243 GROUP by id
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
244 )
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
245 SELECT a.id,
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
246 CASE author
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
247 WHEN '$user' THEN a.rowid||'+'||$rowid
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
248 ELSE ''
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
249 END edit,
170
45d6954af516 TEST: notifyto button added for evaluation
HIROSE Yuuji <yuuji@gentei.org>
parents: 168
diff changeset
250 CASE -- 「通知送信」ボタンの有無
45d6954af516 TEST: notifyto button added for evaluation
HIROSE Yuuji <yuuji@gentei.org>
parents: 168
diff changeset
251 WHEN '$notifyto' = '' THEN '' -- 不要モードならなし
45d6954af516 TEST: notifyto button added for evaluation
HIROSE Yuuji <yuuji@gentei.org>
parents: 168
diff changeset
252 WHEN '$user' = author THEN '' -- 筆者自身ならなし
45d6954af516 TEST: notifyto button added for evaluation
HIROSE Yuuji <yuuji@gentei.org>
parents: 168
diff changeset
253 ELSE "yes"
45d6954af516 TEST: notifyto button added for evaluation
HIROSE Yuuji <yuuji@gentei.org>
parents: 168
diff changeset
254 END notify,
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
255 (SELECT rowid FROM user WHERE name=author) user_rid,
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
256 coalesce((SELECT val FROM user_s
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
257 WHERE name=author AND key='gecos'),
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
258 author) uname,
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 304
diff changeset
259 (SELECT val FROM user_s WHERE name=author AND key='$iconcachekey')
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 304
diff changeset
260 icon,
183
b641b5393c40 TEST: Put rowid of article for convenience to reference
HIROSE Yuuji <yuuji@gentei.org>
parents: 170
diff changeset
261 a.rowid,
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
262 s.TIME,
286
1c4f13f0813e Add newer article flag representing by time string decoration.
HIROSE Yuuji <yuuji@gentei.org>
parents: 283
diff changeset
263 CASE WHEN s.TIME > '$atime' THEN 'new' ELSE '' END newer,
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
264 hex(s.TEXT),
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
265 (SELECT group_concat(rowid||':'||length(bin)||':'||hex(val), ' ')
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
266 FROM article_m
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
267 WHERE id=a.id AND key='image') imxgids
443
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
268 FROM (select rowid,id,author from article
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
269 where blogid in
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
270 (select id from blog where rowid=$rowid)
f1744a954888 New blog mode "quiz" introduced,
HIROSE Yuuji <yuuji@gentei.org>
parents: 442
diff changeset
271 $cond_qz) a
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
272 LEFT JOIN
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
273 a_s s
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
274 ON a.id=s.id;
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
275 EOF
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 304
diff changeset
276 while IFS='|' read id edit notify uid uname icon aid tm new hte imgids; do
407
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
277 cachefile="$td/$id.row.html"
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
278 stampfile="$td/$id.row.stamp"
408
138a0c6b09a7 Edit link in cached row file should be determined dynamically.
HIROSE Yuuji <yuuji@gentei.org>
parents: 407
diff changeset
279 editlink="${edit:+<a href="$elink+$edit">編集</a> }"
409
388639a80a23 Also notify rule in cached file should be generated dynamically.
HIROSE Yuuji <yuuji@gentei.org>
parents: 408
diff changeset
280 nt="<label style=\"font-size: 70%;\"><input type=\"checkbox\"\
388639a80a23 Also notify rule in cached file should be generated dynamically.
HIROSE Yuuji <yuuji@gentei.org>
parents: 408
diff changeset
281 name=\"notifyto\" value=\"$uid\">返信通知送信</label>"
406
1af18eeeffb3 Cache strategy revised to trace icon cache renewal
HIROSE Yuuji <yuuji@gentei.org>
parents: 405
diff changeset
282
1af18eeeffb3 Cache strategy revised to trace icon cache renewal
HIROSE Yuuji <yuuji@gentei.org>
parents: 405
diff changeset
283 # First, check the availability of user-icon.
1af18eeeffb3 Cache strategy revised to trace icon cache renewal
HIROSE Yuuji <yuuji@gentei.org>
parents: 405
diff changeset
284 # If not existent, clear and reset row cache by rm $stampfile
407
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
285 if [ ! -s "$icon" ]; then
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
286 rm -f "$stampfile"; unset stampfile
406
1af18eeeffb3 Cache strategy revised to trace icon cache renewal
HIROSE Yuuji <yuuji@gentei.org>
parents: 405
diff changeset
287 fi
403
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
288 if test -s "$stampfile" &&
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
289 test -s "$cachefile" &&
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
290 { ts=`cat "$stampfile"`; test -n "$ts"; } &&
422
a868a34ca3bc Do not use article cache when user-icon is newer than cache.
HIROSE Yuuji <yuuji@gentei.org>
parents: 421
diff changeset
291 test "$ts" '>' "$tm" && # Cache timestamp is newer
a868a34ca3bc Do not use article cache when user-icon is newer than cache.
HIROSE Yuuji <yuuji@gentei.org>
parents: 421
diff changeset
292 test "$stampfile" -nt "$icon"; then # UserIcon is older
a868a34ca3bc Do not use article cache when user-icon is newer than cache.
HIROSE Yuuji <yuuji@gentei.org>
parents: 421
diff changeset
293 : Nothing to do
322
18be0c210dc8 First implementation of icon display in blog_replies.
HIROSE Yuuji <yuuji@gentei.org>
parents: 304
diff changeset
294 else
403
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
295 { ######## New ROW creation begins here ######## >$cachefile
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
296 tdcls="__NEWCLS__repatt"
407
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
297 if [ -s "$icon" ]; then
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
298 icfn=`echo "$icon"|htmlescape`
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
299 picon="<p class=\"proficon\"><a href=\"$hlink+$uid\"><img src=\"$icfn\"></a></p>"
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
300 else
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
301 echo "DELETE FROM user_s WHERE key='$iconcachekey' AND
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
302 val=`sqlquotestr \"$icon\"`;" >> $iconcleaner
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
303 picon=""
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
304 fi
406
1af18eeeffb3 Cache strategy revised to trace icon cache renewal
HIROSE Yuuji <yuuji@gentei.org>
parents: 405
diff changeset
305
403
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
306 cat<<EOF
283
fe73fb3f9f35 Duplicated id, fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 282
diff changeset
307 <tr id="$id">
420
0f6b4939ee8f Placehold link is not effective. So replace it to normal link.
HIROSE Yuuji <yuuji@gentei.org>
parents: 419
diff changeset
308 <td class="$tdcls">${picon}__EDIT__<a href="#$aid">#$aid</a>
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
309 <a href="$hlink+$uid">$uname</a>
287
422270e94adc New flag attached to `time' has low visibility. Attached to `td'.
HIROSE Yuuji <yuuji@gentei.org>
parents: 286
diff changeset
310 $tm
409
388639a80a23 Also notify rule in cached file should be generated dynamically.
HIROSE Yuuji <yuuji@gentei.org>
parents: 408
diff changeset
311 <__NOTIFY__></td>
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
312 EOF
403
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
313 echo -n "<td id=\"$aid\" class=\"repl\">"
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
314 echo "$hte"|unhexize|htmlescape|hreflink|minitbl
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
315 usecache='' tsfile=$td/$id.stamp
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
316 for i in $imgids; do
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
317 mrid=${i%%:*}; i=${i#*:}; sz=`size_h ${i%%:*}`
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
318 fn=`echo "${i#*:}"|unhexize`
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
319 fnb=$fn"(${sz})"
263
ebd4af16c493 Old blog dumping code based on sq -html, removed entirely
HIROSE Yuuji <yuuji@gentei.org>
parents: 261
diff changeset
320 case "$fn" in
407
4d912c2d48df Little bit spped up the judgement on necessity of cache re-creation
HIROSE Yuuji <yuuji@gentei.org>
parents: 406
diff changeset
321 *.[Pp][Nn][Gg]|*.[Jj][Pp][Gg]|*.[Jj][Pp][Ee][Gg]|*.[GgTt][Ii][Ff])
403
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
322 # fmt=${fn##*.} # convert - jpg:- is slow...why
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
323 case "$fn" in
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
324 *.[Pp][Nn][Gg]) fmt=png ;;
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
325 *.[Gg][Ii][Ff]) fmt=gif ;;
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
326 *) fmt=jpeg ;;
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
327 esac
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
328 outfile=$td/$mrid-${fn%.*}.$fmt
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
329 #err fn=$fn outfile=$outfile
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
330 #err "usecache=$usecache `ls -l $outfile`"
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
331 #err tm=$tm
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
332 #err tsfile=$tsfile=`cat $tsfile`
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
333 if [ -s "$outfile" ] && # $outfile should be > 0
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
334 { [ "$usecache" ] || # And usecache flag is true, or...
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
335 { [ -s "$tsfile" ] && [ x"`cat $tsfile`" = x"$tm" ]
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
336 };}; then
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
337 usecache=1 # Set usecache flag on
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
338 cat<<-EOF
264
9131c7e09112 Use cache file for article images.
HIROSE Yuuji <yuuji@gentei.org>
parents: 263
diff changeset
339 <a href="$catlink+$mrid"><img src="$outfile">
9131c7e09112 Use cache file for article images.
HIROSE Yuuji <yuuji@gentei.org>
parents: 263
diff changeset
340 $fnb</a>
9131c7e09112 Use cache file for article images.
HIROSE Yuuji <yuuji@gentei.org>
parents: 263
diff changeset
341 EOF
404
084a4d35c98f Create row stamp ONLY WHEN imgcache is active
HIROSE Yuuji <yuuji@gentei.org>
parents: 403
diff changeset
342 # !!NOTE!! Create row stamp ONLY WHEN imgcache is active
403
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
343 else
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
344 query "SELECT hex(bin) FROM article_m WHERE rowid=$mrid;" \
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
345 | unhexize \
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
346 | convert -define ${fmt}:size=100x100 -resize 100x100'>' \
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
347 - ${fmt}:- \
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
348 | tee "$outfile" \
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
349 | hexize \
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
350 | sed -e 's/\(..\)/%\1/g' \
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
351 -e "s|^|<a href=\"$catlink+$mrid\"><img src=\"data:image/$fmt,|" \
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
352 -e "s|\$|\">$fnb</a>|"
406
1af18eeeffb3 Cache strategy revised to trace icon cache renewal
HIROSE Yuuji <yuuji@gentei.org>
parents: 405
diff changeset
353 unset stampfile # img data stream is not suitable to cache
403
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
354 echo $tm > $tsfile
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
355 fi
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
356 ;;
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
357 *)
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
358 echo "<a href=\"$catlink+$mrid\"><img src=\"$deficon\">$fnb</a>"
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
359 ;;
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
360 esac
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
361 done
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
362 echo "</td></tr>"
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
363 } > "$cachefile" ######## New ROW Creation Ends here ########
406
1af18eeeffb3 Cache strategy revised to trace icon cache renewal
HIROSE Yuuji <yuuji@gentei.org>
parents: 405
diff changeset
364 test -n "$stampfile" && date "+%F %T" > $stampfile
403
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
365 fi
3ea86fe63490 Introduce row-cache for replyblog()
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
366 # Printing a cached row
409
388639a80a23 Also notify rule in cached file should be generated dynamically.
HIROSE Yuuji <yuuji@gentei.org>
parents: 408
diff changeset
367 sed -e "/^<td class=/s/__NEWCLS__/$new${new:+ }/" \
388639a80a23 Also notify rule in cached file should be generated dynamically.
HIROSE Yuuji <yuuji@gentei.org>
parents: 408
diff changeset
368 -e "/^<td class=/s,__EDIT__,$editlink," \
388639a80a23 Also notify rule in cached file should be generated dynamically.
HIROSE Yuuji <yuuji@gentei.org>
parents: 408
diff changeset
369 -e "/^<__NOTIFY__>/s,,${notify:+$nt}," \
408
138a0c6b09a7 Edit link in cached row file should be determined dynamically.
HIROSE Yuuji <yuuji@gentei.org>
parents: 407
diff changeset
370 $cachefile
263
ebd4af16c493 Old blog dumping code based on sq -html, removed entirely
HIROSE Yuuji <yuuji@gentei.org>
parents: 261
diff changeset
371 done
452
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
372
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
373 help="=== コメントに使用できる特殊記法 ===
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
374 行頭に href=URL でURLへのリンク
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
375 行頭に iframe=URL でURL先を開く iframe
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
376 [[#記事番号]] でs4内の記事番号に飛ぶリンク
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
377 [[URL]] でURLへのリンク
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
378 [[URL|文字列]] でアンカー文字列を指定してのURLリンク
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
379 {{画像URL}} でインライン画像
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
380 {{画像URL|幅}} でピクセル幅を指定したインライン画像
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
381 {{{URL}}} でURL先を開く iframe
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
382 {{{URL|高さ}}} でピクセル高さを指定した iframe
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
383 ## 大見出し
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
384 ### 中見出し
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
385 #### 小見出し"
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
386 touchhelp="${touchpanel:+<p class=\"help\">$help</p>}"
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
387 # touchhelp="<p class=\"help\">$help</p>"
193
5d83ff0bbd40 Comment area modified
HIROSE Yuuji <yuuji@gentei.org>
parents: 192
diff changeset
388 textform='<div class="fold">
341
bad68ea6c30a Add more accesskeys
HIROSE Yuuji <yuuji@gentei.org>
parents: 338
diff changeset
389 <input type="checkbox" id="cmt" checked><label
bad68ea6c30a Add more accesskeys
HIROSE Yuuji <yuuji@gentei.org>
parents: 338
diff changeset
390 accesskey="c" title="C" for="cmt">コメントする</label><div>
193
5d83ff0bbd40 Comment area modified
HIROSE Yuuji <yuuji@gentei.org>
parents: 192
diff changeset
391 <table class="b">
452
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
392 <tr><td><textarea name="text" cols="72" rows="4" title="'"$help"'">
30ab12e54324 Ballon help for s4-WikiStyle added
HIROSE Yuuji <yuuji@gentei.org>
parents: 451
diff changeset
393 </textarea>'"$touchhelp"'</td></tr>
205
6c63ea1b65d5 Add "accept" attribute to input:type="file"
HIROSE Yuuji <yuuji@gentei.org>
parents: 204
diff changeset
394 <tr><td>添付ファイル:
206
c761ce8ff963 Quoting changed
HIROSE Yuuji <yuuji@gentei.org>
parents: 205
diff changeset
395 <input type="file" name="image"'" $file_accept multiple></td></tr>"'
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
396 </table>
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
397 <input type="submit" value="送信">
193
5d83ff0bbd40 Comment area modified
HIROSE Yuuji <yuuji@gentei.org>
parents: 192
diff changeset
398 <input type="reset" value="リセット"></div></div>
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
399 '
219
e2dea2f63a69 Duplicate posting by reload avoided
HIROSE Yuuji <yuuji@gentei.org>
parents: 208
diff changeset
400 cat<<-EOF
239
25e0b1eaf04d Degrade fixed: Explicit notify works again.
HIROSE Yuuji <yuuji@gentei.org>
parents: 238
diff changeset
401 </table> <!-- end of s4-blog:blog_showentry() main table -->
219
e2dea2f63a69 Duplicate posting by reload avoided
HIROSE Yuuji <yuuji@gentei.org>
parents: 208
diff changeset
402 <p class="update_link"><a
341
bad68ea6c30a Add more accesskeys
HIROSE Yuuji <yuuji@gentei.org>
parents: 338
diff changeset
403 href="?reload/$rowid" accesskey="r" title="R">再読込</a> / <a
441
248a27a00265 Id="bottom" moved to the anchor of "To the top"
HIROSE Yuuji <yuuji@gentei.org>
parents: 436
diff changeset
404 href="#title" id="bottom" accesskey="t" title="T">先頭へ</a></p>
219
e2dea2f63a69 Duplicate posting by reload avoided
HIROSE Yuuji <yuuji@gentei.org>
parents: 208
diff changeset
405 EOF
e2dea2f63a69 Duplicate posting by reload avoided
HIROSE Yuuji <yuuji@gentei.org>
parents: 208
diff changeset
406 $iswritable && cat<<-EOF
e2dea2f63a69 Duplicate posting by reload avoided
HIROSE Yuuji <yuuji@gentei.org>
parents: 208
diff changeset
407 <div class="blogcomment">
239
25e0b1eaf04d Degrade fixed: Explicit notify works again.
HIROSE Yuuji <yuuji@gentei.org>
parents: 238
diff changeset
408 <input type="hidden" name="blogid" value="$id">
268
138da0f3a2e5 Duplicate post by reloading or back+submit, dissolved
HIROSE Yuuji <yuuji@gentei.org>
parents: 264
diff changeset
409 <input type="hidden" name="id" value="`genserial`">
239
25e0b1eaf04d Degrade fixed: Explicit notify works again.
HIROSE Yuuji <yuuji@gentei.org>
parents: 238
diff changeset
410 <input type="hidden" name="stage" value="replyblog">
25e0b1eaf04d Degrade fixed: Explicit notify works again.
HIROSE Yuuji <yuuji@gentei.org>
parents: 238
diff changeset
411 $textform
25e0b1eaf04d Degrade fixed: Explicit notify works again.
HIROSE Yuuji <yuuji@gentei.org>
parents: 238
diff changeset
412 </div>
25e0b1eaf04d Degrade fixed: Explicit notify works again.
HIROSE Yuuji <yuuji@gentei.org>
parents: 238
diff changeset
413 </form> <!-- End of s4-blog:blog_showentry() main form -->
25e0b1eaf04d Degrade fixed: Explicit notify works again.
HIROSE Yuuji <yuuji@gentei.org>
parents: 238
diff changeset
414 EOF
333
002cc900200a Nonexistent Icon cleaning is too heavy, put it after loop
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
415 # Clean up orphaned icon cache
406
1af18eeeffb3 Cache strategy revised to trace icon cache renewal
HIROSE Yuuji <yuuji@gentei.org>
parents: 405
diff changeset
416 [ -s $iconcleaner ] && query ".read '$iconcleaner'"
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
417 # Record access log
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
418 acclog blog $rowid
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
419 }
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
420
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
421 lshandout() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
422 # $1=rowid of blog
401
6dc23f0b7279 Allow lshandout on frozen board
HIROSE Yuuji <yuuji@gentei.org>
parents: 399
diff changeset
423 blog_writable $1 $user
6dc23f0b7279 Allow lshandout on frozen board
HIROSE Yuuji <yuuji@gentei.org>
parents: 399
diff changeset
424 r=$? # =0: writable, $BLOG_NOTMEM bit set => not member
6dc23f0b7279 Allow lshandout on frozen board
HIROSE Yuuji <yuuji@gentei.org>
parents: 399
diff changeset
425 if [ $((rc & $BLOG_NOTMEM)) -gt 0 ] ; then
64
54bbd7ce3766 Inhibit non-group-member from *handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 63
diff changeset
426 echo "メンバー以外は利用できません。" | html p; return
54bbd7ce3766 Inhibit non-group-member from *handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 63
diff changeset
427 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
428 time=`getvalbyid blog ctime $1|colrm 11`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
429 owner=`getvalbyid blog owner $1`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
430 title=`getvalbyid blog title $1`
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
431 ge=`gecos $owner`
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
432 fh=$tmpd/formhead
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
433 echo "$time [$title]@${ge:-$owner}" > $fh
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
434 lshandoutsub $owner "$@" \
189
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
435 |_m4 -D_TITLE_="提出状況" \
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
436 -D_FORMHEAD_="syscmd(cat $fh)" \
189
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
437 -D_FORM_="syscmd(cat)" -D_DUMPHEAD_= -D_DUMPTABLE_= \
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
438 $layout/html.m4.html $layout/form+dump-whead.m4.html
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
439 gn=`echo $owner|htmlescape`
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
440 echo "<p><a href=\"?lshandoutall+$1\">グループ $gn すべてのレポート板集計</a></p>"
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
441 }
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
442 gethandoutcsv() {
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
443 # contenttype; echo
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
444 CATCSV=1 lshandoutall "$1"
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
445 }
373
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
446 gethandoutcsv2() {
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
447 # contenttype; echo
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
448 SQL=$(cat<<-EOF) gethandoutcsv "$1"
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
449 WITH this_blog_articles AS (
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
450 SELECT rtb.id bid, rtb.brid, a.id aid, author, title, ctime
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
451 FROM report_type_blogs rtb JOIN article a ON rtb.id=a.blogid
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
452 ), text_or_file AS (
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
453 SELECT bid, author, title, ctime, 'text' shu, count(val) cnt
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
454 FROM this_blog_articles tba, article_s s
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
455 ON tba.aid=s.id
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
456 WHERE key='text'
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
457 GROUP by bid, author
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
458 UNION
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
459 SELECT bid, author, title, ctime, 'file' shu, count(val) cnt
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
460 FROM this_blog_articles tba, article_m m
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
461 ON tba.aid=m.id
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
462 WHERE key='image'
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
463 GROUP by bid, author
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
464 ), count_list AS (
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
465 SELECT author,
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
466 substr(ctime, 1, 10)||upper(substr(shu, 1, 1)) unit,
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
467 cnt
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
468 FROM text_or_file
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
469 )
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
470 SELECT gecos "名前",
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
471 substr(author, 1, instr(author, '@')-1) "uname",
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
472 unit,
374
59e31510f574 Avoid to use "count" as column name(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 373
diff changeset
473 cnt "post"
373
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
474 FROM count_list cl JOIN gecoses g ON cl.author=g.name;
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
475 EOF
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
476 }
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
477 lshandout_ulink_table() {
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
478 # NO Args. Read stdin as SQL
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
479 echo '<table class="b td3rr td3evw">'
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
480 hrb="<a href=\"?home+"
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
481 # echo "$sql" | sq -header -html $db \ # Formerly, this is called via sq()
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
482
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
483 printf ".mode html\n.header ON\n" | query
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
484 cat | query \
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
485 | sed -e "s,\(<TR><TD>\)\([^ ]*\) \(.*\)</TD>,\1$hrb\2\">\3</TD>," -e 's,<TD>0</TD>,<TD class="warn">0</TD>,'
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
486 echo '</table>'
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
487 printf ".mode list\n.header OFF\n" | query
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
488 }
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
489 lshandoutall() {
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
490 # $1=rowid of blog
402
58c291b6a81f Allow lshandoutall and gethandout on frozen board
HIROSE Yuuji <yuuji@gentei.org>
parents: 401
diff changeset
491 blog_writable $1 $user
58c291b6a81f Allow lshandoutall and gethandout on frozen board
HIROSE Yuuji <yuuji@gentei.org>
parents: 401
diff changeset
492 r=$? # =0: writable, $BLOG_NOTMEM bit set => not member
58c291b6a81f Allow lshandoutall and gethandout on frozen board
HIROSE Yuuji <yuuji@gentei.org>
parents: 401
diff changeset
493 if [ $((rc & $BLOG_NOTMEM)) -gt 0 ] ; then
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
494 echo "メンバー以外は利用できません。" | html p; return
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
495 fi
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
496 rowid=$(($1 + 0))
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
497 owner=`getvalbyid blog owner $1`
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
498 qowner=`sqlquotestr "$owner"`
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
499
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
500 query<<-EOF
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
501 CREATE TEMPORARY TABLE IF NOT EXISTS report_type_blogs AS
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
502 WITH blog_owner_mode AS (
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
503 SELECT id,
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
504 blog.rowid brid,
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
505 max(CASE key WHEN 'owner' THEN val END) owner,
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
506 max(CASE key WHEN 'mode' THEN val END) mode,
373
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
507 max(CASE key WHEN 'title' THEN val END) title,
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
508 max(CASE key WHEN 'ctime' THEN val END) ctime
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
509 FROM blog NATURAL JOIN blog_s
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
510 GROUP BY id
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
511 )
373
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
512 SELECT id, brid, title, ctime FROM blog_owner_mode
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
513 WHERE owner=$qowner AND mode LIKE '%report%';
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
514 /* ↑これでレポート形式の blogid 一覧を得る */
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
515 EOF
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
516 if [ -z "$CATCSV" ]; then
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
517 _m4 -D_TITLE_="提出状況" $layout/html.m4.html
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
518 ge=`gecos "$owner"`
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
519 tbls=""
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
520 grptxt=`echo "${ge:-$owner}"|htmlescape`
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
521 echo "<h1>$grptxt 書き込み状況一覧</h1>"
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
522 fi
375
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
523 if [ -z "$SQL" ]; then
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
524 bridlist=`query "SELECT brid FROM report_type_blogs;"`
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
525 for brid in $bridlist; do # Skip this loop if $SQL set
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
526 brid=$(($brid + 0)) # Ensure to be a number
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
527 [ $brid = 0 ] && continue
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
528 time=`getvalbyid blog ctime $brid|colrm 11`
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
529 title=`getvalbyid blog title $brid|htmlescape`
399
db25589d864c Add frozen tag to lshandoutall listings
HIROSE Yuuji <yuuji@gentei.org>
parents: 397
diff changeset
530 state=`getvalbyid blog state $brid|htmlescape`
375
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
531 tt="handout_$brid"
399
db25589d864c Add frozen tag to lshandoutall listings
HIROSE Yuuji <yuuji@gentei.org>
parents: 397
diff changeset
532 [ "$state" = "frozen" ] && frozen=" $FROZEN_TAG" || frozen=""
375
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
533 if [ -z "$CATCSV" ]; then
399
db25589d864c Add frozen tag to lshandoutall listings
HIROSE Yuuji <yuuji@gentei.org>
parents: 397
diff changeset
534 echo "<h2>$time - <a href=\"?replyblog+$brid\">$title</a>$frozen</h2>"
375
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
535 lshandoutsub "$owner" $brid "$tt"
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
536 else
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
537 lshandoutsub "$owner" $brid "$tt" >/dev/null # Only create temp.table
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
538 fi
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
539 tbls="$tbls${tbls:+ NATURAL JOIN }$tt"
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
540 done
b971fa6ebcb1 Do not call lshandoutsub if $SQL set(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 374
diff changeset
541 fi
373
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
542 sql=${SQL:-"SELECT * FROM $tbls;"}
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
543 if [ -z "$CATCSV" ]; then
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
544 echo "<hr><h2>総合</h2>"
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
545 echo "$sql" | lshandout_ulink_table
373
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
546 echo "<h2>総合(<a href=\"?gethandoutcsv+$rowid\">CSV</a>)</h2>"
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
547 printf ".mode csv\n.header ON\n" | query
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
548 echo '<pre class="list">'
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
549 echo "$sql" | query | sed 's/^"[0-9]* /"/'
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
550 echo "</pre>"
373
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
551 echo "<pre><a href=\"?gethandoutcsv2+$rowid\">縦持ちCSV</a></pre>"
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
552 else
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
553 contenttype "Application/CSV"
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
554 printf ".mode csv\n.header ON\n" | query >/dev/null
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
555 fn=report-count.csv
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
556 printf 'Content-Disposition: filename="%s"\n' "$fn"
379
1f62c51bed4f Remove debugging code
HIROSE Yuuji <yuuji@gentei.org>
parents: 375
diff changeset
557 outfile=$tmpd/out-$$.csv
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
558 echo "$sql" | query | sed 's/^"[0-9]* /"/' > $outfile
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
559 echo "Content-Length: " `cat $outfile | wc -c`; echo
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
560
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
561 cat $outfile
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
562 exit 0
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
563 fi
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
564 printf ".mode list\n.header OFF\n.separator |\n" | query
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
565 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
566 lshandoutsub() {
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
567 # $1=owner $2=rowid of blog &optional $3=temp_table name
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
568 qgname=`sqlquote "$1"`
436
e1bdad674c09 Quote arguments that hold group name.
HIROSE Yuuji <yuuji@gentei.org>
parents: 432
diff changeset
569 if isgroup "$1"; then
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
570 sample="(select user from grp_mem where gname=$qgname)"
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
571 else
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
572 sample="(select distinct author as user from arts)"
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 64
diff changeset
573 echo "(集計は板への投稿者のみ)" | html p
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
574 fi
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
575 tmpname="${3:-handout_$2}"
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
576 sql="CREATE TEMPORARY TABLE IF NOT EXISTS $tmpname AS
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
577 with arts as (select id,author from article \
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
578 where blogid=(select id from blog where rowid=$2))\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
579 select (select rowid from user where name=c0.user)||' '|| \
366
884cd7c66917 Use gecoses table instead of coalesce().
HIROSE Yuuji <yuuji@gentei.org>
parents: 365
diff changeset
580 (select gecos from gecoses where name=c0.user) as 'メンバー',\
373
57a2e6acf005 Add link to creating normalized csv(gethandoutcsv2)
HIROSE Yuuji <yuuji@gentei.org>
parents: 369
diff changeset
581 substr(c0.user, 1, instr(c0.user, '@')-1) 'uname',\
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
582 sum(case when c1.key is not null then 1 else 0 end)\
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
583 as '[$title] コメント記入',\
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
584 sum(case when c2.key is not null then 1 else 0 end)\
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
585 as '[$title] ファイルの提出'\
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
586 from $sample c0 \
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
587 left join (select id,author from arts) a\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
588 on c0.user=a.author\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
589 left join (select id,key from article_s where key='text') c1\
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
590 on a.id=c1.id left join (select id,key from article_m ) c2\
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
591 on c1.id=c2.id group by c0.user order by c0.user;\
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
592 \
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
593 SELECT * FROM $tmpname;"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
594 err ishandoutsub: sql="$sql"
369
5f01ead0174f Add feature of scoring up all report-style blogs.
HIROSE Yuuji <yuuji@gentei.org>
parents: 367
diff changeset
595 echo "$sql" | lshandout_ulink_table
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
596 }
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
597 gethandout() {
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
598 # $1=rowid of blog
402
58c291b6a81f Allow lshandoutall and gethandout on frozen board
HIROSE Yuuji <yuuji@gentei.org>
parents: 401
diff changeset
599 blog_writable $1 $user
58c291b6a81f Allow lshandoutall and gethandout on frozen board
HIROSE Yuuji <yuuji@gentei.org>
parents: 401
diff changeset
600 r=$? # =0: writable, $BLOG_NOTMEM bit set => not member
58c291b6a81f Allow lshandoutall and gethandout on frozen board
HIROSE Yuuji <yuuji@gentei.org>
parents: 401
diff changeset
601 if [ $((rc & $BLOG_NOTMEM)) -gt 0 ] ; then
64
54bbd7ce3766 Inhibit non-group-member from *handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 63
diff changeset
602 echo "メンバー以外は利用できません。" | html p; return
54bbd7ce3766 Inhibit non-group-member from *handout
HIROSE Yuuji <yuuji@gentei.org>
parents: 63
diff changeset
603 fi
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
604 i=0
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
605 bd=$tmpd/archive.$$
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
606 mkdir $bd
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
607 query "select m.rowid,author,m.val from article a join article_m m\
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
608 on a.id=m.id where blogid=(select id from blog where rowid=$1)\
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
609 and m.key in ('image', 'document', 'binary');" \
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
610 | while IFS='|' read rowid author filename; do
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
611 err isfilereadable $user article_m $rowid
63
da23cad20e4a Permission check fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 59
diff changeset
612 isfilereadable $user article_m $rowid || continue
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
613 err ok
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
614 i=$((i+1))
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
615 dir=`printf $bd/%03d $i`
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
616 mkdir $dir
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
617 query "select quote(bin) from article_m where rowid=$rowid;" \
8
3db7524d3dea Add default images
HIROSE Yuuji <yuuji@gentei.org>
parents: 4
diff changeset
618 | unhexize > $dir/$filename
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
619 done
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
620 if [ ! -d $bd/001 ]; then
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
621 contenttype; echo
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 64
diff changeset
622 echo "取得できるファイルがありませんでした。" | html p
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
623 return
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
624 fi
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
625 (cd $bd
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
626 ## err cdto$bd; (pwd; ls -lFa) 1>&3
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
627 tar zcf .archive.tar.gz * && mv .archive.tar.gz archive.tar.gz
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
628 err Creating tar archive "`ls -l archive.tar.gz`"
2
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
629 )
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
630 arc=$bd/archive.tar.gz
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
631 echo "Content-type: application/x-gzip"
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
632 echo "Content-Length: `cat $arc|wc -c`"
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
633 echo "Content-Disposition: filename=\"archive.tar.gz\""
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
634 echo
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
635 cat $arc
7aa52f9874ae .hgignore added
HIROSE Yuuji <yuuji@gentei.org>
parents: 0
diff changeset
636 }
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
637 lsmyfile() { # $1(optional)=SortBy
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
638 case "$1" in
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
639 ""|CTIME-DESC)
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
640 by="CTIME" ord="DESC" ;;
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
641 CTIME*) by="CTIME" ;;
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
642 FILE*) by="FILE" ;;
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
643 OWNER*) by="OWNER" ;;
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
644 TITLE*) by="TITLE" ;;
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
645 esac
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
646 case "$1" in
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
647 *DESC) ord="DESC" ;;
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
648 esac
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
649 case "$ord" in
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
650 DESC) lkod="" jord="降順" ;;
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
651 *) lkod="-DESC" jord="昇順" ;;
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
652 esac
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
653 sql="select m.val||'/'||m.rowid FILE,
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
654 coalesce(
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
655 case when (select name from user where name=bs.owner)
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
656 is not null
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
657 then (select val from user_s where name=bs.owner
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
658 and key='gecos')
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
659 when (select gname from grp where gname=bs.owner)
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
660 is not null
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
661 then (select val from grp_s where gname=bs.owner
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
662 and key='gecos')
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
663 else
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
664 null
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
665 end,
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
666 bs.owner
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
667 ) OWNER,
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
668 a_s.val CTIME,
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
669 ',t,'||bs.title||':'||b.rowid||'#'||a.id TITLE
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
670 from (select rowid,id,val from article_m where id
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
671 in (select id from article where author='$user')
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
672 and type like 'file:%')
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
673 m left join article a on m.id=a.id
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
674 left join article_s a_s on a.id=a_s.id and a_s.key='ctime'
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
675 left join (select id,
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
676 max(case key when 'owner' then val end) as owner,
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
677 max(case key when 'title' then val end) as title
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
678 from blog_s group by id)
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
679 bs on a.blogid=bs.id
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
680 left join blog b on bs.id=b.id
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
681 where m.val is not null order by $by $ord;"
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
682 err lshandoutbyauthor: sql=`echo "$sql"`
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
683 title="個人提出ファイル"
189
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
684 _m4 -D_TITLE_=$title $layout/html.m4.html
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
685 hra="<a href=\"?lsmyfile+"
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
686 hrb="<a href=\"?showattc+article_m+"
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
687 hrc="<a href=\"?replyblog+"
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
688 (echo '<table class="b">'
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
689 echo "$sql"|sq -html -header $db ) \
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
690 | sed -e "s|\(<TR><TD>\)\([^/]*\)/\([0-9]*\)|\1$hrb\3\">\2</a>|" \
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
691 -e "s|,t,\(.*\):\([^<]*\)\(</TD>\)|$hrc\2\">\1</a>\3|" \
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
692 -e "s|\(<TH>\)\([A-Z]*\)\(</TH>\)|\1$hra\2$lkod\">\2</a>|" \
189
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
693 | _m4 -D_TITLE_=$title -D_FORM_="<p>($by$jord)</p>" \
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
694 -D_DUMPTABLE_="syscmd(cat)" $layout/form+dump.m4.html
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
695 echo '</table>'
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
696 }
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
697 searchart() {
301
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 293
diff changeset
698 kwd=`getpar kwd|nkf -wZ1` # Convert Zenkaku-SPC to ASCII-SPC
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 293
diff changeset
699 kwdgrp=""
337
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
700 authcond=""
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
701 if [ -z "$kwd" ]; then
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
702 echo "検索語を指定してください" | html p; return
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
703 fi
301
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 293
diff changeset
704 if expr x"$kwd" : 'x#[1-9][0-9]*$' >/dev/null 1>&2; then
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 293
diff changeset
705 # Like '#1234', assume as artID
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 293
diff changeset
706 rowid=$((${kwd#\#} + 0)) # Force to be a number
337
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
707 kc="ar.rowid = $rowid"
301
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 293
diff changeset
708 else
344
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
709 for k in `echo "$kwd" | sed "s/'/''/g"`; do # With wrap quotes
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
710 if expr x"$k" : 'x@[><= ]*[1-9][][0-9]*-[][0-9:-]*$' >/dev/null >&2; then
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
711 # '@<2016-10-10' -> ctime < '2016-10-10'
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
712 # '@>=2016-10-10' -> ctime >= '2016-10-10'
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
713 # '@2016-10-10' -> ctime GLOB '@2016-10-10'
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
714 k=${k#@}
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
715 case "$k" in
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
716 [\<\>]*) op=${k%%[!<>=]*}; ctime=${k##*[><= ]} ;;
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
717 *) op='GLOB'; ctime="${k##*[><= ]}*" ;;
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
718 esac
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
719 kc=$kc${kc:+" AND "}"ctime $op '${ctime}'"
301
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 293
diff changeset
720 # Not sure GROUP BY a.blogid is comfortable for searchers...?
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 326
diff changeset
721 ##### kwdgrp=" GROUP BY a.blogid" ## Add this to lessen results
304
ab11a49bd64e Sort search result by "DATE DESC, TITLE, x.ctime"
HIROSE Yuuji <yuuji@gentei.org>
parents: 303
diff changeset
722 elif [ x"$k" = x"@today" -o x"$k" = x"@今日" ]; then
ab11a49bd64e Sort search result by "DATE DESC, TITLE, x.ctime"
HIROSE Yuuji <yuuji@gentei.org>
parents: 303
diff changeset
723 ctime=`date +%F`
337
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
724 kc=$kc${kc:+" AND "}"ctime GLOB '${ctime}*'"
344
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
725 elif [ x"$k" = x"@week" ]; then
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
726 ctime=`query "SELECT datetime('now', 'localtime', '-7 days');"`
7ff49d1c2987 Support '<', '>' for date search keyword
HIROSE Yuuji <yuuji@gentei.org>
parents: 341
diff changeset
727 kc=$kc${kc:+" AND "}"ctime > '${ctime}'"
352
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
728 elif [ x"$k" = x"@month" ]; then
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
729 ctime=`query "SELECT datetime('now', 'localtime', '-1 month');"`
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
730 kc=$kc${kc:+" AND "}"ctime > '${ctime}'"
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
731 elif [ x"$k" = x"@year" ]; then
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
732 ctime=`query "SELECT datetime('now', 'localtime', '-1 year');"`
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
733 kc=$kc${kc:+" AND "}"ctime > '${ctime}'"
301
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 293
diff changeset
734 else
333
002cc900200a Nonexistent Icon cleaning is too heavy, put it after loop
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
735 kc=$kc${kc:+" AND "}"content LIKE '%$k%'"
301
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 293
diff changeset
736 fi
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 293
diff changeset
737 done
ba0730073d6f Add (1)article-ID search, (2)DATE search
HIROSE Yuuji <yuuji@gentei.org>
parents: 293
diff changeset
738 fi
165
4040bb8b2038 quote search kwd. $SMAIL_TO controls To: header value.
HIROSE Yuuji <yuuji@gentei.org>
parents: 162
diff changeset
739 kwd=`echo "$kwd"|htmlescape`
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
740 owner=`getpar owner`
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
741 owner=${owner:-$1}
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
742 echo "「$kwd」による検索結果" | html p
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
743 if [ -n "$owner" ]; then
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
744 cond="where key='owner' and val='$owner'"
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
745 if isuser $owner; then
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
746 echo "(`linkhome $owner` さんの記録からの検索)" | html p
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
747 else
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
748 linkhome $owner 1>&3
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
749 echo "(`linkhome $owner` グループからの検索)" | html p
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
750 fi
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 326
diff changeset
751 elif { author=`getpar author`; test -n "$author"; }; then
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 326
diff changeset
752 atptn=`sqlquotestr $author`
337
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
753 #kc="$kc${kc:+ AND }author=$atptn"
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
754 authcond="WHERE author=$atptn"
331
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 326
diff changeset
755 if isuser $author; then
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 326
diff changeset
756 echo "(`linkhome $author` さんの書き込みからの検索)" | html p
1a60dfc56bb0 Search form in other user's home restrict author to that one.
HIROSE Yuuji <yuuji@gentei.org>
parents: 326
diff changeset
757 fi
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
758 fi
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
759 # article_s: id=article-id, key='text', val='TEXT'
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
760 # article: id=article-id, blogid=blogkd
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
761 # blog: id=blog-id, author=LeaderAuthor
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
762 # blog_s: id=blog-id, key='title', val='BLOG-TITLE'
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
763 # WANT: blog-ROWid,article-id,val(TEXT)
337
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
764 sql2="`sql4readableblogs` -- Extract user-readable blogs
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
765 -- 0.3sec
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
766 WITH artsm AS (
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
767 SELECT a.id,ctime, text || ' ' || coalesce(files, '') content
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
768 FROM article a
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
769 LEFT JOIN
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
770 (SELECT ars.id, ctime, text, coalesce(files, '') files
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
771 FROM (SELECT id,
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
772 max(CASE key WHEN 'ctime' THEN val END) ctime,
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
773 max(CASE key WHEN 'text' THEN val END) text
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
774 FROM article_s
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
775 GROUP BY id) ars
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
776 LEFT JOIN
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
777 (SELECT id, group_concat(val) files
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
778 FROM article_m
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
779 WHERE type LIKE 'file:%'
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
780 GROUP BY id) arm
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
781 ON ars.id=arm.id
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
782 ) ar
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
783 ON a.id=ar.id
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
784 ), ar AS (
338
291a3eeed05e Show author in search result
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
785 SELECT a.rowid, a.blogid, a.id, a.author, ctime, content
291a3eeed05e Show author in search result
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
786 FROM article a JOIN artsm ON a.id=artsm.id
337
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
787 $authcond
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
788 ), bl AS (
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
789 SELECT blg.rid, blg.*, blog_s.val TITLE
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
790 FROM readableblogs blg JOIN blog_s ON blg.id=blog_s.id AND blog_s.key='title'
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
791 )
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
792 SELECT bl.rid||'#'||ar.id '',
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
793 bl.title TITLE,
338
291a3eeed05e Show author in search result
HIROSE Yuuji <yuuji@gentei.org>
parents: 337
diff changeset
794 (SELECT gecos FROM gecoses WHERE name=ar.author) AUTHOR,
337
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
795 substr(ctime, 0, 11) DATE,
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
796 substr(content, 0, 78) TEXT
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
797 FROM ar JOIN bl
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
798 ON ar.blogid=bl.id
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
799 WHERE $kc AND bl.id IN (SELECT id FROM blog_s $cond)
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
800 ORDER by DATE DESC, TITLE, ctime;"
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
801 sedopt="s,<TR><TD>\([^<]*\)</TD>,<TR><TD><a\
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
802 href=\"?replyblog+\1\">VIEW</a></TD>,"
337
48d0b6c4de65 Revise SQL for article search drastically for speed.
HIROSE Yuuji <yuuji@gentei.org>
parents: 336
diff changeset
803 # echo "$sql2" > tmp/sql.out
352
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
804 result=$tmpd/result.$$
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
805 cat<<EOF
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
806 <table class="b searchart">
352
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
807 `sq -header -html $db "$sql2"|sed "$sedopt"|tee $result`
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
808 </table>
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
809 EOF
352
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
810 if [ -s "$result" ]; then
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
811 found=$((`grep "^<TR><TD>" $result | wc -l` + 0)) # Cast to INT
352
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
812 one=${found%1}
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
813 echo "$found match${one:+es} found"
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
814 else
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
815 echo orz...
dd0c70353869 More HELP text for search form. Add search result report.
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
816 fi
78
0cbbb0874eb5 Code cleaning
HIROSE Yuuji <yuuji@gentei.org>
parents: 72
diff changeset
817 }
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
818 listblog() (
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 64
diff changeset
819 # $1={user,group}
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 64
diff changeset
820 qow=`sqlquote $1`
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 64
diff changeset
821 cond="where a.id in (select id from blog_s where key='owner' and val=$qow) order by ctime desc"
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
822 DT_CHLD=article:blogid
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
823 cgi_form searchart<<EOF
128
42234d2d6e9c Add Full-Range search
HIROSE Yuuji <yuuji@gentei.org>
parents: 122
diff changeset
824 <label>`cgi_text kwd`という語を含む記事をこの一覧から検索</label>
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
825 `cgi_hidden owner $user`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
826 EOF
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
827 dumptable html blog 'ctime title heading' "$cond"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
828 )
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
829
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
830 blog_addentry() {
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
831 # $1=GRPname(if it is a group)
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 13
diff changeset
832 grprowid=$1
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
833 rowid=`getpar rowid`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
834 ## err blog_addentry0: rowid=$rowid
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
835 if [ -n "$grprowid" ]; then
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
836 owner=`getgroupbyid $grprowid`
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
837 else
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
838 owner=`getpar owner`
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
839 fi
122
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 117
diff changeset
840 err blog-add: \$1=$1 rowid=$rowid owner=$owner
436
e1bdad674c09 Quote arguments that hold group name.
HIROSE Yuuji <yuuji@gentei.org>
parents: 432
diff changeset
841 if isgroup "$owner"; then
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
842 groupmode=1 listing=$owner guide="[${owner}]" GF_OWNER=$owner
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
843 else
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
844 usermode=1 listing=$user guide="[個人]"
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
845 fi
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
846
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
847 if [ -n "`getpar title`" ]; then
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
848 if [ "$usermode" ]; then
122
0681534f9451 When deleting group, remove all blos that belong it.
HIROSE Yuuji <yuuji@gentei.org>
parents: 117
diff changeset
849 err usermode: user=$user owner=$owner
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
850 if [ x"$user" != x"$owner" ]; then
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 64
diff changeset
851 echo "他人の日記は書けません" | html p
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
852 return 2
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
853 fi
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
854 elif [ "$groupmode" ]; then # if write to group log
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
855 grp=$owner #\`getpar grp\`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
856 err ismember: $user $grp
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
857 if ! ismember "$user" "$grp"; then
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 64
diff changeset
858 echo "(話題作成はこのグループに加入してから)" | html p
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
859 return 3
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
860 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
861 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
862 par2table $formdir/blog.def
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
863 serial=`getpar serial`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
864 ## err SERIAL: $serial ROWID=$rowid listing=$listing
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
865 id=""
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
866 if [ -n "$rowid" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
867 # Here, id becomes NULL when removal of entries at par2table
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
868 id=`query "select rowid from blog where rowid=$rowid;"`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
869 elif [ -n "$serial" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
870 # If new blog leader created, traverse to its head.
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
871 id=`query "select rowid from blog where id='$serial';"`
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
872 ## err new-Leader: "select rowid from blog where id='$serial';" id=$id
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
873 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
874 if [ -n "$id" ]; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
875 ## If new aritcle is entered, JUMP to blog_reply
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
876 blog_reply $id
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
877 return
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
878 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
879 fi
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
880 echo "${guide}新規話題作成" > $tmpd/title.$$
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
881 listblog $listing > $tmpd/listblog.$$
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
882 genform $formdir/blog.def \
189
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
883 | _m4 -D_TITLE_="spaste(\`$tmpd/title.$$')" \
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
884 -D_FORMHEAD_="序文は簡単に詳しくはコメントに" \
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
885 -D_DUMPHEAD_="これまでの蓄積" \
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
886 -D_FORM_="syscmd(\`cat')" \
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
887 -D_DUMPTABLE_="spaste(\`$tmpd/listblog.$$')" \
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
888 $layout/html.m4.html \
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
889 $layout/form+dump-whead.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
890 }
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
891
379
1f62c51bed4f Remove debugging code
HIROSE Yuuji <yuuji@gentei.org>
parents: 375
diff changeset
892 blog_reply() { # Posting to blog article
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
893 rowid=$1
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
894
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
895 if [ -z "$rowid" ]; then
67
3b70f847277e Rearrangement
HIROSE Yuuji <yuuji@gentei.org>
parents: 64
diff changeset
896 echo "表示する日記番号が未指定です。" | html p
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
897 return
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
898 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
899 title=`getvalbyid blog title $rowid`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
900 owner=`getvalbyid blog owner $rowid`
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
901 if [ -z "$title" ]; then
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
902 echo "日記番号指定が無効です。" | html p
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
903 return
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
904 fi
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
905 blog_writable $rowid $user; rc=$?
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
906 if [ $rc = 0 ]; then
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
907 iswritable=true
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
908 else
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
909 iswritable=false
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
910 if [ $((rc & $BLOG_FROZEN)) -gt 0 ]; then
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
911 isfrozen=true
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
912 frozen_class='frozen"'
399
db25589d864c Add frozen tag to lshandoutall listings
HIROSE Yuuji <yuuji@gentei.org>
parents: 397
diff changeset
913 frozen_flag=$FROZEN_TAG
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
914 fi
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
915 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
916 if isuser "$owner"; then
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
917 subtitle="`gecos $owner` さんの話題"
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
918 else
16
636df1c1bdf2 Track group by rowid in URLs
HIROSE Yuuji <yuuji@gentei.org>
parents: 13
diff changeset
919 grprowid=`query "select rowid from grp where gname=\"$owner\";"`
341
bad68ea6c30a Add more accesskeys
HIROSE Yuuji <yuuji@gentei.org>
parents: 338
diff changeset
920 subtitle="グループ
bad68ea6c30a Add more accesskeys
HIROSE Yuuji <yuuji@gentei.org>
parents: 338
diff changeset
921 <a href=\"?grp+$grprowid\" accesskey=\"h\" title=\"H\">$owner</a> での話題
222
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
922 `query \"SELECT printf('(チーム:%s)', val)\
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
923 FROM blog_s
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
924 WHERE id=(SELECT id FROM blog WHERE rowid=$rowid)
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
925 AND key='team';
d320c73bf16f Add "team" attributes in groups.
HIROSE Yuuji <yuuji@gentei.org>
parents: 219
diff changeset
926 \"|htmlescape`"
288
d50996dc2664 Function `grpaction' should be provided with moderated/ismember class
HIROSE Yuuji <yuuji@gentei.org>
parents: 287
diff changeset
927 memclass=`grp_getbodyclass "$owner"`
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
928 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
929
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
930 text=`getpar text`
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
931 if [ -n "$text" ]; then
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
932 if $iswritable; then
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
933 par2table $formdir/article.def
356
c087423c8234 Most of debugging code deactivated
HIROSE Yuuji <yuuji@gentei.org>
parents: 352
diff changeset
934 st=$?
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
935 case $st in
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
936 0|4)
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
937 [ "$st" = "4" ] && act="書込削除"
386
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 381
diff changeset
938 blog_notify_reply $rowid $user "$text" $act
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 381
diff changeset
939 if [ -n "$grprowid" ]; then
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 381
diff changeset
940 qgrp=$(sqlquote "$owner")
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 381
diff changeset
941 dbsetbyid grp $owner wtime "`date '+%F %T'`"
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 381
diff changeset
942 fi
606404fbb3d3 Sort group list by posting time(wtime)
HIROSE Yuuji <yuuji@gentei.org>
parents: 381
diff changeset
943 ;;
80
39e69daa2071 New feature "lsmyfile" added
HIROSE Yuuji <yuuji@gentei.org>
parents: 78
diff changeset
944 esac
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
945 else
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
946 if $isfrozen; then
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
947 title="$title(凍結板につき書き込み不可)"
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
948 else
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
949 title="$title(加入してないので書き込み不可)"
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
950 fi
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
951 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
952 fi
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
953 def=$formdir/article.def
81
ddc8a4c0b8d9 All macro-expanding by m4 bypassed via syscmd or spaste
HIROSE Yuuji <yuuji@gentei.org>
parents: 80
diff changeset
954 echo "$title" > $tmpd/title.$$
397
e9e8b4d40220 Add feature of `frozen state' of the blog board
HIROSE Yuuji <yuuji@gentei.org>
parents: 386
diff changeset
955 echo "$subtitle$frozen_flag" > $tmpd/subtitle.$$
154
75598f2d3118 TEST: blog_showentry2 - constructing loop by output from single SQL
HIROSE Yuuji <yuuji@gentei.org>
parents: 138
diff changeset
956 ${BLOG_SHOW:-blog_showentry} blog $rowid \
259
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 250
diff changeset
957 | _m4 -D_TITLE_="spaste(\`$tmpd/title.$$')" \
85a001a9c7c5 Make it visible: the group is moderated; the user is a member of the group
HIROSE Yuuji <yuuji@gentei.org>
parents: 250
diff changeset
958 -D_BODYCLASS_=general"${memclass:+ $memclass}" \
189
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
959 -D_FORMHEAD_="spaste(\`$tmpd/subtitle.$$')" \
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
960 -D_FORM_='' \
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
961 -D_DUMPTABLE_="syscmd(cat)" -D_DUMPHEAD_="" \
972cb5ab0c5f Rename m4 to _m4
HIROSE Yuuji <yuuji@gentei.org>
parents: 184
diff changeset
962 $layout/html.m4.html $layout/form+dump-whead.m4.html
0
b8a890828283 add se-blog.sh se-cgi.sh se-funcs.sh se-init.sh mpsplit.rb
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
963 }
451
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
964
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
965 blog_reply_article() { # Direct link to article in some blog
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
966 arid=${1:-0} # Already sanitized to digits
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
967 brid=`query "SELECT rowid FROM blog WHERE \
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
968 id=(SELECT blogid FROM article WHERE rowid=$arid);"`
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
969 if [ -n "$brid" ]; then
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
970 newurl="?replyblog+$brid#$arid"
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
971 echo "Refresh: 0; $newurl"; echo
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
972 exit 0
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
973 else
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
974 contenttype; echo
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
975 echo "無効な記事番号です." | html p
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
976 fi
8965bdad3172 Add convenient link pattern [[#ArticleId]] for direct link to articles.
HIROSE Yuuji <yuuji@gentei.org>
parents: 446
diff changeset
977 }

yatex.org