<commit_before>class ArticlesController < ApplicationController
  
  skip_before_filter :require_user, :only => [:show, :legacy_show]
  
  before_filter :set_liquid_variables, :only => :show
  before_filter :require_design, :only => :show
  before_filter :find_template, :only => :show
  before_filter :build_registers, :only => :show

  
  # Since the show action is public facing, it should always fail in a predictable
  # informative way.
  def show
    
    @article = Article.find(params[:id], :account_id => @account.account_resource_id, :as => @account.access_token)
    @comments = @article.comments
    
  # Widget data processing -- start  
    # Build query of only the necessary ids, from the widgets
    schema_ids = Array.new
    found_widgets = @current_template.widgets
    found_widgets += @current_template.current_layout.widgets if @current_template.current_layout
    found_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
    
      found_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
    @registers[:form_authenticity_token] = self.form_authenticity_token
    @registers[:article] = @article
    
    page_html = @current_template.parsed_code.render({'article' => @article, 'newspaper' => @newspaper}, :registers => @registers )
    if @current_template.current_layout
      render :text => @current_template.current_layout.parsed_code.render({'page_content' => page_html, 'article' => @article, 'newspaper' => @newspaper}, :registers => @registers)
    else  
      render :text => page_html
    end 
    #render :text => "Sorry, the page you were looking for could not be found.", :status => :not_found # If the current deisgn has no article template we should render 404
  end
  
  
  # temporary redirect action until legacy url code is complete
  def legacy_show
    # grab the id from slugged urls like "3818-cops-bust-frat-boys-for"
    redirect_to account_article_url(@account, params[:id].split("-")[0]), :status=>:moved_permanently
  end

end
  <commit_msg>Don't want account part of URL being written for deployed versions<commit_after>class ArticlesController < ApplicationController
  
  skip_before_filter :require_user, :only => [:show, :legacy_show]
  
  before_filter :set_liquid_variables, :only => :show
  before_filter :require_design, :only => :show
  before_filter :find_template, :only => :show
  before_filter :build_registers, :only => :show

  
  # Since the show action is public facing, it should always fail in a predictable
  # informative way.
  def show
    
    @article = Article.find(params[:id], :account_id => @account.account_resource_id, :as => @account.access_token)
    @comments = @article.comments
    
  # Widget data processing -- start  
    # Build query of only the necessary ids, from the widgets
    schema_ids = Array.new
    found_widgets = @current_template.widgets
    found_widgets += @current_template.current_layout.widgets if @current_template.current_layout
    found_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
    
      found_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
    @registers[:form_authenticity_token] = self.form_authenticity_token
    @registers[:article] = @article
    
    page_html = @current_template.parsed_code.render({'article' => @article, 'newspaper' => @newspaper}, :registers => @registers )
    if @current_template.current_layout
      render :text => @current_template.current_layout.parsed_code.render({'page_content' => page_html, 'article' => @article, 'newspaper' => @newspaper}, :registers => @registers)
    else  
      render :text => page_html
    end 
    #render :text => "Sorry, the page you were looking for could not be found.", :status => :not_found # If the current deisgn has no article template we should render 404
  end
  
  
  # temporary redirect action until legacy url code is complete
  def legacy_show
    # grab the id from slugged urls like "3818-cops-bust-frat-boys-for"
    # skip the account part of the URL - this only runs on deployed Hot Ink
    redirect_to "/articles/#{params[:id].split("-")[0]}", :status=>:moved_permanently
  end

end
  
{'fraction_non_alphanumeric': 0.11189777240545674, 'fraction_numerical': 0.0027629079606285617, 'mean_word_length': 3.535630383711825, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, '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': '4425232', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1735, 'n_words': 447}