<commit_before>class RecipesController < ApplicationController
  include RecipesHelper
  include UsersHelper

  before_filter :authenticate_user!, :except => [:show, :forks]

  def upvote
    @recipe = find_recipe_by_slug_and_username(params[:recipe], params[:username])
    current_user.up_vote!(@recipe)

    redirect_to recipe_path(@recipe)
  end

  def downvote
    @recipe = find_recipe_by_slug_and_username(params[:recipe], params[:username])
    current_user.down_vote!(@recipe)

    redirect_to recipe_path(@recipe)
  end

  def fork
    recipe = find_recipe_by_slug_and_username(params[:recipe], params[:username])

    respond_to do |format|
      if recipe.user_id != current_user.id && forked_recipe = recipe.fork_to(current_user)
        format.html { redirect_to "/#{forked_recipe.user.username}/#{forked_recipe.slug}", notice: 'Recipe was successfully forked.' }
      else
        format.html { render action: "new" }
      end
    end
  end

  def forks
    @recipe = find_recipe_by_slug_and_username(params[:recipe], params[:username])
    @forked_recipes = Recipe.where(:forked_from_recipe_id => @recipe.id)
  end

  def index
    @recipes = Recipe.where(:user_id => current_user)
  end

  def show
    @recipe = find_recipe_by_slug_and_username(params[:recipe], params[:username])

    return render :inline => "We couldn't find that recipe in our system :(" unless @recipe

    @revision_count = RecipeRevision.where(:recipe_id => @recipe.id).count
    @forked_from_recipe = Recipe.find(@recipe.forked_from_recipe_id) if @recipe.forked_from_recipe_id

    @page_title = "ForkingRecipes - #{@recipe.user.username} / #{@recipe.title}"

    @forks  = Rails.cache.fetch("recipe_#{@recipe.id}_forked_count", :expires_in => 5.minutes) do
      Recipe.where(:forked_from_recipe_id => @recipe.id).count
    end

    @upvotes = @recipe.up_votes
    @downvotes = @recipe.down_votes

    respond_to do |format|
      format.html
      format.json { render json: @recipe }
    end
  end

  def new
    @recipe = Recipe.new(:body => <<body)
### Source
[some_blog](http://www.someblog.com/recipe)

### Ingredients
* 1 cup of water

### Steps
* put water in cup

### Pictures
![my_image](imgur.com/my_image)
body

    respond_to do |format|
      format.html
      format.json { render json: @recipe }
    end
  end

  def edit
    @recipe = find_recipe_by_slug_and_username(params[:recipe], params[:username])
  end
<commit_msg>fixing intro recipe<commit_after>class RecipesController < ApplicationController
  include RecipesHelper
  include UsersHelper

  before_filter :authenticate_user!, :except => [:show, :forks]

  def upvote
    @recipe = find_recipe_by_slug_and_username(params[:recipe], params[:username])
    current_user.up_vote!(@recipe)

    redirect_to recipe_path(@recipe)
  end

  def downvote
    @recipe = find_recipe_by_slug_and_username(params[:recipe], params[:username])
    current_user.down_vote!(@recipe)

    redirect_to recipe_path(@recipe)
  end

  def fork
    recipe = find_recipe_by_slug_and_username(params[:recipe], params[:username])

    respond_to do |format|
      if recipe.user_id != current_user.id && forked_recipe = recipe.fork_to(current_user)
        format.html { redirect_to "/#{forked_recipe.user.username}/#{forked_recipe.slug}", notice: 'Recipe was successfully forked.' }
      else
        format.html { render action: "new" }
      end
    end
  end

  def forks
    @recipe = find_recipe_by_slug_and_username(params[:recipe], params[:username])
    @forked_recipes = Recipe.where(:forked_from_recipe_id => @recipe.id)
  end

  def index
    @recipes = Recipe.where(:user_id => current_user)
  end

  def show
    @recipe = find_recipe_by_slug_and_username(params[:recipe], params[:username])

    return render :inline => "We couldn't find that recipe in our system :(" unless @recipe

    @revision_count = RecipeRevision.where(:recipe_id => @recipe.id).count
    @forked_from_recipe = Recipe.find(@recipe.forked_from_recipe_id) if @recipe.forked_from_recipe_id

    @page_title = "ForkingRecipes - #{@recipe.user.username} / #{@recipe.title}"

    @forks  = Rails.cache.fetch("recipe_#{@recipe.id}_forked_count", :expires_in => 5.minutes) do
      Recipe.where(:forked_from_recipe_id => @recipe.id).count
    end

    @upvotes = @recipe.up_votes
    @downvotes = @recipe.down_votes

    respond_to do |format|
      format.html
      format.json { render json: @recipe }
    end
  end

  def new
    @recipe = Recipe.new(:body => <<body)
### Source
[some_blog](http://www.someblog.com/recipe)

### Ingredients
* 1 cup of water

### Directions
1. put water in cup

### Pictures
![my_image](imgur.com/my_image)
body

    respond_to do |format|
      format.html
      format.json { render json: @recipe }
    end
  end

  def edit
    @recipe = find_recipe_by_slug_and_username(params[:recipe], params[:username])
  end

{'fraction_non_alphanumeric': 0.11921343711593609, 'fraction_numerical': 0.0010241704219582138, 'mean_word_length': 4.003073770491803, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '113337', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1697, 'n_words': 325}