foodsoft/app/helpers/pages_helper.rb
Benjamin Meichsner f450070dbf First steps for an own wiki.
* Scaffold for Page Objekt
* Using textile for rendering html
* Easy wiki-links with [[wikipage]]
2009-03-25 19:54:04 +01:00

18 lines
507 B
Ruby

module PagesHelper
def wikified_body(body)
r = RedCloth.new(body)
r.gsub!(/\[\[(.*?)(\|(.*?))?\]\]/) { wiki_link($1, $3) }
sanitize r.to_html
r.to_html
end
def wiki_link(wiki_words, link_text = nil)
permalink = wiki_words.downcase.gsub(' ', '-')
if Page.exists?(:permalink => permalink)
link_to((link_text || wiki_words), wiki_page_url(permalink))
else
link_to((link_text || wiki_words), wiki_page_url(permalink), :class => "new_wiki_link")
end
end
end