# comment_check.rb $Revision:$ # # Copyright(c) 2008 arton # You can redistribute it and/or modify it under GPL2. # @comment_check_caption_title = "caption for the checkbox" @comment_check_label_conf = "comment check" # # ### useless override # #def update_proc # unless @cgi.params['xishuman'][0] && @cgi.valid?('xishuman') # raise PermissionError.new # end #end # # No, it's too late to raise the exception, because TDiaryComment saves spam in the # constructor. # So, you must modify index.rb # ie) =begin $ diff -u -p index.rb~ index.rb --- index.rb~ 2008-09-06 23:03:09.268151242 +0900 +++ index.rb 2008-09-17 23:41:51.460322030 +0900 @@ -28,7 +28,11 @@ begin begin if @cgi.valid?( 'comment' ) then - tdiary = TDiary::TDiaryComment::new( @cgi, "day.rhtml", conf ) + if @cgi.valid?('xishuman') and @cgi.params['xishuman'][0] + tdiary = TDiary::TDiaryComment::new( @cgi, "day.rhtml", conf ) + else + raise TDiary::PermissionError.new + end elsif @cgi.valid?( 'date' ) date = @cgi.params['date'][0] if /^\d{8}-\d+$/ =~ date then =end # # def comment_check_caption begin if @conf['comment_check.caption'].length > 0 then return @conf['comment_check.caption'] end rescue end "check if you'd like to post comments" end # # override 00default.rb # def comment_form_text r = '' unless @conf.hide_comment_form then r = <<-FORM
FORM if @diaries[@date.strftime('%Y%m%d')].count_comments( true ) >= @conf.comment_limit_per_day then r << <<-FORM
#{comment_limit_label}
FORM else r << <<-FORM
#{comment_description}
#{comment_check_caption}
#{comment_name_label}:
#{comment_mail_label}:
#{comment_body_label}:
FORM end r << <<-FORM
FORM end r end # # install configuration proc for the caption # add_conf_proc('comment_check', @comment_check_label_conf) do comment_check_conf_proc end def comment_check_conf_proc if @mode == 'saveconf' then @conf['comment_check.caption'] = @cgi.params['comment_check.caption'][0] end <<-HTML

#{@comment_check_caption_title}

HTML end