rubocop: fix various Rubocop warnings.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
require 'dtext'
|
||||
|
||||
module ApplicationHelper
|
||||
def listing_type(*fields, member_check: true, types: [:revert, :standard])
|
||||
(fields.reduce(false) { |acc, field| acc || params.dig(:search, field).present? } && (!member_check || CurrentUser.is_member?) ? types[0] : types[1])
|
||||
@@ -11,8 +9,7 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
def diff_name_html(this_name, other_name)
|
||||
pattern = Regexp.new('.')
|
||||
DiffBuilder.new(this_name, other_name, pattern).build
|
||||
DiffBuilder.new(this_name, other_name, /./).build
|
||||
end
|
||||
|
||||
def diff_body_html(record, other, field)
|
||||
@@ -21,7 +18,7 @@ module ApplicationHelper
|
||||
return h(diff_record[field]).gsub(/\r?\n/, '<span class="paragraph-mark">¶</span><br>').html_safe
|
||||
end
|
||||
|
||||
pattern = Regexp.new('(?:<.+?>)|(?:\w+)|(?:[ \t]+)|(?:\r?\n)|(?:.+?)')
|
||||
pattern = /(?:<.+?>)|(?:\w+)|(?:[ \t]+)|(?:\r?\n)|(?:.+?)/
|
||||
DiffBuilder.new(record[field], other[field], pattern).build
|
||||
end
|
||||
|
||||
@@ -32,18 +29,17 @@ module ApplicationHelper
|
||||
return type == "previous" ? "New" : ""
|
||||
end
|
||||
|
||||
statuses = []
|
||||
record.class.status_fields.each do |field, status|
|
||||
if record.has_attribute?(field)
|
||||
statuses += [status] if record[field] != other[field]
|
||||
else
|
||||
statuses += [status] if record.send(field, type)
|
||||
end
|
||||
changed_fields = record.class.status_fields.select do |field, status|
|
||||
(record.has_attribute?(field) && record[field] != other[field]) ||
|
||||
(!record.has_attribute?(field) && record.send(field, type))
|
||||
end
|
||||
|
||||
statuses = changed_fields.map { |field, status| status }
|
||||
altered = record.updater_id != other.updater_id
|
||||
|
||||
%(<div class="version-statuses" data-altered="#{altered}">#{statuses.join("<br>")}</div>).html_safe
|
||||
tag.div(class: "version-statuses", "data-altered": altered) do
|
||||
safe_join(statuses, tag.br)
|
||||
end
|
||||
end
|
||||
|
||||
def wordbreakify(string)
|
||||
|
||||
@@ -4,7 +4,7 @@ module ForumTopicsHelper
|
||||
end
|
||||
|
||||
def available_min_user_levels
|
||||
ForumTopic::MIN_LEVELS.select { |name, level| level <= CurrentUser.level }.to_a
|
||||
ForumTopic::MIN_LEVELS.select { |_name, level| level <= CurrentUser.level }.to_a
|
||||
end
|
||||
|
||||
def new_forum_topic?(topic, read_forum_topics)
|
||||
|
||||
@@ -22,11 +22,12 @@ module PopularPostsHelper
|
||||
end
|
||||
|
||||
def date_range_description(date, scale, min_date, max_date)
|
||||
if scale == "day"
|
||||
case scale
|
||||
when "day"
|
||||
date.strftime("%B %d, %Y")
|
||||
elsif scale == "week"
|
||||
when "week"
|
||||
"#{min_date.strftime("%B %d, %Y")} - #{max_date.strftime("%B %d, %Y")}"
|
||||
elsif scale == "month"
|
||||
when "month"
|
||||
date.strftime("%B %Y")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,12 +40,12 @@ module PostVersionsHelper
|
||||
def post_version_field(post_version, field)
|
||||
value = post_version_value(post_version.send(field))
|
||||
prefix = (field == :parent_id ? "parent" : field.to_s)
|
||||
search = prefix + ":" + value.to_s
|
||||
search = "#{prefix}:#{value}"
|
||||
display = (field == :rating ? post_version.pretty_rating : value)
|
||||
%(<b>#{field.to_s.titleize}:</b> #{link_to(display, posts_path(:tags => search))}).html_safe
|
||||
end
|
||||
|
||||
def post_version_value(value)
|
||||
return (value.present? ? value : "none")
|
||||
value.presence || "none"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
module WikiPagesHelper
|
||||
def wiki_page_other_names_list(wiki_page)
|
||||
names_html = wiki_page.other_names.map {|name| link_to(name, "http://www.pixiv.net/search.php?s_mode=s_tag_full&word=#{u(name)}", :class => "wiki-other-name")}
|
||||
names_html.join(" ").html_safe
|
||||
names_html = wiki_page.other_names.map do |name|
|
||||
link_to(name, "https://www.pixiv.net/tags/#{u(name)}/artworks", class: "wiki-other-name")
|
||||
end
|
||||
|
||||
safe_join(names_html, " ")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user