diff --git a/Gemfile.lock b/Gemfile.lock index c9770a399..615f3d644 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -103,7 +103,7 @@ GEM coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.3.1) - rack (1.4.3) + rack (1.4.4) rack-cache (1.2) rack (>= 0.4) rack-ssl (1.3.2) diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index bcc79cfaa..cfb623c05 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -1,5 +1,28 @@ class StaticController < ApplicationController - def jquery_test + def benchmark + n = 1_000 + + Benchmark.bm do |x| + x.report("default") do + n.times do + view_context.link_to("test", :controller => "posts", :action => "index", :tags => "abc") + end + end + + x.report("posts_path") do + n.times do + view_context.link_to("test", posts_path(:tags => "abc")) + end + end + + x.report("fast link to") do + n.times do + view_context.fast_link_to("test", :controller => "posts", :action => "index", :tags => "abc") + end + end + end + + render :nothing => true end def terms_of_service diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6ad9dd5c1..fce5e8e63 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -9,6 +9,38 @@ module ApplicationHelper content_tag("li", link_to(text, url, options), :class => klass) end + def fast_link_to(text, link_params, options = {}) + if options + attributes = options.map do |k, v| + %{#{k}="#{h(v)}"} + end.join(" ") + else + attributes = "" + end + + if link_params.is_a?(Hash) + action = link_params.delete(:action) + controller = link_params.delete(:controller) || controller_name + id = link_params.delete(:id) + + link_params = link_params.map {|k, v| "#{k}=#{u(v)}"}.join("&") + + if link_params.present? + link_params = "?#{link_params}" + end + + if id + url = "/#{controller}/#{action}/#{id}#{link_params}" + else + url = "/#{controller}/#{action}#{link_params}" + end + else + url = link_params + end + + raw %{#{text}} + end + def format_text(text, options = {}) DText.parse(text) end diff --git a/app/views/comments/partials/index/_threshold.html.erb b/app/views/comments/partials/index/_threshold.html.erb index 5b02e190d..449a7ab96 100644 --- a/app/views/comments/partials/index/_threshold.html.erb +++ b/app/views/comments/partials/index/_threshold.html.erb @@ -1,3 +1,3 @@ <% if post.hidden_comment_count(@current_user) > 0 %> - <%= link_to_remote "#{pluralize post.hidden_comment_count(@current_user), 'comment'} below threshold", :url => {:controller => "comment", :action => "index_all", :post_id => post.id} %>. + <%= link_to_remote "#{pluralize post.hidden_comment_count(@current_user), 'comment'} below threshold", :url => index_all_comments_path(:post_id => post.id) %>. <% end %> diff --git a/app/views/notes/_note.html.erb b/app/views/notes/_note.html.erb index a4972c3fb..4d4f860c7 100644 --- a/app/views/notes/_note.html.erb +++ b/app/views/notes/_note.html.erb @@ -1 +1,3 @@ -<%= content_tag(:article, raw(DText.sanitize(note.body)), "data-width" => note.width, "data-height" => note.height, "data-x" => note.x, "data-y" => note.y, "data-id" => note.id) %> +
+ <%= raw DText.sanitize(note.body) %> +
\ No newline at end of file diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb index e77bfd0f4..ace6f2d52 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -45,7 +45,7 @@ <%= content_for(:html_header) do %> - <%= auto_discovery_link_tag :atom, :controller => "posts", :action => "index", :format => "atom", :tags => params[:tags] %> + <% if @post_set.wiki_page %> <% end %> diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index f0784704e..75cf09b3b 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -29,8 +29,8 @@

History

diff --git a/app/views/static/terms_of_service.html.erb b/app/views/static/terms_of_service.html.erb index e83cc3850..5d757a6f0 100644 --- a/app/views/static/terms_of_service.html.erb +++ b/app/views/static/terms_of_service.html.erb @@ -9,7 +9,7 @@
  • The Site is presented to you AS IS, without any warranty, express or implied. You will not hold the Site or its staff members liable for damages caused by the use of the site.
  • The Site reserves the right to delete or modify your account, or any content you have posted to the site.
  • You will make a best faith effort to upload only high quality anime-related images.
  • -
  • You have read the <%= link_to "tagging guidelines", :controller => "help", :action => "tags" %>.
  • +
  • You have read the <%= link_to "tagging guidelines", wiki_pages_path(:title => "help:tags") %>.
  • diff --git a/config/routes.rb b/config/routes.rb index afc05c885..ae13c3543 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -65,6 +65,7 @@ Danbooru::Application.routes.draw do resources :votes, :controller => "comment_votes", :only => [:create, :destroy] collection do get :search + get :index_all end end resources :delayed_jobs, :only => [:index] @@ -253,6 +254,7 @@ Danbooru::Application.routes.draw do match "/static/terms_of_service" => "static#terms_of_service", :as => "terms_of_service" match "/static/mrtg" => "static#mrtg", :as => "mrtg" match "/static/contact" => "static#contact", :as => "contact" + match "/static/benchmark" => "static#benchmark" root :to => "posts#index" end diff --git a/db/migrate/20130114154400_add_queue_to_delayed_jobs.rb b/db/migrate/20130114154400_add_queue_to_delayed_jobs.rb new file mode 100644 index 000000000..072c8d40c --- /dev/null +++ b/db/migrate/20130114154400_add_queue_to_delayed_jobs.rb @@ -0,0 +1,9 @@ +class AddQueueToDelayedJobs < ActiveRecord::Migration + def self.up + add_column :delayed_jobs, :queue, :string + end + + def self.down + remove_column :delayed_jobs, :queue + end +end diff --git a/db/structure.sql b/db/structure.sql index 3d348dddf..a2593b436 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -722,7 +722,8 @@ CREATE TABLE delayed_jobs ( failed_at timestamp without time zone, locked_by character varying(255), created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + updated_at timestamp without time zone NOT NULL, + queue character varying(255) ); @@ -6172,4 +6173,6 @@ INSERT INTO schema_migrations (version) VALUES ('20110815233456'); INSERT INTO schema_migrations (version) VALUES ('20111101212358'); -INSERT INTO schema_migrations (version) VALUES ('20130106210658'); \ No newline at end of file +INSERT INTO schema_migrations (version) VALUES ('20130106210658'); + +INSERT INTO schema_migrations (version) VALUES ('20130114154400'); \ No newline at end of file