This commit is contained in:
albert
2013-01-14 11:23:43 -05:00
parent 7b4f7c5532
commit 7bca79e71a
11 changed files with 81 additions and 10 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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 %{<a href="#{h(url)}" #{attributes}>#{text}</a>}
end
def format_text(text, options = {})
DText.parse(text)
end

View File

@@ -1,3 +1,3 @@
<% if post.hidden_comment_count(@current_user) > 0 %>
<span class="info" id="threshold-comments-notice-for-<%= post.id %>"><%= link_to_remote "#{pluralize post.hidden_comment_count(@current_user), 'comment'} below threshold", :url => {:controller => "comment", :action => "index_all", :post_id => post.id} %>.</span>
<span class="info" id="threshold-comments-notice-for-<%= post.id %>"><%= link_to_remote "#{pluralize post.hidden_comment_count(@current_user), 'comment'} below threshold", :url => index_all_comments_path(:post_id => post.id) %>.</span>
<% end %>

View File

@@ -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) %>
<article data-width="<%= note.width %>" data-height="<%= note.height %>" data-x="<%= note.x %>" note-y="<%= note.y %>" data-id="<%= note.id %>">
<%= raw DText.sanitize(note.body) %>
</article>

View File

@@ -45,7 +45,7 @@
</div>
<%= content_for(:html_header) do %>
<%= auto_discovery_link_tag :atom, :controller => "posts", :action => "index", :format => "atom", :tags => params[:tags] %>
<link href="<%= posts_path(:format => 'atom', :tags => params[:tags]) %>" rel="alternate" title="ATOM" type="application/atom+xml" />
<% if @post_set.wiki_page %>
<meta name="description" content="<%= @post_set.wiki_page.presenter.blurb %>"></meta>
<% end %>

View File

@@ -29,8 +29,8 @@
<section>
<h1>History</h1>
<ul>
<li><%= link_to "Tags", post_versions_path(:search => {:post_id => @post.id}) %></li>
<li><%= link_to "Notes", note_versions_path(:search => {:post_id => @post.id}) %></li>
<li><%= fast_link_to "Tags", post_versions_path(:search => {:post_id => @post.id}) %></li>
<li><%= fast_link_to "Notes", note_versions_path(:search => {:post_id => @post.id}) %></li>
</ul>
</section>

View File

@@ -9,7 +9,7 @@
<li>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.</li>
<li>The Site reserves the right to delete or modify your account, or any content you have posted to the site.</li>
<li>You will make a best faith effort to upload only high quality anime-related images.</li>
<li>You have read the <%= link_to "tagging guidelines", :controller => "help", :action => "tags" %>.</li>
<li>You have read the <%= link_to "tagging guidelines", wiki_pages_path(:title => "help:tags") %>.</li>
</ul>
<div class="section">

View File

@@ -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

View File

@@ -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

View File

@@ -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');
INSERT INTO schema_migrations (version) VALUES ('20130106210658');
INSERT INTO schema_migrations (version) VALUES ('20130114154400');