<commit_before>module Blogit

  # Using explicit ::Blogit::ApplicationController fixes NoMethodError 'blogit_authenticate' in
  # the main_app
  class PostsController < ::Blogit::ApplicationController

    # If a layout is specified, use that. Otherwise, fall back to the default
    layout Blogit.configuration.layout if Blogit.configuration.layout

    # If using Blogit's Create, Update and Destroy actions AND ping_search_engines is
    # set, call ping_search_engines after these requests
    if Blogit.configuration.include_admin_actions
      after_filter :ping_search_engines, only: [:create, :update, :destroy], :if => lambda { Blogit.configuration.ping_search_engines }
    end

    # Raise a 404 error if the admin actions aren't to be included
    # We can't use blogit_conf here because it sometimes raises NoMethodError in main app's routes
    unless Blogit.configuration.include_admin_actions
      before_filter :raise_404, except: [:index, :show]
    end

    blogit_authenticate(except: [:index, :show, :tagged])

    def index
      respond_to do |format|
        format.xml {
          @posts = Post.active.order('created_at DESC')
        }
        format.html {
          @posts = if is_blogger_logged_in?
                    Post.for_index(params[Kaminari.config.param_name])
                  else
                    Post.active.for_index(params[Kaminari.config.param_name])
                  end
        }
        format.rss {
          @posts = Post.active.order('created_at DESC')
        }
      end
    end

    def show
      @post = Post.find(params[:id])
    end

    def tagged
      param_name = params[Kaminari.config.param_name]
      @posts = Post.for_index(param_name).tagged_with(params[:tag])
      render :index
    end

    def new
      @post = blog_posts_scope.new(post_paramters)
    end

    def edit
      @post = blog_posts_scope.find(params[:id])
    end

    def create
      @post = blog_posts_scope.new(post_paramters)
      if @post.save
        redirect_to @post, notice: t(:blog_post_was_successfully_created, scope: 'blogit.posts')
      else
        render action: "new"<commit_msg>Don't use scope in new or create so that the blogger FK gets set.<commit_after>module Blogit

  # Using explicit ::Blogit::ApplicationController fixes NoMethodError 'blogit_authenticate' in
  # the main_app
  class PostsController < ::Blogit::ApplicationController

    # If a layout is specified, use that. Otherwise, fall back to the default
    layout Blogit.configuration.layout if Blogit.configuration.layout

    # If using Blogit's Create, Update and Destroy actions AND ping_search_engines is
    # set, call ping_search_engines after these requests
    if Blogit.configuration.include_admin_actions
      after_filter :ping_search_engines, only: [:create, :update, :destroy], :if => lambda { Blogit.configuration.ping_search_engines }
    end

    # Raise a 404 error if the admin actions aren't to be included
    # We can't use blogit_conf here because it sometimes raises NoMethodError in main app's routes
    unless Blogit.configuration.include_admin_actions
      before_filter :raise_404, except: [:index, :show]
    end

    blogit_authenticate(except: [:index, :show, :tagged])

    def index
      respond_to do |format|
        format.xml {
          @posts = Post.active.order('created_at DESC')
        }
        format.html {
          @posts = if is_blogger_logged_in?
                    Post.for_index(params[Kaminari.config.param_name])
                  else
                    Post.active.for_index(params[Kaminari.config.param_name])
                  end
        }
        format.rss {
          @posts = Post.active.order('created_at DESC')
        }
      end
    end

    def show
      @post = Post.find(params[:id])
    end

    def tagged
      param_name = params[Kaminari.config.param_name]
      @posts = Post.for_index(param_name).tagged_with(params[:tag])
      render :index
    end

    def new
      @post = current_blogger.blog_posts.new(post_paramters)
    end

    def edit
      @post = blog_posts_scope.find(params[:id])
    end

    def create
      @post = current_blogger.blog_posts.new(post_paramters)
      if @post.save
        redirect_to @post, notice: t(:blog_post_was_successfully_created, scope: 'blogit.posts')
      else
        render action: "new"
{'fraction_non_alphanumeric': 0.08268259072117592, 'fraction_numerical': 0.002756086357372531, 'mean_word_length': 2.7381974248927037, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5281122', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1250, 'n_words': 334}