<commit_before>require 'base64'

module Admin; end

class Admin::ContentController < Admin::BaseController
  layout 'administration'

  cache_sweeper :blog_sweeper

  def auto_complete_for_article_keywords
    @items = Tag.select(:display_name).order(:display_name).map { |t| t.display_name }
    render inline: '<%= @items %>'
  end

  def index
    @search = params[:search] ? params[:search] : {}
    @articles = Article.search_with(@search).page(params[:page]).per(this_blog.admin_display_elements)

    if request.xhr?
      respond_to do |format|
        format.js {}
      end
    else
      @article = Article.new(params[:article])
    end
  end

  def new
    @article = Article::Factory.new(this_blog, current_user).default
    load_resources
  end

  def create
    article_factory = Article::Factory.new(this_blog, current_user)
    @article = article_factory.get_or_build_from(params[:article][:id])

    update_article_attributes
    @article.author = current_user

    if @article.save
      flash[:success] = I18n.t('admin.content.create.success')
      redirect_to action: 'edit', id: @article
    else
      @article.keywords = Tag.collection_to_string @article.tags
      load_resources
      render 'new'
    end<commit_msg>Don’t list draft articles with parent ids in the main article list.<commit_after>require 'base64'

module Admin; end

class Admin::ContentController < Admin::BaseController
  layout 'administration'

  cache_sweeper :blog_sweeper

  def auto_complete_for_article_keywords
    @items = Tag.select(:display_name).order(:display_name).map { |t| t.display_name }
    render inline: '<%= @items %>'
  end

  def index
    @search = params[:search] ? params[:search] : {}
    @articles = Article.search_with(@search)
    @articles = @articles.where('parent_id IS NULL')
    @articles = @articles.page(params[:page]).per(this_blog.admin_display_elements)

    if request.xhr?
      respond_to do |format|
        format.js {}
      end
    else
      @article = Article.new(params[:article])
    end
  end

  def new
    @article = Article::Factory.new(this_blog, current_user).default
    load_resources
  end

  def create
    article_factory = Article::Factory.new(this_blog, current_user)
    @article = article_factory.get_or_build_from(params[:article][:id])

    update_article_attributes
    @article.author = current_user

    if @article.save
      flash[:success] = I18n.t('admin.content.create.success')
      redirect_to action: 'edit', id: @article
    else
      @article.keywords = Tag.collection_to_string @article.tags
      load_resources
      render 'new'
    end
{'fraction_non_alphanumeric': 0.11178939336131248, 'fraction_numerical': 0.003052270125906143, 'mean_word_length': 3.682142857142857, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '2878879', 'n_tokens_mistral': 830, 'n_tokens_neox': 791, 'n_words': 166}