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



class Blog::PageFeature < ParagraphFeature

  feature :blog_entry_list, :default_feature => <<-FEATURE
    <cms:entries>
      <cms:entry>
        <div class='blog_entry'>
          <cms:image align='left' border='10' size='preview' shadow='1' />
          <h2><cms:detail_link><cms:title/></cms:detail_link></h2>
          <cms:preview/>
          <cms:more><cms:detail_link>Read More...</cms:detail_link><br/><br/></cms:more>
          <div class='blog_info'>
             Posted <cms:published_at /> by <cms:author/> | <cms:detail_link>User Comments (<cms:comment_count/>)</cms:detail_link><br/><br/>
             <cms:categories> Categories: <cms:value/> <cms:tags> | </cms:tags> </cms:categories> 
             <cms:tags> Tags: <cms:value/> </cms:tags>
          </div>
        </div>
        <div style='clear:both;'></div>
        <cms:not_last><hr/></cms:not_last>
      </cms:entry>
      <cms:pages/>
    </cms:entries>
  FEATURE

  def blog_entry_list_feature(data)
    webiva_feature('blog_entry_list') do |c|
      c.value_tag 'title' do |tag|
        exists = !data[:type].blank? && !data[:identifier].blank?
        tag.locals.value = "Showing #{data[:type]} &gt; #{data[:identifier]}"
        tag.single? ? tag.locals.value : (exists ? tag.expand : nil)
      end

      c.link_tag('list_page') { |tag| data[:list_page] }

      c.loop_tag('grouping') do |t|
        by = t.attr['by'] || "%B %Y"
        # Get a list of entries of the form [ [ "May 2009", <Entry> ], ... ]
        entries = data[:entries].select(&:published_at).map { |entry| [ entry.published_at.localize(by), entry ] }

        # Now group the entries, keeping the same order
        # [ [ "May 2009", [ <Entry1>, <Entry2> ], ... ]
        entries.inject([]) do |acc,entry|
          if acc[-1] && acc[-1][0] == entry[0]
            acc[-1][1] << entry[1]
          else
            acc << [ entry[0], [ entry[1] ] ]
          end
          acc
        end
      end
      c.value_tag('grouping:header') { |t| t.locals.grouping[0] }


      c.loop_tag('entry') { |t| t.locals.grouping ? t.locals.grouping[1] : data[:entries] }
        blog_entry_tags(c,data)

      c.pagelist_tag('pages') { |t| data[:pages] }
    end
  end

  feature :blog_entry_detail, :default_feature => <<-FEATURE
      <cms:entry>
        <div class='blog_entry'>
          <cms:image align='left' border='10' size='preview' shadow='1' />
          <h1><cms:title/></h1>
          <cms:body/>
        </div>
          <cms:embedded_media>
            <div style='clear:both;'></div>
            <br/><br/>
            <div align='center'><cms:value/></div>
            <br/>
          </cms:embedded_media>
          <cms:media_file>
            <div style='clear:both;'></div>
            <br/><br/>
            <div style='text-align:center;'><cms:value/></div>
          </cms:media_file>
          <div class='blog_info'>
             Posted <cms:published_at /> by <cms:author/> <br/>
             <cms:categories>Categories: <cms:value/> <cms:tags>|</cms:tags> </cms:categories> 
             <cms:tags>Tags: <cms:value/></cms:tags>
          </div>
        <div style='clear:both;'></div>
      </cms:entry>
      <cms:no_entry>Invalid Post</cms:no_entry>
  FEATURE
  
  def blog_entry_detail_feature(data)
    webiva_feature('blog_entry_detail') do |c|
      c.link_tag('list_page') { |tag| data[:list_page] }
      c.expansion_tag('entry') { |tag| tag.locals.entry = data[:entry] }
        blog_entry_tags(c,data)
   end
  end   

  def blog_entry_tags(c,data)
    c.value_tag('blog_name') { |t| data[:blog].name }
    c.value_tag('blog_description') { |t| data[:blog].description } 
    c.value_tag('blog_target_id') { |t| data[:blog].target_id } 
    
    
    c.value_tag('entry:blog') { |t| t.locals.entry.blog_blog.name  }
    c.value_tag('entry:embedded_media') { |tag| tag.locals.entry.embedded_media }
    
    c.media_tag('entry:media_file') { |tag| tag.locals.entry.media_file }

    c.value_tag('entry:rating') { |t| (t.locals.entry.rating * (t.attr['multiplier'] || 1).to_i).floor.to_i }
    c.value_tag('entry:rating_display') { |t| sprintf("%.1f",t.locals.entry.rating) }
    
    c.date_tag('entry:published_at',"%H:%M%p on %B %d %Y".t) { |t|  t.locals.entry.published_at }
    c.image_tag('entry:image') { |t| t.locals.entry.image }
    c.expansion_tag('entry:comments') { |t| t.locals.entry.comments_count > 0 }
    c.value_tag('entry:comment_count') { |t| t.locals.entry.comments_count }
    c.value_tag('entry:approved_comment_count') { |t| t.locals.entry.approved_comments_count }
    
    
    %w(title author).each do |elem|
      c.value_tag('entry:' + elem) { |tag| h(tag.locals.entry.send(elem)) }
    end
    
    c.value_tag('entry:id') { |t| t.locals.entry.id }
    c.value_tag('entry:permalink') { |t| t.locals.entry.permalink }
    c.value_tag('entry:body') { |tag| tag.locals.entry.body_content }
    c.value_tag('entry:preview') {  |tag| tag.locals.entry.preview_content }
    c.value_tag('entry:content_node_id') { |t| t.locals.entry.content_node_id }

    c.value_tag 'entry:preview_title' do |tag|
      h(tag.locals.entry.preview_title.blank? ? tag.locals.entry.title : tag.locals.entry.preview_title)
    end

    c.expansion_tag('entry:more') { |tag| !tag.locals.entry.preview.blank? }
    c.link_tag('entry:detail') do |tag| 
      if !data[:detail_page].blank?
        SiteNode.link data[:detail_page], tag.locals.entry.permalink
      else
        tag.locals.entry.content_node.link if tag.locals.entry.content_node
      end
    end
    c.link_tag('entry:full_detail') { |tag| "#{SiteNode.domain_link(data[:detail_page], tag.locals.entry.permalink)}" }

    c.value_tag('entry:categories') do |tag|
      categories = tag.locals.entry.blog_categories(true).collect(&:name)<commit_msg>Fix to point to content node id<commit_after># Copyright (C) 2009 <NAME>.



class Blog::PageFeature < ParagraphFeature

  feature :blog_entry_list, :default_feature => <<-FEATURE
    <cms:entries>
      <cms:entry>
        <div class='blog_entry'>
          <cms:image align='left' border='10' size='preview' shadow='1' />
          <h2><cms:detail_link><cms:title/></cms:detail_link></h2>
          <cms:preview/>
          <cms:more><cms:detail_link>Read More...</cms:detail_link><br/><br/></cms:more>
          <div class='blog_info'>
             Posted <cms:published_at /> by <cms:author/> | <cms:detail_link>User Comments (<cms:comment_count/>)</cms:detail_link><br/><br/>
             <cms:categories> Categories: <cms:value/> <cms:tags> | </cms:tags> </cms:categories> 
             <cms:tags> Tags: <cms:value/> </cms:tags>
          </div>
        </div>
        <div style='clear:both;'></div>
        <cms:not_last><hr/></cms:not_last>
      </cms:entry>
      <cms:pages/>
    </cms:entries>
  FEATURE

  def blog_entry_list_feature(data)
    webiva_feature('blog_entry_list') do |c|
      c.value_tag 'title' do |tag|
        exists = !data[:type].blank? && !data[:identifier].blank?
        tag.locals.value = "Showing #{data[:type]} &gt; #{data[:identifier]}"
        tag.single? ? tag.locals.value : (exists ? tag.expand : nil)
      end

      c.link_tag('list_page') { |tag| data[:list_page] }

      c.loop_tag('grouping') do |t|
        by = t.attr['by'] || "%B %Y"
        # Get a list of entries of the form [ [ "May 2009", <Entry> ], ... ]
        entries = data[:entries].select(&:published_at).map { |entry| [ entry.published_at.localize(by), entry ] }

        # Now group the entries, keeping the same order
        # [ [ "May 2009", [ <Entry1>, <Entry2> ], ... ]
        entries.inject([]) do |acc,entry|
          if acc[-1] && acc[-1][0] == entry[0]
            acc[-1][1] << entry[1]
          else
            acc << [ entry[0], [ entry[1] ] ]
          end
          acc
        end
      end
      c.value_tag('grouping:header') { |t| t.locals.grouping[0] }


      c.loop_tag('entry') { |t| t.locals.grouping ? t.locals.grouping[1] : data[:entries] }
        blog_entry_tags(c,data)

      c.pagelist_tag('pages') { |t| data[:pages] }
    end
  end

  feature :blog_entry_detail, :default_feature => <<-FEATURE
      <cms:entry>
        <div class='blog_entry'>
          <cms:image align='left' border='10' size='preview' shadow='1' />
          <h1><cms:title/></h1>
          <cms:body/>
        </div>
          <cms:embedded_media>
            <div style='clear:both;'></div>
            <br/><br/>
            <div align='center'><cms:value/></div>
            <br/>
          </cms:embedded_media>
          <cms:media_file>
            <div style='clear:both;'></div>
            <br/><br/>
            <div style='text-align:center;'><cms:value/></div>
          </cms:media_file>
          <div class='blog_info'>
             Posted <cms:published_at /> by <cms:author/> <br/>
             <cms:categories>Categories: <cms:value/> <cms:tags>|</cms:tags> </cms:categories> 
             <cms:tags>Tags: <cms:value/></cms:tags>
          </div>
        <div style='clear:both;'></div>
      </cms:entry>
      <cms:no_entry>Invalid Post</cms:no_entry>
  FEATURE
  
  def blog_entry_detail_feature(data)
    webiva_feature('blog_entry_detail') do |c|
      c.link_tag('list_page') { |tag| data[:list_page] }
      c.expansion_tag('entry') { |tag| tag.locals.entry = data[:entry] }
        blog_entry_tags(c,data)
   end
  end   

  def blog_entry_tags(c,data)
    c.value_tag('blog_name') { |t| data[:blog].name }
    c.value_tag('blog_description') { |t| data[:blog].description } 
    c.value_tag('blog_target_id') { |t| data[:blog].target_id } 
    
    
    c.value_tag('entry:blog') { |t| t.locals.entry.blog_blog.name  }
    c.value_tag('entry:embedded_media') { |tag| tag.locals.entry.embedded_media }
    
    c.media_tag('entry:media_file') { |tag| tag.locals.entry.media_file }

    c.value_tag('entry:rating') { |t| (t.locals.entry.rating * (t.attr['multiplier'] || 1).to_i).floor.to_i }
    c.value_tag('entry:rating_display') { |t| sprintf("%.1f",t.locals.entry.rating) }
    
    c.date_tag('entry:published_at',"%H:%M%p on %B %d %Y".t) { |t|  t.locals.entry.published_at }
    c.image_tag('entry:image') { |t| t.locals.entry.image }
    c.expansion_tag('entry:comments') { |t| t.locals.entry.comments_count > 0 }
    c.value_tag('entry:comment_count') { |t| t.locals.entry.comments_count }
    c.value_tag('entry:approved_comment_count') { |t| t.locals.entry.approved_comments_count }
    
    
    %w(title author).each do |elem|
      c.value_tag('entry:' + elem) { |tag| h(tag.locals.entry.send(elem)) }
    end
    
    c.value_tag('entry:id') { |t| t.locals.entry.id }
    c.value_tag('entry:permalink') { |t| t.locals.entry.permalink }
    c.value_tag('entry:body') { |tag| tag.locals.entry.body_content }
    c.value_tag('entry:preview') {  |tag| tag.locals.entry.preview_content }
    c.value_tag('entry:content_node_id') { |t| t.locals.entry.content_node.id }

    c.value_tag 'entry:preview_title' do |tag|
      h(tag.locals.entry.preview_title.blank? ? tag.locals.entry.title : tag.locals.entry.preview_title)
    end

    c.expansion_tag('entry:more') { |tag| !tag.locals.entry.preview.blank? }
    c.link_tag('entry:detail') do |tag| 
      if !data[:detail_page].blank?
        SiteNode.link data[:detail_page], tag.locals.entry.permalink
      else
        tag.locals.entry.content_node.link if tag.locals.entry.content_node
      end
    end
    c.link_tag('entry:full_detail') { |tag| "#{SiteNode.domain_link(data[:detail_page], tag.locals.entry.permalink)}" }

    c.value_tag('entry:categories') do |tag|
      categories = tag.locals.entry.blog_categories(true).collect(&:name)
{'fraction_non_alphanumeric': 0.18264957264957266, 'fraction_numerical': 0.006495726495726496, 'mean_word_length': 2.799025974025974, 'pattern_counts': {'":': 0, '<': 203, '<?xml version=': 0, '>': 191, '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': '933551', 'n_tokens_mistral': 4361, 'n_tokens_neox': 4175, 'n_words': 637}