Fixed hard coded links in wiki pages.
This commit is contained in:
parent
571548dfbc
commit
d6ee00db17
2 changed files with 12 additions and 14 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue