Fix problem in breadcrumps, when no "Home"-page exists.

This commit is contained in:
sandoz 2009-08-19 22:59:53 +02:00
parent 42b5e7a73f
commit 47d3232e4e
6 changed files with 21 additions and 5 deletions

View file

@ -20,6 +20,22 @@ module PagesHelper
link_to text, "/wiki/#{page.title}" link_to text, "/wiki/#{page.title}"
end end
end end
def link_to_wikipage_by_permalink(permalink, text = nil)
unless permalink.blank?
page = Page.find_by_permalink(permalink)
if page.nil?
if text.nil?
link_to permalink, new_page_path(:title => permalink)
else
link_to text, new_page_path(:title => permalink)
end
else
link_to_wikipage(page, text)
end
end
end
# def generate_toc(body) # def generate_toc(body)
# toc = "" # toc = ""
# body.gsub(/^([=]{1,6})\s*(.*?)\s*(\1)/) do # body.gsub(/^([=]{1,6})\s*(.*?)\s*(\1)/) do

View file

@ -2,7 +2,7 @@
.wiki_all .wiki_all
#breadcrump #breadcrump
= link_to_wikipage(Page.find_by_permalink("Home"), "Foodcoop-Wiki") = link_to_wikipage_by_permalink("Home", "Foodcoop-Wiki")
%h1 Alle Wikiseite %h1 Alle Wikiseite

View file

@ -2,7 +2,7 @@
.wiki_edit .wiki_edit
#breadcrump #breadcrump
= link_to_wikipage(Page.find_by_permalink("Home"), "Foodcoop-Wiki") = link_to_wikipage_by_permalink("Home", "Foodcoop-Wiki")
- for page in @page.ancestors.reverse - for page in @page.ancestors.reverse
%span.wikiSeparator > %span.wikiSeparator >
= link_to_wikipage(page) = link_to_wikipage(page)

View file

@ -2,7 +2,7 @@
.wiki_new .wiki_new
#breadcrump #breadcrump
= link_to_wikipage(Page.find_by_permalink("Home"), "Foodcoop-Wiki") = link_to_wikipage_by_permalink("Home", "Foodcoop-Wiki")
- parent_page = Page.find_by_permalink(params[:parent]) - parent_page = Page.find_by_permalink(params[:parent])
- if parent_page != nil - if parent_page != nil
- for page in parent_page.ancestors.reverse - for page in parent_page.ancestors.reverse

View file

@ -3,7 +3,7 @@
.wiki_show .wiki_show
#breadcrump #breadcrump
= link_to_wikipage(Page.find_by_permalink("Home"), "Foodcoop-Wiki") = link_to_wikipage_by_permalink("Home", "Foodcoop-Wiki")
- for page in @page.ancestors.reverse - for page in @page.ancestors.reverse
%span.wikiSeparator > %span.wikiSeparator >
= link_to_wikipage(page) = link_to_wikipage(page)

View file

@ -2,7 +2,7 @@
.wiki_version .wiki_version
#breadcrump #breadcrump
= link_to_wikipage(Page.find_by_permalink("Home"), "Foodcoop-Wiki") = link_to_wikipage_by_permalink("Home", "Foodcoop-Wiki")
- for page in @page.ancestors.reverse - for page in @page.ancestors.reverse
%span.wikiSeparator > %span.wikiSeparator >
= link_to_wikipage(page) = link_to_wikipage(page)