From 76ed5c7cc34831d3fd394ef1bba91042e4acacc4 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Mon, 14 Oct 2019 17:47:40 +0000 Subject: [PATCH] code cleanup: rubocop: fix Layout/ElseAlignment in ApplicationHelper#parse_wiki_links git-svn-id: http://svn.redmine.org/redmine/trunk@18664 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ea61884c0..0ad9fc99f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -898,19 +898,26 @@ module ApplicationHelper anchor = sanitize_anchor_name(anchor) if anchor.present? # check if page exists wiki_page = link_project.wiki.find_page(page) - url = if anchor.present? && wiki_page.present? && (obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version)) && obj.page == wiki_page - "##{anchor}" - else - case options[:wiki_links] - when :local; "#{page.present? ? Wiki.titleize(page) : ''}.html" + (anchor.present? ? "##{anchor}" : '') - when :anchor; "##{page.present? ? Wiki.titleize(page) : title}" + (anchor.present? ? "_#{anchor}" : '') # used for single-file wiki export + url = + if anchor.present? && wiki_page.present? && (obj.is_a?(WikiContent) || + obj.is_a?(WikiContent::Version)) && obj.page == wiki_page + "##{anchor}" else - wiki_page_id = page.present? ? Wiki.titleize(page) : nil - parent = wiki_page.nil? && obj.is_a?(WikiContent) && obj.page && project == link_project ? obj.page.title : nil - url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project, - :id => wiki_page_id, :version => nil, :anchor => anchor, :parent => parent) + case options[:wiki_links] + when :local + "#{page.present? ? Wiki.titleize(page) : ''}.html" + (anchor.present? ? "##{anchor}" : '') + when :anchor + # used for single-file wiki export + "##{page.present? ? Wiki.titleize(page) : title}" + (anchor.present? ? "_#{anchor}" : '') + else + wiki_page_id = page.present? ? Wiki.titleize(page) : nil + parent = wiki_page.nil? && obj.is_a?(WikiContent) && obj.page && project == link_project ? obj.page.title : nil + url_for(:only_path => only_path, :controller => 'wiki', + :action => 'show', :project_id => link_project, + :id => wiki_page_id, :version => nil, :anchor => anchor, + :parent => parent) + end end - end link_to(title.present? ? title.html_safe : h(page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new'))) else # project or wiki doesn't exist