From 74c0cee5ee342dc3b0a22437d9392ed5e3628b2a Mon Sep 17 00:00:00 2001 From: albert Date: Sun, 17 Feb 2013 00:59:19 -0500 Subject: [PATCH] routing fixes --- app/controllers/janitor_trials_controller.rb | 1 + app/controllers/legacy_controller.rb | 8 ++++++++ app/models/mod_action.rb | 10 ++++++++++ app/views/pool_versions/index.html.erb | 2 +- config/routes.rb | 6 ++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/controllers/janitor_trials_controller.rb b/app/controllers/janitor_trials_controller.rb index db38f3a2b..60633893a 100644 --- a/app/controllers/janitor_trials_controller.rb +++ b/app/controllers/janitor_trials_controller.rb @@ -1,5 +1,6 @@ class JanitorTrialsController < ApplicationController respond_to :html, :xml, :json + before_filter :moderator_only, :only => [:create, :promote, :demote] def new @janitor_trial = JanitorTrial.new diff --git a/app/controllers/legacy_controller.rb b/app/controllers/legacy_controller.rb index 1c4ea040b..27eba6690 100644 --- a/app/controllers/legacy_controller.rb +++ b/app/controllers/legacy_controller.rb @@ -1,9 +1,17 @@ class LegacyController < ApplicationController + before_filter :member_only, :only => [:create_post] + def posts @post_set = PostSets::Post.new(tag_query, params[:page], params[:limit]) @posts = @post_set.posts end + def create_post + @upload = Upload.create(params[:post].merge(:server => Socket.gethostname)) + @upload.delay.process! + render :nothing => true + end + def users @users = User.search(params).limit(100) end diff --git a/app/models/mod_action.rb b/app/models/mod_action.rb index 529aac5ff..57de91148 100644 --- a/app/models/mod_action.rb +++ b/app/models/mod_action.rb @@ -2,6 +2,16 @@ class ModAction < ActiveRecord::Base belongs_to :creator, :class_name => "User" before_validation :initialize_creator, :on => :create + def self.search(params = {}) + q = scoped() + + if params[:creator_id] + q = q.where("creator_id = ?", params[:creator_id].to_i) + end + + q + end + def initialize_creator self.creator_id = CurrentUser.id end diff --git a/app/views/pool_versions/index.html.erb b/app/views/pool_versions/index.html.erb index 5d576fbc5..054bfc3cf 100644 --- a/app/views/pool_versions/index.html.erb +++ b/app/views/pool_versions/index.html.erb @@ -18,7 +18,7 @@ <% @pool_versions.each do |pool_version| %> <%= pool_version.pool.name %> - <%= link_to pool_version.post_id_array.size, pool_version_path(pool_version) %> + <%= link_to pool_version.post_id_array.size, pool_versions_path(:search => {:pool_id => pool_version.pool_id}) %> <%= pool_version_diff(pool_version) %> <%= link_to pool_version.updater.name, user_path(pool_version.updater) %> diff --git a/config/routes.rb b/config/routes.rb index d41fc4338..2f601bc21 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -196,6 +196,7 @@ Danbooru::Application.routes.draw do match "/artist" => redirect {|params, req| "/artists?page=#{req.params[:page]}"} match "/artist/index" => redirect {|params, req| "/artists?page=#{req.params[:page]}"} match "/artist/show/:id" => redirect("/artists/%{id}") + match "/artist/show" => redirect {|params, req| "/artists?name=#{req.params[:name]}"} match "/artist/history/:id" => redirect("/artist_versions?search[artist_id]=%{id}") match "/comment" => redirect {|params, req| "/comments?page=#{req.params[:page]}"} @@ -221,6 +222,7 @@ Danbooru::Application.routes.draw do match "/post/index.xml", :controller => "legacy", :action => "posts", :format => "xml" match "/post/index.json", :controller => "legacy", :action => "posts", :format => "json" + match "/post/create.xml", :controller => "legacy", :action => "create_post" match "/post/index" => redirect {|params, req| "/posts?tags=#{req.params[:tags].to_s.gsub(/ /, '%20')}&page=#{req.params[:page]}"} match "/post" => redirect {|params, req| "/posts?tags=#{req.params[:tags].to_s.gsub(/ /, '%20')}&page=#{req.params[:page]}"} match "/post/upload" => redirect("/uploads/new") @@ -232,6 +234,8 @@ 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/view/:id/:tag_title" => redirect("/posts/%{id}") + match "/post/view/:id" => redirect("/posts/%{id}") match "/post_tag_history" => redirect {|params, req| "/post_versions?page=#{req.params[:page]}"} match "/post_tag_history/index" => redirect {|params, req| "/post_versions?page=#{req.params[:page]}"} @@ -245,6 +249,8 @@ Danbooru::Application.routes.draw do match "/user/index.json", :controller => "legacy", :action => "users", :format => "json" match "/user" => redirect {|params, req| "/users?page=#{req.params[:page]}"} match "/user/index" => redirect {|params, req| "/users?page=#{req.params[:page]}"} + match "/user/show/:id" => redirect("/users/%{id}") + match "/user/login" => redirect("/sessions/new") match "/wiki" => redirect {|params, req| "/wiki_pages?page=#{req.params[:page]}"} match "/wiki/index" => redirect {|params, req| "/wiki_pages?page=#{req.params[:page]}"}