rubocop: fix various style issues.
This commit is contained in:
@@ -8,7 +8,7 @@ module ApplicationHelper
|
||||
|
||||
def wordbreakify(string)
|
||||
lines = string.scan(/.{1,10}/)
|
||||
wordbreaked_string = lines.map{|str| h(str)}.join("<wbr>")
|
||||
wordbreaked_string = lines.map {|str| h(str)}.join("<wbr>")
|
||||
raw(wordbreaked_string)
|
||||
end
|
||||
|
||||
@@ -43,7 +43,7 @@ module ApplicationHelper
|
||||
def error_messages_for(instance_name)
|
||||
instance = instance_variable_get("@#{instance_name}")
|
||||
|
||||
if instance && instance.errors.any?
|
||||
if 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
|
||||
""
|
||||
@@ -133,11 +133,11 @@ module ApplicationHelper
|
||||
return "anonymous" if user.blank?
|
||||
|
||||
user_class = "user-#{user.level_string.downcase}"
|
||||
user_class = user_class + " user-post-approver" if user.can_approve_posts?
|
||||
user_class = user_class + " user-post-uploader" if user.can_upload_free?
|
||||
user_class = user_class + " user-super-voter" if user.is_super_voter?
|
||||
user_class = user_class + " user-banned" if user.is_banned?
|
||||
user_class = user_class + " with-style" if CurrentUser.user.style_usernames?
|
||||
user_class += " user-post-approver" if user.can_approve_posts?
|
||||
user_class += " user-post-uploader" if user.can_upload_free?
|
||||
user_class += " user-super-voter" if user.is_super_voter?
|
||||
user_class += " user-banned" if user.is_banned?
|
||||
user_class += " with-style" if CurrentUser.user.style_usernames?
|
||||
if options[:raw_name]
|
||||
name = user.name
|
||||
else
|
||||
@@ -252,15 +252,13 @@ module ApplicationHelper
|
||||
CurrentUser.can_approve_posts? && (cookies[:moderated].blank? || Time.at(cookies[:moderated].to_i) < 72.hours.ago)
|
||||
end
|
||||
|
||||
protected
|
||||
protected
|
||||
|
||||
def nav_link_match(controller, url)
|
||||
url =~ case controller
|
||||
when "sessions", "users", "maintenance/user/password_resets", "admin/users"
|
||||
/^\/(session|users)/
|
||||
|
||||
when "forum_posts"
|
||||
/^\/forum_topics/
|
||||
|
||||
when "comments"
|
||||
/^\/comments/
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module ArtistVersionsHelper
|
||||
def artist_versions_listing_type
|
||||
params.dig(:search, :artist_id).present? && CurrentUser.is_member? ? :revert : :standard
|
||||
(params.dig(:search, :artist_id).present? && CurrentUser.is_member?) ? :revert : :standard
|
||||
end
|
||||
|
||||
def artist_version_other_names_diff(artist_version)
|
||||
|
||||
@@ -94,7 +94,7 @@ module BulkUpdateRequestsHelper
|
||||
"#{btag}remove implication " + link_to(arg1, posts_path(:tags => arg1)) + " (#{arg1_count}) -> " + link_to(arg2, posts_path(:tags => arg2)) + " (#{arg2_count})#{etag}"
|
||||
|
||||
when :mass_update
|
||||
"#{btag}mass update " + link_to(arg1, posts_path(:tags => arg1)) + " -> " + link_to(arg2, posts_path(:tags => arg2)) + "#{etag}"
|
||||
"#{btag}mass update " + link_to(arg1, posts_path(:tags => arg1)) + " -> " + link_to(arg2, posts_path(:tags => arg2)) + etag.to_s
|
||||
|
||||
when :change_category
|
||||
arg1_count = Tag.find_by_name(arg1).try(:post_count).to_i
|
||||
|
||||
@@ -54,7 +54,7 @@ module PaginationHelper
|
||||
else
|
||||
html << numbered_paginator_item(1, records.current_page)
|
||||
html << numbered_paginator_item("...", records.current_page)
|
||||
if records.size > 0
|
||||
if records.present?
|
||||
right_window = records.current_page + window
|
||||
else
|
||||
right_window = records.current_page
|
||||
@@ -62,13 +62,13 @@ module PaginationHelper
|
||||
(records.current_page - window).upto(right_window) do |page|
|
||||
html << numbered_paginator_item(page, records.current_page)
|
||||
end
|
||||
if records.size > 0
|
||||
if records.present?
|
||||
html << numbered_paginator_item("...", records.current_page)
|
||||
html << numbered_paginator_final_item(records.total_pages, records.current_page)
|
||||
end
|
||||
end
|
||||
|
||||
if records.current_page < records.total_pages && records.size > 0
|
||||
if records.current_page < records.total_pages && records.present?
|
||||
html << "<li class='arrow'>" + link_to(content_tag(:i, nil, class: "fas fa-chevron-right"), nav_params_for(records.current_page + 1), rel: "next", id: "paginator-next", "data-shortcut": "d right") + "</li>"
|
||||
else
|
||||
html << "<li class='arrow'><span>" + content_tag(:i, nil, class: "fas fa-chevron-right") + "</span></li>"
|
||||
@@ -93,7 +93,7 @@ module PaginationHelper
|
||||
if page == "..."
|
||||
html << "<li class='more'>"
|
||||
html << content_tag(:i, nil, class: "fas fa-ellipsis-h")
|
||||
html << "</li>"
|
||||
html << "</li>"
|
||||
elsif page == current_page
|
||||
html << "<li class='current-page'>"
|
||||
html << '<span>' + page.to_s + '</span>'
|
||||
|
||||
@@ -23,7 +23,7 @@ module PostsHelper
|
||||
|
||||
def missed_post_search_count_js
|
||||
return nil unless post_search_counts_enabled?
|
||||
|
||||
|
||||
if params[:ms] == "1" && @post_set.post_count == 0 && @post_set.is_single_tag?
|
||||
session_id = session.id
|
||||
verifier = ActiveSupport::MessageVerifier.new(Danbooru.config.reportbooru_key, serializer: JSON, digest: "SHA256")
|
||||
@@ -34,7 +34,7 @@ module PostsHelper
|
||||
|
||||
def post_search_count_js
|
||||
return nil unless post_search_counts_enabled?
|
||||
|
||||
|
||||
if params[:action] == "index" && params[:page].nil?
|
||||
tags = Tag.scan_query(params[:tags]).sort.join(" ")
|
||||
|
||||
@@ -68,7 +68,7 @@ module PostsHelper
|
||||
end
|
||||
|
||||
def post_favlist(post)
|
||||
post.favorited_users.reverse_each.map{|user| link_to_user(user)}.join(", ").html_safe
|
||||
post.favorited_users.reverse_each.map {|user| link_to_user(user)}.join(", ").html_safe
|
||||
end
|
||||
|
||||
def has_parent_message(post, parent_post_set)
|
||||
@@ -81,7 +81,7 @@ module PostsHelper
|
||||
sibling_count = parent_post_set.children.count - 1
|
||||
if sibling_count > 0
|
||||
html << " and has "
|
||||
text = sibling_count == 1 ? "a sibling" : "#{sibling_count} siblings"
|
||||
text = (sibling_count == 1) ? "a sibling" : "#{sibling_count} siblings"
|
||||
html << link_to(text, posts_path(:tags => "parent:#{post.parent_id}"))
|
||||
end
|
||||
|
||||
@@ -96,7 +96,7 @@ module PostsHelper
|
||||
html = ""
|
||||
|
||||
html << "This post has "
|
||||
text = children_post_set.children.count == 1 ? "a child" : "#{children_post_set.children.count} children"
|
||||
text = (children_post_set.children.count == 1) ? "a child" : "#{children_post_set.children.count} children"
|
||||
html << link_to(text, posts_path(:tags => "parent:#{post.id}"))
|
||||
|
||||
html << " (#{link_to_wiki "learn more", "help:post_relationships"}) "
|
||||
@@ -111,9 +111,9 @@ module PostsHelper
|
||||
end
|
||||
|
||||
def is_pool_selected?(pool)
|
||||
return false if params.has_key?(:q)
|
||||
return false if params.has_key?(:favgroup_id)
|
||||
return false if !params.has_key?(:pool_id)
|
||||
return false if params.key?(:q)
|
||||
return false if params.key?(:favgroup_id)
|
||||
return false if !params.key?(:pool_id)
|
||||
return params[:pool_id].to_i == pool.id
|
||||
end
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ module UploadsHelper
|
||||
|
||||
when /\Aerror: /
|
||||
search_params = params[:search].permit!
|
||||
link_to(upload.sanitized_status, uploads_path(search: search_params.merge({ status: upload.sanitized_status })))
|
||||
link_to(upload.sanitized_status, uploads_path(search: search_params.merge(status: upload.sanitized_status)))
|
||||
|
||||
else
|
||||
search_params = params[:search].permit!
|
||||
link_to(upload.status, uploads_path(search: search_params.merge({ status: upload.status })))
|
||||
link_to(upload.status, uploads_path(search: search_params.merge(status: upload.status)))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module UsersHelper
|
||||
def email_sig(user)
|
||||
verifier = ActiveSupport::MessageVerifier.new(Danbooru.config.email_key, serializer: JSON, digest: "SHA256")
|
||||
verifier.generate("#{user.id}")
|
||||
verifier.generate(user.id.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ module WikiPageVersionsHelper
|
||||
status = []
|
||||
status += ["Renamed"] if cur.title != prev.title
|
||||
status += ["Deleted"] if cur.is_deleted? && !prev.is_deleted?
|
||||
status += ["Undeleted"] if !cur.is_deleted? && prev.is_deleted?
|
||||
status += ["Undeleted"] if !cur.is_deleted? && prev.is_deleted?
|
||||
status.join(" ")
|
||||
end
|
||||
|
||||
@@ -27,15 +27,15 @@ module WikiPageVersionsHelper
|
||||
cbo = Diff::LCS::ContextDiffCallbacks.new
|
||||
diffs = thisarr.diff(otharr, cbo)
|
||||
|
||||
escape_html = ->(str) {str.gsub(/&/,'&').gsub(/</,'<').gsub(/>/,'>')}
|
||||
escape_html = ->(str) {str.gsub(/&/, '&').gsub(/</, '<').gsub(/>/, '>')}
|
||||
|
||||
output = thisarr
|
||||
output.each { |q| q.replace(escape_html[q]) }
|
||||
|
||||
diffs.reverse_each do |hunk|
|
||||
newchange = hunk.max{|a,b| a.old_position <=> b.old_position}
|
||||
newchange = hunk.max {|a, b| a.old_position <=> b.old_position}
|
||||
newstart = newchange.old_position
|
||||
oldstart = hunk.min{|a,b| a.old_position <=> b.old_position}.old_position
|
||||
oldstart = hunk.min {|a, b| a.old_position <=> b.old_position}.old_position
|
||||
|
||||
if newchange.action == '+'
|
||||
output.insert(newstart, '</ins>')
|
||||
@@ -50,7 +50,7 @@ module WikiPageVersionsHelper
|
||||
if chg.new_element.match(/^\r?\n$/)
|
||||
output.insert(chg.old_position, '<br>')
|
||||
else
|
||||
output.insert(chg.old_position, "#{escape_html[chg.new_element]}")
|
||||
output.insert(chg.old_position, (escape_html[chg.new_element]).to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -60,7 +60,7 @@ module WikiPageVersionsHelper
|
||||
end
|
||||
|
||||
if hunk[0].action == '-'
|
||||
output.insert((newstart == oldstart || newchange.action != '+') ? newstart+1 : newstart, '</del>')
|
||||
output.insert((newstart == oldstart || newchange.action != '+') ? newstart + 1 : newstart, '</del>')
|
||||
output.insert(oldstart, '<del>')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,14 +11,14 @@ module WikiPagesHelper
|
||||
html << "<h2>Posts (#{full_link})</h2>"
|
||||
html << wiki_page.post_set.presenter.post_previews_html(self)
|
||||
end
|
||||
|
||||
|
||||
html << "</div>"
|
||||
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
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 = 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
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user