<commit_before># encoding: utf-8

class PostsController < ApplicationController
  respond_to :html
  
  def create
    @forum = Forum.find params[:forum_id]
    @topic = @forum.topics.find params[:topic_id]
    @post = @topic.posts.new params[:post]
    @post.user = current_user
    @post.save
    @recent_posts = @topic.posts.order{created_at.desc}.includes(:user).limit(3)
    respond_with @forum, @topic, @post, :location => forum_topic_path(@forum, @topic)
  end
  
  def destroy
    @forum = Forum.find params[:forum_id]
    @topic = @forum.topics.find params[:topic_id]
    @post = @topic.posts.find params[:id]
    @post.destroy
    respond_with @forum, @topic, @post
  end
  
  def edit
    @forum = Forum.find params[:forum_id]
    @topic = @forum.topics.find params[:topic_id]
    @post = @topic.posts.find params[:id]
    respond_with @forum, @topic, @post
  end
  
  def new
    @forum = Forum.find params[:forum_id]
    @topic = @forum.topics.find params[:topic_id]
    @post = @topic.posts.new
    @post.post = ""
    @recent_posts = @topic.posts.order{created_at.desc}.includes(:user).limit(3)
    
    if params[:quote]
      @quote = Post.find params[:quote]
      
      @post.post << "> _**#{@quote.user.username}** skrifaði:_\n>\n"
      
      @quote.post.to_s.each_line do |line|
        @post.post << "> " + line
      end
      
      @post.post << "\n\n"
    end
    
    respond_with @forum, @topic, @post
  end
  
  def update
    @forum = Forum.find params[:forum_id]
    @topic = @forum.topics.find params[:topic_id]
    @post = @topic.posts.find params[:id]
    @post.update_attributes params[:post]
    respond_with @forum, @topic, @post, :location => forum_topic_path(@forum, @topic)
  end
end<commit_msg>Redirect to post on post updated and create.<commit_after># encoding: utf-8

class PostsController < ApplicationController
  respond_to :html
  
  def create
    @forum = Forum.find params[:forum_id]
    @topic = @forum.topics.find params[:topic_id]
    @post = @topic.posts.new params[:post]
    @post.user = current_user
    @post.save
    @recent_posts = @topic.posts.order{created_at.desc}.includes(:user).limit(3)
    respond_with @forum, @topic, @post, :location => forum_topic_path(@forum, @topic, :page => "p#{@post.id}", :anchor => "post#{@post.id}")
  end
  
  def destroy
    @forum = Forum.find params[:forum_id]
    @topic = @forum.topics.find params[:topic_id]
    @post = @topic.posts.find params[:id]
    @post.destroy
    respond_with @forum, @topic, @post
  end
  
  def edit
    @forum = Forum.find params[:forum_id]
    @topic = @forum.topics.find params[:topic_id]
    @post = @topic.posts.find params[:id]
    respond_with @forum, @topic, @post
  end
  
  def new
    @forum = Forum.find params[:forum_id]
    @topic = @forum.topics.find params[:topic_id]
    @post = @topic.posts.new
    @post.post = ""
    @recent_posts = @topic.posts.order{created_at.desc}.includes(:user).limit(3)
    
    if params[:quote]
      @quote = Post.find params[:quote]
      
      @post.post << "> _**#{@quote.user.username}** skrifaði:_\n>\n"
      
      @quote.post.to_s.each_line do |line|
        @post.post << "> " + line
      end
      
      @post.post << "\n\n"
    end
    
    respond_with @forum, @topic, @post
  end
  
  def update
    @forum = Forum.find params[:forum_id]
    @topic = @forum.topics.find params[:topic_id]
    @post = @topic.posts.find params[:id]
    @post.update_attributes params[:post]
    respond_with @forum, @topic, @post, :location => forum_topic_path(@forum, @topic, :page => "p#{@post.id}", :anchor => "post#{@post.id}")
  end
end
{'fraction_non_alphanumeric': 0.15454796792922312, 'fraction_numerical': 0.0016588332872546309, 'mean_word_length': 3.097395243488109, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '1668528', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1271, 'n_words': 258}