<commit_before>require_dependency 'kebapress/application_controller'

module Kebapress
  class PostsController < ApplicationController
    def new
      @post = Kebapress::Post.new
      @categories = Kebapress::Category.all
    end

    def index
      @posts = Kebapress::Post.published.order('published_at DESC')
      render layout: 'layouts/application'
    end

    def show
      @post = Kebapress::Post.find(params[:id])
      render layout: 'layouts/application'
    end

    def create
      @post = Kebapress::Post.new(post_params)

      # params[:boolean_variable] returns 'true' or 'nil'
      # So we have to assign false value by using unless true
      @post.commentable = false unless @post.commentable
      @post.published = false unless @post.published
      @post.published_at = Time.now if @post.published

      # Relating post with Cybele app's current admin
      @post.admin = current_admin<commit_msg>#20 Use outside template for show and index<commit_after>require_dependency 'kebapress/application_controller'

module Kebapress
  class PostsController < ApplicationController
    skip_before_filter :authenticate_admin!, only: [:show, :index]
    def new
      @post = Kebapress::Post.new
      @categories = Kebapress::Category.all
    end

    def index
      @posts = Kebapress::Post.published.order('published_at DESC')
      render layout: 'layouts/application', template: 'blog/index'
    end

    def show
      @post = Kebapress::Post.find(params[:id])
      render layout: 'layouts/application', template: 'blog/show'
    end

    def create
      @post = Kebapress::Post.new(post_params)

      # params[:boolean_variable] returns 'true' or 'nil'
      # So we have to assign false value by using unless true
      @post.commentable = false unless @post.commentable
      @post.published = false unless @post.published
      @post.published_at = Time.now if @post.published

      # Relating post with Cybele app's current admin
      @post.admin = current_admin
{'fraction_non_alphanumeric': 0.0919080919080919, 'fraction_numerical': 0.000999000999000999, 'mean_word_length': 3.30752688172043, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1206042', 'n_tokens_mistral': 598, 'n_tokens_neox': 578, 'n_words': 159}