TAKANO Mitsuhiro
tak****@no32*****
2005年 7月 15日 (金) 02:37:09 JST
はじめまして,こんにちは 高野です. commentプラグインで日時や名前を省略してコメントするために comment_simple, rcomment_simpleというメソッドを追加してみました. (単純にコメントだけを "* コメント" という形で追加するメソッドです.) おまけとして(r)?comment_no_user, (r)?comment_no_dateなんていう メソッドも作ってみましたが,こちらはあまり利用価値がないかもです. よろしければ,お使いください. Index: comment.rb =================================================================== --- comment.rb (リビジョン 11) +++ comment.rb (作業コピー) @@ -5,21 +5,27 @@ add_body_enter_proc(Proc.new do @comment_num = 0 + @comment_reverse = 0b001 + @comment_no_name = 0b010 + @comment_no_date = 0b100 "" end) def comment(cols = 60, style = 0) cols = 60 unless cols.respond_to?(:integer?) style = 0 unless style.respond_to?(:integer?) - style = 0 if style != 1 + style = 0 unless (0..7).include?(style) + reverse = style & @comment_reverse != 0 + no_name = style & @comment_no_name != 0 + no_date = style & @comment_no_date != 0 @comment_num += 1 name = @user || '' <<EOS <form action="#{@conf.cgi_name}" method="post"> <div> - #{comment_name_label}: - <input type="text" name="name" value="#{name}" size="10"> + #{no_name ? '':comment_name_label+':'} + <input type="#{no_name ? 'hidden':'text'}" name="name" value="#{name}" size="10"> #{comment_comment_label}: <input type="text" name="msg" size="#{cols}"> <input type="submit" name="comment" value="#{comment_post_label}"> @@ -39,6 +45,9 @@ name = params['name'][0].size == 0 ? comment_anonymous_label : params['name'][0] msg = params['msg'][0] style = params['style'][0].to_i + reverse = style & @comment_reverse != 0 + no_name = style & @comment_no_name != 0 + no_date = style & @comment_no_date != 0 return '' if msg.strip.size == 0 @@ -52,9 +61,13 @@ lines.each do |l| if /^\{\{r?comment.*\}\}/ =~ l && flag == false if count == comment_no - content << l if style == 1 - content << "*#{format_date(Time::now)} #{name} : #{msg}\n" - content << l if style == 0 + content << l if reverse + content << "*" + content << "#{format_date(Time::now)} " unless no_date + content << "#{name} " unless no_name + content << ": " unless no_date && no_name + content << "#{msg}\n" + content << l unless reverse flag = true else count += 1 @@ -69,5 +82,37 @@ end def rcomment(cols = 60) - comment(cols, 1) + style = @comment_reverse + comment(cols, style) end + +def comment_no_name(cols = 60) + style = @comment_no_name + comment(cols, style) +end + +def rcomment_no_name(cols = 60) + style = @comment_reverse | @comment_no_name + comment(cols, style) +end + +def comment_no_date(cols = 60) + style = @comment_no_date + comment(cols, style) +end + +def rcomment_no_date(cols = 60) + style = @comment_reverse | @comment_no_date + comment(cols, style) +end + +def comment_simple(cols = 60) + style = @comment_no_name | @comment_no_date + comment(cols, style) +end + +def rcomment_simple(cols = 60) + style = @comment_reverse | @comment_no_name | @comment_no_date + comment(cols, style) +end + -- TAKANO Mitsuhiro <tak****@no32*****> http://taka.no32.tk/