From afdc61c31ab907dcd8b750638737c27760e4f93d Mon Sep 17 00:00:00 2001 From: Toks Date: Fri, 5 Jul 2013 10:33:54 -0400 Subject: [PATCH] fixes #1829 --- app/controllers/posts_controller.rb | 17 +++++++++++------ config/routes.rb | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 3a1f320fe..fe2cc88c0 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -9,12 +9,17 @@ class PostsController < ApplicationController rescue_from ActiveRecord::RecordNotFound, :with => :rescue_exception def index - @post_set = PostSets::Post.new(tag_query, params[:page], params[:limit] || CurrentUser.user.per_page, params[:raw]) - @posts = @post_set.posts - respond_with(@posts) do |format| - format.atom - format.xml do - render :xml => @posts.to_xml(:root => "posts") + if params[:md5].present? + @post = Post.find_by_md5(params[:md5]) + redirect_to post_path(@post) + else + @post_set = PostSets::Post.new(tag_query, params[:page], params[:limit] || CurrentUser.user.per_page, params[:raw]) + @posts = @post_set.posts + respond_with(@posts) do |format| + format.atom + format.xml do + render :xml => @posts.to_xml(:root => "posts") + end end end end diff --git a/config/routes.rb b/config/routes.rb index 24bedd4be..b4c53fa33 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -309,6 +309,7 @@ Danbooru::Application.routes.draw do match "/post/popular_by_month" => redirect("/explore/posts/popular") match "/post/show/:id/:tag_title" => redirect("/posts/%{id}") match "/post/show/:id" => redirect("/posts/%{id}") + match "/post/show" => redirect {|params, req| "/posts?md5=#{req.params[:md5]}"} match "/post/view/:id/:tag_title" => redirect("/posts/%{id}") match "/post/view/:id" => redirect("/posts/%{id}") match "/post/flag/:id" => redirect("/posts/%{id}")