foodsoft/lib/wikilink.rb

22 lines
852 B
Ruby
Raw Normal View History

class Wikilink < WikiCloth::WikiLinkHandler
2010-03-22 03:11:32 +01:00
include ActionController::UrlWriter # To use named routes
def link_attributes_for(page)
permalink = Page.permalink(page)
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
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})) }
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"}
end
end
def section_link(section)
""
end
2010-03-22 03:11:32 +01:00
end