File: speed_comment.rb

package info (click to toggle)
tdiary 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,088 kB
  • sloc: ruby: 23,031; javascript: 1,029; xml: 325; makefile: 26; sh: 4
file content (67 lines) | stat: -rw-r--r-- 2,415 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# speed_comment.rb
#
# spped_comment: 最新・月毎表示時に簡易なツッコミフォームを表示する
#                pluginディレクトリに入れるだけで動きます。
#
# Copyright (c) 2002 TADA Tadashi <sho@spc.gr.jp>
# Distributed under the GPL2 or any later version.
#
=begin ChangeLog
2003-09-24 TADA Tadashi <sho@spc.gr.jp>
	* support cookie for name.
	* support conf_proc.

2002-03-24 TADA Tadashi <sho@spc.gr.jp>
	* suppress output in mobile mode.

2002-03-12 TADA Tadashi <sho@spc.gr.jp>
	* support insert into @header.
=end

add_body_leave_proc do |date|
	if /latest|month/ =~ @mode
		@conf['speed_comment.name_size'] = 20 unless @conf['speed_comment.name_size']
		@conf['speed_comment.body_size'] = 40 unless @conf['speed_comment.body_size']
		r = ""
		r << %Q[<div class="form"><form method="post" action="#{h( @index )}"><p>]
		r << %Q[<input type="hidden" name="date" value="#{h( date.strftime( '%Y%m%d' ) )}">]
		r << %Q[<input type="hidden" name="mail" value="">]
		r << %Q[#{h( comment_name_label )} : <input class="field" name="name" size="#{@conf['speed_comment.name_size']}" value="#{h( @conf.to_native(@cgi.cookies['tdiary'][0] || '' ))}">]
		r << %Q[#{h( comment_body_label )} : <input class="field" name="body" size="#{@conf['speed_comment.body_size']}">]
		r << %Q[<input type="submit" name="comment" value="#{h( comment_submit_label )}">]
		r << %Q[</p></form></div>]
	else
		''
	end
end

unless @resource_loaded then
	def speed_comment_label
		'簡易ツッコミ'
	end

	def speed_comment_html
		<<-HTML
		<h3>簡易ツッコミフォームのサイズ</h3>
		<p>名前欄: <input name="speed_comment.name_size" size="5" value="#{h( @conf['speed_comment.name_size'] ) || 20}"></p>
		<p>本文欄: <input name="speed_comment.body_size" size="5" value="#{h( @conf['speed_comment.body_size'] ) || 40}"></p>
		HTML
	end
end

add_conf_proc( 'speed_comment', speed_comment_label ) do
	if @mode == 'saveconf' then
		@conf['speed_comment.name_size'] = @cgi.params['speed_comment.name_size'][0].to_i
		@conf['speed_comment.name_size'] = 20 if @conf['speed_comment.name_size'] < 1
		@conf['speed_comment.body_size'] = @cgi.params['speed_comment.body_size'][0].to_i
		@conf['speed_comment.body_size'] = 40 if @conf['speed_comment.body_size'] < 1
	end
	speed_comment_html
end

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End: