<commit_before>class StoriesController < ApplicationController
  before_filter :require_logged_in_user_or_400,
    :only => [ :upvote, :downvote, :unvote, :hide, :unhide, :preview ]

  before_filter :require_logged_in_user, :only => [ :destroy, :create, :edit,
    :fetch_url_title, :new ]

  before_filter :find_user_story, :only => [ :destroy, :edit, :undelete,
    :update ]

  def create
    @title = "Submit Story"
    @cur_url = "/stories/new"

    @story = Story.new(story_params)
    @story.user_id = @user.id

    if @story.valid? && !(@story.already_posted_story && !@story.seen_previous)
      if @story.save
        Countinual.count!("#{Rails.application.shortname}.stories.submitted",
          "+1")

        return redirect_to @story.comments_url
      end
    end

    return render :action => "new"
  end

  def guess
    @title = "Submit Story"
    @cur_url = "/stories/new"
    text = params.require(:text)

    if text.start_with? "http://" or text.start_with? "https://"
      story = Story.new(:url => text)
      story.title = story.fetched_title(request.remote_ip)
      @story = story
    else
      @story = Story.new(:title => text)
    end<commit_msg>Sure, having nil in a language is a great idea<commit_after>class StoriesController < ApplicationController
  before_filter :require_logged_in_user_or_400,
    :only => [ :upvote, :downvote, :unvote, :hide, :unhide, :preview ]

  before_filter :require_logged_in_user, :only => [ :destroy, :create, :edit,
    :fetch_url_title, :new ]

  before_filter :find_user_story, :only => [ :destroy, :edit, :undelete,
    :update ]

  def create
    @title = "Submit Story"
    @cur_url = "/stories/new"

    @story = Story.new(story_params)
    @story.user_id = @user.id

    if @story.valid? && !(@story.already_posted_story && !@story.seen_previous)
      if @story.save
        Countinual.count!("#{Rails.application.shortname}.stories.submitted",
          "+1")

        return redirect_to @story.comments_url
      end
    end

    return render :action => "new"
  end

  def guess
    @title = "Submit Story"
    @cur_url = "/stories/new"
    text = params.require(:text)

    if text.start_with? "http://" or text.start_with? "https://"
      @story = Story.new(:url => text)
      title = @story.fetched_title(request.remote_ip)
      if title
        @story.title = title
      end
    else
      @story = Story.new(:title => text)
    end
{'fraction_non_alphanumeric': 0.13760330578512397, 'fraction_numerical': 0.003305785123966942, 'mean_word_length': 3.0689075630252103, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '5985003', 'n_tokens_mistral': 838, 'n_tokens_neox': 807, 'n_words': 177}