<commit_before>require 'uri'

class SectionsController < ApplicationController

  skip_before_filter :require_user, :only => :show
  
  before_filter :set_liquid_variables, :only => :show
  before_filter :find_template, :only => :show

  before_filter :build_registers, :only => :show

  def show
    @section = Section.find(URI.encode(params[:id]), :account_id => @account.account_resource_id, :as => @account.access_token)
    
    @articles = Article.find(:all, :account_id => @account.account_resource_id, :section_id => @section.id, :as => @account.access_token)
 
      # Widget data processing -- start  
      # Build query of only the necessary ids, from the widgets
      schema_ids = Array.new
      @current_template.widgets.each do |widget|
        widget.schema.each_key do |item|
          schema_ids += widget.schema[item]['ids']
        end
      end

      unless schema_ids.blank?  
        article_resources = Article.find(:all, :ids => schema_ids.reject{ |i| i.blank? }, :account_id => @account.account_resource_id, :as => @account.access_token)

        widget_data = {}
        schema_articles = {}

        article_resources.each do |article|
           schema_articles.merge!(article.id.to_s => article)
        end

        @current_template.widgets.each do |widget|
          widget.schema.each_key do |item|
            item_array = widget.schema[item]['ids'].collect{ |i| schema_articles[i] }
            widget_data.merge!( "#{item}_#{widget.name}" => item_array )
          end
        end

        # Set registers here 
        @registers[:widget_data] = widget_data
      end
      # Widget data processing -- end

    @registers[:account] = @account
    @registers[:design] = @current_template.design if @current_template.design
   
    page_html = @current_template.parsed_code.render({'section' => @section, 'articles' => @articles, 'newspaper' => @newspaper}, :registers => @registers )
     if @current_template.current_layout
       render :text => @current_template.current_layout.parsed_code.render({'page_content' => page_html, 'newspaper' => @newspaper}, :registers => @registers)
     else  
       render :text => page_html<commit_msg>Changed name of section drop in sections/show.<commit_after>require 'uri'

class SectionsController < ApplicationController

  skip_before_filter :require_user, :only => :show
  
  before_filter :set_liquid_variables, :only => :show
  before_filter :find_template, :only => :show

  before_filter :build_registers, :only => :show

  def show
    @section = Section.find(URI.encode(params[:id]), :account_id => @account.account_resource_id, :as => @account.access_token)
    
    @articles = Article.find(:all, :account_id => @account.account_resource_id, :section_id => @section.id, :as => @account.access_token)
 
      # Widget data processing -- start  
      # Build query of only the necessary ids, from the widgets
      schema_ids = Array.new
      @current_template.widgets.each do |widget|
        widget.schema.each_key do |item|
          schema_ids += widget.schema[item]['ids']
        end
      end

      unless schema_ids.blank?  
        article_resources = Article.find(:all, :ids => schema_ids.reject{ |i| i.blank? }, :account_id => @account.account_resource_id, :as => @account.access_token)

        widget_data = {}
        schema_articles = {}

        article_resources.each do |article|
           schema_articles.merge!(article.id.to_s => article)
        end

        @current_template.widgets.each do |widget|
          widget.schema.each_key do |item|
            item_array = widget.schema[item]['ids'].collect{ |i| schema_articles[i] }
            widget_data.merge!( "#{item}_#{widget.name}" => item_array )
          end
        end

        # Set registers here 
        @registers[:widget_data] = widget_data
      end
      # Widget data processing -- end

    @registers[:account] = @account
    @registers[:design] = @current_template.design if @current_template.design
   
    page_html = @current_template.parsed_code.render({'current_section' => @section, 'articles' => @articles, 'newspaper' => @newspaper}, :registers => @registers )
     if @current_template.current_layout
       render :text => @current_template.current_layout.parsed_code.render({'page_content' => page_html, 'newspaper' => @newspaper}, :registers => @registers)
     else  
       render :text => page_html
{'fraction_non_alphanumeric': 0.12451715519200182, 'fraction_numerical': 0.0, 'mean_word_length': 3.244937319189971, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '1198045', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1298, 'n_words': 279}