Kill trailing whitespace in ruby files
This commit is contained in:
@@ -4,14 +4,14 @@ module AdvertisementsHelper
|
||||
@advertisement = Advertisement.find(:first, :conditions => ["ad_type = ? AND status = 'active'", ad_type], :order => "random()")
|
||||
if @advertisement
|
||||
content_tag(
|
||||
"div",
|
||||
"div",
|
||||
link_to(
|
||||
image_tag(
|
||||
@advertisement.image_url,
|
||||
:alt => "Advertisement",
|
||||
:width => @advertisement.width,
|
||||
@advertisement.image_url,
|
||||
:alt => "Advertisement",
|
||||
:width => @advertisement.width,
|
||||
:height => @advertisement.height
|
||||
),
|
||||
),
|
||||
advertisement_hits_path(:advertisement_id => @advertisement.id),
|
||||
:method => :post
|
||||
),
|
||||
@@ -22,7 +22,7 @@ module AdvertisementsHelper
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def render_rss_advertisement(short_or_long, safe)
|
||||
if Danbooru.config.can_see_ads?(CurrentUser.user)
|
||||
if safe
|
||||
|
||||
@@ -8,27 +8,27 @@ 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|
|
||||
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
|
||||
@@ -37,43 +37,43 @@ module ApplicationHelper
|
||||
else
|
||||
url = link_params
|
||||
end
|
||||
|
||||
|
||||
raw %{<a href="#{h(url)}" #{attributes}>#{text}</a>}
|
||||
end
|
||||
|
||||
|
||||
def format_text(text, options = {})
|
||||
DText.parse(text)
|
||||
end
|
||||
|
||||
def error_messages_for(instance_name)
|
||||
instance = instance_variable_get("@#{instance_name}")
|
||||
|
||||
|
||||
if instance && instance.errors.any?
|
||||
%{<div class="error-messages ui-state-error ui-corner-all"><strong>Error</strong>: #{instance.__send__(:errors).full_messages.join(", ")}</div>}.html_safe
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def time_tag(content, time)
|
||||
zone = time.strftime("%z")
|
||||
datetime = time.strftime("%Y-%m-%dT%H:%M" + zone[0, 3] + ":" + zone[3, 2])
|
||||
|
||||
|
||||
content_tag(:time, content || datetime, :datetime => datetime, :title => time.to_formatted_s)
|
||||
end
|
||||
|
||||
|
||||
def time_ago_in_words_tagged(time)
|
||||
raw time_tag(time_ago_in_words(time) + " ago", time)
|
||||
end
|
||||
|
||||
|
||||
def compact_time(time)
|
||||
time_tag(time.strftime("%Y-%m-%d %H:%M"), time)
|
||||
end
|
||||
|
||||
|
||||
def mod_link_to_user(user, positive_or_negative)
|
||||
html = ""
|
||||
html << link_to(user.name, user_path(user))
|
||||
|
||||
|
||||
if positive_or_negative == :positive
|
||||
html << " [" + link_to("+", new_user_feedback_path(:user_feedback => {:category => "positive", :user_id => user.id})) + "]"
|
||||
|
||||
@@ -83,26 +83,26 @@ module ApplicationHelper
|
||||
else
|
||||
html << " [" + link_to("–".html_safe, new_user_feedback_path(:user_feedback => {:category => "negative", :user_id => user.id})) + "]"
|
||||
end
|
||||
|
||||
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
|
||||
def dtext_field(object, name, options = {})
|
||||
options[:name] ||= "Body"
|
||||
options[:input_id] ||= "#{object}_#{name}"
|
||||
options[:input_name] ||= "#{object}[#{name}]"
|
||||
options[:value] ||= instance_variable_get("@#{object}").try(name)
|
||||
options[:preview_id] ||= "dtext-preview"
|
||||
|
||||
|
||||
render "dtext/form", options
|
||||
end
|
||||
|
||||
|
||||
def dtext_preview_button(object, name, options = {})
|
||||
options[:input_id] ||= "#{object}_#{name}"
|
||||
options[:preview_id] ||= "dtext-preview"
|
||||
submit_tag("Preview", "data-input-id" => options[:input_id], "data-preview-id" => options[:preview_id])
|
||||
end
|
||||
|
||||
|
||||
def search_field(method, options = {})
|
||||
name = options[:label] || method.titleize
|
||||
string = '<div class="input"><label for="search_' + method + '">' + name + '</label><input type="text" name="search[' + method + ']" id="search_' + method + '">'
|
||||
@@ -112,49 +112,49 @@ module ApplicationHelper
|
||||
string += '</div>'
|
||||
string.html_safe
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
def nav_link_match(controller, url)
|
||||
url =~ case controller
|
||||
when "sessions", "users", "maintenance/user/login_reminders", "maintenance/user/password_resets", "admin/users", "tag_subscriptions"
|
||||
/^\/(session|users)/
|
||||
|
||||
|
||||
when "forum_posts"
|
||||
/^\/forum_topics/
|
||||
|
||||
|
||||
when "comments"
|
||||
/^\/comments/
|
||||
|
||||
|
||||
when "notes", "note_versions"
|
||||
/^\/notes/
|
||||
|
||||
|
||||
when "posts", "uploads", "post_versions", "explore/posts", "moderator/post/dashboards", "favorites"
|
||||
/^\/post/
|
||||
|
||||
|
||||
when "artists", "artist_versions"
|
||||
/^\/artist/
|
||||
|
||||
|
||||
when "tags"
|
||||
/^\/tags/
|
||||
|
||||
|
||||
when "pools"
|
||||
/^\/pools/
|
||||
|
||||
|
||||
when "moderator/dashboards"
|
||||
/^\/moderator/
|
||||
|
||||
|
||||
when "tag_aliases", "tag_alias_corrections", "tag_alias_requests"
|
||||
/^\/tag_aliases/
|
||||
|
||||
|
||||
when "tag_implications", "tag_implication_requests"
|
||||
/^\/tag_implications/
|
||||
|
||||
|
||||
when "wiki_pages", "wiki_page_versions"
|
||||
/^\/wiki_pages/
|
||||
|
||||
|
||||
when "forum_topics", "forum_posts"
|
||||
/^\/forum_topics/
|
||||
|
||||
|
||||
else
|
||||
/^\/static/
|
||||
end
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
module ArtistsHelper
|
||||
def link_to_artist(name)
|
||||
artist = Artist.find_by_name(name)
|
||||
|
||||
|
||||
if artist
|
||||
link_to(artist.name, artist_path(artist))
|
||||
else
|
||||
link_to(name, new_artist_path(:name => name)) + " " + content_tag("span", "*", :class => "new-artist")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def link_to_artists(names)
|
||||
names.map do |name|
|
||||
names.map do |name|
|
||||
link_to_artist(name)
|
||||
end.join(", ").html_safe
|
||||
end
|
||||
|
||||
@@ -3,28 +3,28 @@ module DelayedJobsHelper
|
||||
case job.name
|
||||
when "Class#expire_cache"
|
||||
"<strong>expire post count cache</strong>: " + job.payload_object.args.flatten.join(" ")
|
||||
|
||||
|
||||
when "Upload#process!"
|
||||
'<strong>upload post</strong>: <a href="/uploads/' + job.payload_object.object.id.to_s + '">record</a>'
|
||||
|
||||
|
||||
when "Tag#update_related"
|
||||
"<strong>update related tags</strong>: " + job.payload_object.name
|
||||
|
||||
|
||||
when "TagAlias#process!"
|
||||
'<strong>alias</strong>: ' + job.payload_object.antecedent_name + " -> " + job.payload_object.consequent_name
|
||||
|
||||
|
||||
when "TagImplication#process!"
|
||||
'<strong>implication</strong>: ' + job.payload_object.antecedent_name + " -> " + job.payload_object.consequent_name
|
||||
|
||||
|
||||
when "Class#clear_cache_for"
|
||||
"<strong>expire tag alias cache</strong>: " + job.payload_object.flatten.join(" ")
|
||||
|
||||
|
||||
when "Tag#update_category_cache"
|
||||
"<strong>update tag category cache</strong>: " + job.payload_object.name
|
||||
|
||||
when "Tag#update_category_post_counts"
|
||||
"<strong>update category post counts</strong>: " + job.payload_object.name
|
||||
|
||||
|
||||
else
|
||||
job.handler
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ module Moderator
|
||||
["Moderator", 40],
|
||||
["Admin", 50]
|
||||
]
|
||||
|
||||
|
||||
select_tag(name, options_for_select(choices, params[name].to_i), options)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
module PaginationHelper
|
||||
def sequential_paginator(records)
|
||||
html = '<div class="paginator"><menu>'
|
||||
|
||||
if records.any?
|
||||
|
||||
if records.any?
|
||||
if params[:page] =~ /[ab]/
|
||||
html << '<li>' + link_to("< Previous", params.merge(:page => "a#{records[0].id}"), :rel => "prev") + '</li>'
|
||||
end
|
||||
|
||||
|
||||
html << '<li>' + link_to("Next >", params.merge(:page => "b#{records[-1].id}"), :rel => "next") + '</li>'
|
||||
end
|
||||
|
||||
|
||||
html << "</menu></div>"
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
|
||||
def use_sequential_paginator?(records)
|
||||
params[:page] =~ /[ab]/ || records.current_page >= Danbooru.config.max_numbered_pages
|
||||
end
|
||||
|
||||
|
||||
def numbered_paginator(records, switch_to_sequential = true)
|
||||
if use_sequential_paginator?(records) && switch_to_sequential
|
||||
return sequential_paginator(records)
|
||||
end
|
||||
|
||||
|
||||
html = '<div class="paginator"><menu>'
|
||||
window = 3
|
||||
|
||||
|
||||
if records.current_page >= 2
|
||||
html << "<li>" + link_to("<<", params.merge(:page => records.current_page - 1), :rel => "prev") + "</li>"
|
||||
end
|
||||
@@ -34,7 +34,7 @@ module PaginationHelper
|
||||
1.upto(records.total_pages) do |page|
|
||||
html << numbered_paginator_item(page, records.current_page)
|
||||
end
|
||||
|
||||
|
||||
elsif records.current_page <= window + 2
|
||||
1.upto(records.current_page + window) do |page|
|
||||
html << numbered_paginator_item(page, records.current_page)
|
||||
@@ -63,15 +63,15 @@ module PaginationHelper
|
||||
html << numbered_paginator_final_item(records.total_pages, records.current_page)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if records.current_page < records.total_pages && records.size > 0
|
||||
html << "<li>" + link_to(">>", params.merge(:page => records.current_page + 1), :rel => "next") + "</li>"
|
||||
end
|
||||
|
||||
|
||||
html << "</menu></div>"
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
|
||||
def numbered_paginator_final_item(total_pages, current_page)
|
||||
if total_pages <= Danbooru.config.max_numbered_pages
|
||||
numbered_paginator_item(total_pages, current_page)
|
||||
@@ -79,10 +79,10 @@ module PaginationHelper
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def numbered_paginator_item(page, current_page)
|
||||
return "" if page.to_i > Danbooru.config.max_numbered_pages
|
||||
|
||||
|
||||
html = "<li>"
|
||||
if page == "..."
|
||||
html << "..."
|
||||
|
||||
@@ -2,11 +2,11 @@ module PostAppealsHelper
|
||||
def post_appeal_reasons(post)
|
||||
html = []
|
||||
html << '<ul>'
|
||||
|
||||
|
||||
post.appeals.each do |appeal|
|
||||
html << '<li>' + DText.parse_inline(appeal.reason).html_safe + ' - ' + link_to(appeal.creator.name, user_path(appeal.creator)) + ' ' + time_ago_in_words_tagged(appeal.created_at) + '</li>'
|
||||
end
|
||||
|
||||
|
||||
html << '</ul>'
|
||||
html.join("\n").html_safe
|
||||
end
|
||||
|
||||
@@ -2,24 +2,24 @@ module PostFlagsHelper
|
||||
def post_flag_reasons(post)
|
||||
html = []
|
||||
html << '<ul>'
|
||||
|
||||
|
||||
post.flags.each do |flag|
|
||||
html << '<li>'
|
||||
html << DText.parse_inline(flag.reason).html_safe
|
||||
|
||||
|
||||
if CurrentUser.is_janitor?
|
||||
html << ' - ' + link_to(flag.creator.name, user_path(flag.creator))
|
||||
end
|
||||
|
||||
html << ' - ' + time_ago_in_words_tagged(flag.created_at)
|
||||
|
||||
|
||||
if flag.is_resolved?
|
||||
html << ' <span class="resolved">RESOLVED</span>'
|
||||
end
|
||||
|
||||
|
||||
html << '</li>'
|
||||
end
|
||||
|
||||
|
||||
html << '</ul>'
|
||||
html.join("\n").html_safe
|
||||
end
|
||||
|
||||
@@ -5,18 +5,18 @@ module PostsHelper
|
||||
if post.has_large?
|
||||
links << link_to("L", post.large_file_url, :id => "large-file-link")
|
||||
end
|
||||
|
||||
|
||||
if post.has_large?
|
||||
links << link_to("O", post.file_url, :id => "original-file-link")
|
||||
end
|
||||
|
||||
|
||||
if links.any?
|
||||
content_tag("span", raw("Resize: " + links.join(" ")))
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def post_source_tag(post)
|
||||
if post.source =~ /^http/
|
||||
text = truncate(post.normalized_source.sub(/^https?:\/\//, ""))
|
||||
|
||||
Reference in New Issue
Block a user