<commit_before># encoding: utf-8
class BoardsController < ApplicationController
  skip_before_filter :verify_authenticity_token
  before_filter :verify_referer_or_authenticity_token, :only => [:create]
  before_filter :authenticate_account!, :only => :create
  after_filter :expire_cache, :only => [:create]
  caches_page :show, :if => Proc.new { |c| c.request.format.xml? }
  respond_to :html, :xml

  def show
    @boards = Board.all(Board.free)
    respond_with(@boards)
  end

  def create
    board = Board.new(params[:board])
    board.user = current_account.user
    enforce_create_permission(board)
    board.user_agent = request.user_agent
    board.save
    respond_to do |wants|
      wants.html { redirect_to :back rescue redirect_to root_url }
      wants.js   { render :nothing => true }
    end
  end

protected

  def verify_referer_or_authenticity_token
    request.referer =~ /^https?:\/\/#{MY_DOMAIN}\// or verify_authenticity_token
  end

  def expire_cache
    expire_page :action => :show, :format => :xml
  end
end<commit_msg>Mark a news as read when posting on its board<commit_after># encoding: utf-8
class BoardsController < ApplicationController
  skip_before_filter :verify_authenticity_token
  before_filter :verify_referer_or_authenticity_token, :only => [:create]
  before_filter :authenticate_account!, :only => :create
  after_filter :expire_cache, :only => [:create]
  caches_page :show, :if => Proc.new { |c| c.request.format.xml? }
  respond_to :html, :xml

  def show
    @boards = Board.all(Board.free)
    respond_with(@boards)
  end

  def create
    board = Board.new(params[:board])
    board.user = current_account.user
    enforce_create_permission(board)
    board.user_agent = request.user_agent
    board.save
    news = board.news
    news.node.read_by current_account.id if news
    respond_to do |wants|
      wants.html { redirect_to :back rescue redirect_to root_url }
      wants.js   { render :nothing => true }
    end
  end

protected

  def verify_referer_or_authenticity_token
    request.referer =~ /^https?:\/\/#{MY_DOMAIN}\// or verify_authenticity_token
  end

  def expire_cache
    expire_page :action => :show, :format => :xml
  end
end
{'fraction_non_alphanumeric': 0.10313493866424353, 'fraction_numerical': 0.0009086778736937755, 'mean_word_length': 3.9042316258351892, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '2253635', 'n_tokens_mistral': 741, 'n_tokens_neox': 726, 'n_words': 168}