2009-08-11 14:30:35 +02:00
|
|
|
class Wikilink < WikiCloth::WikiLinkHandler
|
2010-03-22 03:11:32 +01:00
|
|
|
|
2009-08-11 14:30:35 +02:00
|
|
|
def link_attributes_for(page)
|
|
|
|
permalink = Page.permalink(page)
|
2012-08-24 19:52:38 +02:00
|
|
|
url_options = {:host => FoodsoftConfig[:host], :protocol => FoodsoftConfig[:protocol]}
|
|
|
|
url_options.merge!({:port => FoodsoftConfig[:port]}) if FoodsoftConfig[:port]
|
2010-03-22 03:11:32 +01:00
|
|
|
|
2009-08-11 14:30:35 +02:00
|
|
|
if Page.exists?(:permalink => permalink)
|
2012-09-30 21:15:55 +02:00
|
|
|
{ :href => url_for(:wiki_page_path, permalink: permalink, use_route: :wiki_page) }
|
2009-08-11 14:30:35 +02:00
|
|
|
else
|
2012-09-30 21:15:55 +02:00
|
|
|
{ href: url_for(:new_page_path, title: page, parent: params[:referer]), class: 'new_wiki_link' }
|
2009-08-11 14:30:35 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def section_link(section)
|
|
|
|
""
|
|
|
|
end
|
2012-09-30 21:15:55 +02:00
|
|
|
|
|
|
|
def url_for(path_name, options = {})
|
|
|
|
Rails.application.routes.url_helpers.send path_name, options.merge({foodcoop: FoodsoftConfig.scope})
|
|
|
|
end
|
2010-03-22 03:11:32 +01:00
|
|
|
end
|