<commit_before># Copyright (C) 2009 <NAME>.

class Feedback::CommentsFeature < ParagraphFeature

  feature :comments_page_comments, :default_feature => <<-FEATURE
      <br/><br/>
      <cms:add_comment>
        <cms:errors><div class='errors'><cms:value/></div></cms:errors>
        <cms:not_logged_in>Name:<br/><cms:name/><br/></cms:not_logged_in>
        <cms:trans>Add a Comment:</cms:trans><br/>
        <cms:comment/><br/>
        <cms:captcha/>
        <input type='submit' value='Add Comment'/>
        <br/><br/>
      </cms:add_comment>
      <cms:posted_comment><b>Your comment has been posted</b><br/><br/></cms:posted_comment>
      <cms:comments>
        <cms:comment>
        Posted by <cms:name/> at <cms:posted_at /><br/>
        <cms:body/>
        <cms:not_last><hr/></cms:not_last>
        </cms:comment>
      </cms:comments>
      <cms:no_comments>
        No Comments
      </cms:no_comments>
  FEATURE

  def comments_page_comments_feature(data)
    webiva_feature('comments_page_comments') do |c|
      c.loop_tag('comment') { |t| data[:comments] }
        add_comment_features( c, data )

      c.expansion_tag('logged_in') { |t| myself.id }
      
      paragraph_id = data[:paragraph_id] ? data[:paragraph_id] : paragraph.id

      c.form_for_tag('add_comment',"comment_#{paragraph_id}") { |t|  data[:comment] }
        c.form_error_tag('add_comment:errors')
        c.field_tag('add_comment:email')
        c.field_tag('add_comment:website')
        c.field_tag('add_comment:name')
        c.field_tag('add_comment:comment',:control => 'text_area', :rows => 6, :cols => 50)

        if data[:options] &&  data[:options].captcha
	  c.captcha_tag('add_comment:captcha')
	else
	  c.define_tag('add_comment:captcha') { |t| '' }
	end

      c.expansion_tag('posted_comment') { |t| data[:posted_comment] }
    end
  end

  def add_comment_features(context, data, base='comment')
    context.h_tag(base + ':name') { |t| t.locals.comment.name }
    context.h_tag(base + ':first_name') { |t| t.locals.comment.name.to_s.split(" ")[0] }
    context.value_tag(base + ':body') { |t| t.locals.comment.comment_html.blank? ? simple_format(h(t.locals.comment.comment)) : "<p>#{t.locals.comment.comment_html}</p>" }
    context.date_tag(base + ':posted_at', "%I:%M%p on %B %d %Y".t) { |t| t.locals.comment.posted_at }
  end

end<commit_msg>Created a default style for trackbacks.<commit_after># Copyright (C) 2009 <NAME>.

class Feedback::CommentsFeature < ParagraphFeature

  feature :comments_page_comments, :default_feature => <<-FEATURE
      <br/><br/>
      <cms:add_comment>
        <cms:errors><div class='errors'><cms:value/></div></cms:errors>
        <cms:not_logged_in>Name:<br/><cms:name/><br/></cms:not_logged_in>
        <cms:trans>Add a Comment:</cms:trans><br/>
        <cms:comment/><br/>
        <cms:captcha/>
        <input type='submit' value='Add Comment'/>
        <br/><br/>
      </cms:add_comment>
      <cms:posted_comment><b>Your comment has been posted</b><br/><br/></cms:posted_comment>
      <cms:comments>
        <cms:comment>
          <cms:trackback>
            Trackback from <cms:website_link rel="nofollow" target="_blank"><cms:name/></cms:website_link> at <cms:posted_at /><br/>
            <cms:body/>
          </cms:trackback>
          <cms:no_trackback>
            Posted by <cms:name/> at <cms:posted_at /><br/>
            <cms:body/>
          </cms:no_trackback>
          <cms:not_last><hr/></cms:not_last>
        </cms:comment>
      </cms:comments>
      <cms:no_comments>
        No Comments
      </cms:no_comments>
  FEATURE

  def comments_page_comments_feature(data)
    webiva_feature('comments_page_comments') do |c|
      c.loop_tag('comment') { |t| data[:comments] }
        add_comment_features( c, data )

      c.expansion_tag('logged_in') { |t| myself.id }
      
      paragraph_id = data[:paragraph_id] ? data[:paragraph_id] : paragraph.id

      c.form_for_tag('add_comment',"comment_#{paragraph_id}") { |t|  data[:comment] }
        c.form_error_tag('add_comment:errors')
        c.field_tag('add_comment:email')
        c.field_tag('add_comment:website')
        c.field_tag('add_comment:name')
        c.field_tag('add_comment:comment',:control => 'text_area', :rows => 6, :cols => 50)

        if data[:options] &&  data[:options].captcha
	  c.captcha_tag('add_comment:captcha')
	else
	  c.define_tag('add_comment:captcha') { |t| '' }
	end

      c.expansion_tag('posted_comment') { |t| data[:posted_comment] }
    end
  end

  def add_comment_features(context, data, base='comment')
    context.h_tag(base + ':name') { |t| t.locals.comment.name }
    context.h_tag(base + ':first_name') { |t| t.locals.comment.name.to_s.split(" ")[0] }
    context.value_tag(base + ':body') { |t| t.locals.comment.comment_html.blank? ? simple_format(h(t.locals.comment.comment)) : "<p>#{t.locals.comment.comment_html}</p>" }
    context.date_tag(base + ':posted_at', "%I:%M%p on %B %d %Y".t) { |t| t.locals.comment.posted_at }
    context.link_tag(base + ':website') { |t| t.locals.comment.website }
    context.expansion_tag(base + ':trackback') { |t| t.locals.comment.source_type == 'FeedbackPingback' }
  end

end
{'fraction_non_alphanumeric': 0.17682221365214038, 'fraction_numerical': 0.0030852294639413806, 'mean_word_length': 3.3333333333333335, 'pattern_counts': {'":': 0, '<': 109, '<?xml version=': 0, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6890093', 'n_tokens_mistral': 1965, 'n_tokens_neox': 1833, 'n_words': 274}