Fixed hard coded links in wiki pages.

This commit is contained in:
Benjamin Meichsner 2010-03-22 03:11:32 +01:00
parent 571548dfbc
commit d6ee00db17
2 changed files with 12 additions and 14 deletions

View file

@ -7,9 +7,9 @@ module PagesHelper
def link_to_wikipage(page, text = nil)
if text == nil
link_to page.title, "/wiki/#{page.title}"
link_to page.title, wiki_page_path(page.permalink)
else
link_to text, "/wiki/#{page.title}"
link_to text, wiki_page_path(page.permalink)
end
end

View file

@ -1,19 +1,17 @@
class Wikilink < WikiCloth::WikiLinkHandler
def url_for(page, parent = nil)
if parent
"/pages/new?title=#{page}&parent=#{parent}"
else
"/wiki/#{page}"
end
end
include ActionController::UrlWriter # To use named routes
def link_attributes_for(page)
permalink = Page.permalink(page)
url_options = {:host => Foodsoft.config[:host], :protocol => Foodsoft.config[:protocol]}
url_options.merge!({:port => Foodsoft.config[:port]}) if Foodsoft.config[:port]
if Page.exists?(:permalink => permalink)
{ :href => url_for(permalink) }
{ :href => url_for(url_options.merge({:controller => "pages", :action => "show",
:permalink => permalink, :use_route => :wiki_page})) }
else
{ :href => url_for(page, params[:referer]), :class => "new_wiki_link"}
{ :href => url_for(url_options.merge({:controller => "pages", :action => "new",
:title => page, :parent => params[:referer]})), :class => "new_wiki_link"}
end
end