<commit_before>class CommentsController < ApplicationController

  layout 'default'

  has_rakismet
  
  before_filter :find_account

  def index
    
    conditions = { :spam => "false" }
    
    if params[:article_id].nil?
      @comments = Comment.find(:all, :conditions => conditions)
    else    
      @article = Article.find(params[:article_id], :params => {:account_id => @account.account_resource_id})
      @comments = @article.comments
    end

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @comment }
    end
  end


  def show
    @comment = Comment.find(params[:id], :params => {:account_id => 1})
      
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @comment }
    end
  end


  def new
    @comment = Comment.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @comment }
    end
  end


  def edit
    @comment = Comment.find(params[:id])
  end


  def create

    @comment = Comment.new(params[:comment])
    @comment.content_id = params[:article_id]
    @comment.account_id = @account.id
    @comment.ip = request.remote_ip
    
    if facebook_session
      @comment.type = "FacebookComment"
      @comment.fb_user_id = facebook_session.user.id
    end
    
    if @comment.spam?
      @comment.spam = true
    end
    
    respond_to do |format|
      if @comment.save
        format.html { redirect_to(account_article_path(@account, @comment.content_id)) }
        format.xml  { render :xml => @comment, :status => :created, :location => @comment }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @comment.errors, :status => :unprocessable_entity }
      end
    end
  end


  def update
    @comment = Comment.find(params[:id])

    respond_to do |format|
      if @comment.update_attributes(params[:Comment])
        flash[:notice] = 'Comment was successfully updated.'
        format.html { redirect_to(@comment) }
        format.js { head :ok } 
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @comment.errors, :status => :unprocessable_entity }
      end
    end
  end


  def destroy
    @comment = Comment.find(params[:id])
    @comment.destroy

    respond_to do |format|
      format.html { redirect_to(Comments_url) }
      format.xml  { head :ok }
    end
  end
  
end<commit_msg>Skip authentication on comment actions<commit_after>class CommentsController < ApplicationController

  layout 'default'

  has_rakismet
  
  skip_before_filter :require_user, :only => [:index, :show, :new, :create]
  
  before_filter :find_account

  def index
    
    conditions = { :spam => "false" }
    
    if params[:article_id].nil?
      @comments = Comment.find(:all, :conditions => conditions)
    else    
      @article = Article.find(params[:article_id], :params => {:account_id => @account.account_resource_id})
      @comments = @article.comments
    end

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @comment }
    end
  end


  def show
    @comment = Comment.find(params[:id], :params => {:account_id => 1})
      
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @comment }
    end
  end


  def new
    @comment = Comment.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @comment }
    end
  end

  def create

    @comment = Comment.new(params[:comment])
    @comment.content_id = params[:article_id]
    @comment.account_id = @account.id
    @comment.ip = request.remote_ip
    
    if facebook_session
      @comment.type = "FacebookComment"
      @comment.fb_user_id = facebook_session.user.id
    end
    
    if @comment.spam?
      @comment.spam = true
    end
    
    respond_to do |format|
      if @comment.save
        format.html { redirect_to(account_article_path(@account, @comment.content_id)) }
        format.xml  { render :xml => @comment, :status => :created, :location => @comment }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @comment.errors, :status => :unprocessable_entity }
      end
    end
  end




  
end
{'fraction_non_alphanumeric': 0.11721443346357159, 'fraction_numerical': 0.0004596644449551827, 'mean_word_length': 2.4871794871794872, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 24}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1994897', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1345, 'n_words': 316}