Fix anchor links in Wiki

Fixes #558.
This commit is contained in:
JuliusR 2019-06-13 12:06:55 +02:00 committed by wvengen
parent 00458f79ab
commit 8b0c749c5b
1 changed files with 6 additions and 3 deletions

View File

@ -9,10 +9,13 @@ module FoodsoftWiki
url_for page
end
link_attributes_for do |page|
link_attributes_for do |page_anchor|
page, anchor = page_anchor.split(/#/, 2)
permalink = Page.permalink(page)
if Page.exists?(:permalink => permalink)
{ href: url_for(:wiki_page_path, permalink: permalink) }
if page.empty?
{ href: '#' + anchor }
elsif Page.exists?(:permalink => permalink)
{ href: url_for(:wiki_page_path, permalink: permalink, anchor: anchor) }
else
{ href: url_for(:new_page_path, title: page, parent: params[:referer]), class: 'new_wiki_link' }
end