2009-08-11 14:30:35 +02:00
|
|
|
class Wikilink < WikiCloth::WikiLinkHandler
|
2010-03-22 03:11:32 +01:00
|
|
|
include ActionController::UrlWriter # To use named routes
|
|
|
|
|
2009-08-11 14:30:35 +02:00
|
|
|
def link_attributes_for(page)
|
|
|
|
permalink = Page.permalink(page)
|
2010-03-22 03:11:32 +01:00
|
|
|
url_options = {:host => Foodsoft.config[:host], :protocol => Foodsoft.config[:protocol]}
|
|
|
|
url_options.merge!({:port => Foodsoft.config[:port]}) if Foodsoft.config[:port]
|
|
|
|
|
2009-08-11 14:30:35 +02:00
|
|
|
if Page.exists?(:permalink => permalink)
|
2010-03-22 03:11:32 +01:00
|
|
|
{ :href => url_for(url_options.merge({:controller => "pages", :action => "show",
|
|
|
|
:permalink => permalink, :use_route => :wiki_page})) }
|
2009-08-11 14:30:35 +02:00
|
|
|
else
|
2010-03-22 03:11:32 +01:00
|
|
|
{ :href => url_for(url_options.merge({:controller => "pages", :action => "new",
|
|
|
|
:title => page, :parent => params[:referer]})), :class => "new_wiki_link"}
|
2009-08-11 14:30:35 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def section_link(section)
|
|
|
|
""
|
|
|
|
end
|
2010-03-22 03:11:32 +01:00
|
|
|
end
|