|
|
|
@ -257,17 +257,22 @@ module OpenProject::TextFormatting::Formatters |
|
|
|
|
page = CGI.unescapeHTML(page) |
|
|
|
|
# check if page exists |
|
|
|
|
wiki_page = link_project.wiki.find_page(page) |
|
|
|
|
wiki_title = wiki_page.nil? ? page : wiki_page.title |
|
|
|
|
default_wiki_title = wiki_page.nil? ? page : wiki_page.title |
|
|
|
|
wiki_title = title || default_wiki_title |
|
|
|
|
url = case options[:wiki_links] |
|
|
|
|
when :local; |
|
|
|
|
"#{title}.html" |
|
|
|
|
when :anchor; |
|
|
|
|
"##{title}" # used for single-file wiki export |
|
|
|
|
when :local; "#{title}.html" |
|
|
|
|
when :anchor; "##{title}" # used for single-file wiki export |
|
|
|
|
else |
|
|
|
|
wiki_page_id = wiki_page.nil? ? page.to_url : wiki_page.slug |
|
|
|
|
url_for(only_path: only_path, controller: '/wiki', action: 'show', project_id: link_project, id: wiki_page_id, anchor: anchor) |
|
|
|
|
end |
|
|
|
|
link_to(h(title || wiki_title), url, class: ('wiki-page' + (wiki_page ? '' : ' new'))) |
|
|
|
|
url_for(only_path: only_path, |
|
|
|
|
controller: '/wiki', |
|
|
|
|
action: 'show', |
|
|
|
|
project_id: link_project, |
|
|
|
|
id: wiki_page_id, |
|
|
|
|
title: wiki_page.nil? ? wiki_title.strip : nil, |
|
|
|
|
anchor: anchor) |
|
|
|
|
end |
|
|
|
|
link_to(h(wiki_title), url, class: ('wiki-page' + (wiki_page ? '' : ' new'))) |
|
|
|
|
else |
|
|
|
|
# project or wiki doesn't exist |
|
|
|
|
all |
|
|
|
|