diff --git a/app/controllers/counts_controller.rb b/app/controllers/counts_controller.rb new file mode 100644 index 000000000..9f5b16285 --- /dev/null +++ b/app/controllers/counts_controller.rb @@ -0,0 +1,7 @@ +class CountsController < ApplicationController + respond_to :xml, :json + + def posts + @count = Post.fast_count(params[:tags]) + end +end diff --git a/app/views/counts/posts.json.erb b/app/views/counts/posts.json.erb new file mode 100644 index 000000000..002fead90 --- /dev/null +++ b/app/views/counts/posts.json.erb @@ -0,0 +1 @@ +{"counts": {"posts": <%= @count %>}} \ No newline at end of file diff --git a/app/views/counts/posts.xml.erb b/app/views/counts/posts.xml.erb new file mode 100644 index 000000000..e89efa3a7 --- /dev/null +++ b/app/views/counts/posts.xml.erb @@ -0,0 +1,6 @@ + + + + <%= @count %> + + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 6d43b60b6..8886f94b2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -81,6 +81,11 @@ Danbooru::Application.routes.draw do get :index_all end end + resources :counts do + collection do + get :posts + end + end resources :delayed_jobs, :only => [:index] resources :dmails do collection do