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}"
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)
# toc = ""
# body.gsub(/^([=]{1,6})\s*(.*?)\s*(\1)/) do

View File

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

View File

@ -2,7 +2,7 @@
.wiki_edit
#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
%span.wikiSeparator >
= link_to_wikipage(page)

View File

@ -2,7 +2,7 @@
.wiki_new
#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])
- if parent_page != nil
- for page in parent_page.ancestors.reverse

View File

@ -3,7 +3,7 @@
.wiki_show
#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
%span.wikiSeparator >
= link_to_wikipage(page)

View File

@ -2,7 +2,7 @@
.wiki_version
#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
%span.wikiSeparator >
= link_to_wikipage(page)