First steps for an own wiki.
* Scaffold for Page Objekt * Using textile for rendering html * Easy wiki-links with [[wikipage]]
This commit is contained in:
parent
37199bae1d
commit
f450070dbf
16 changed files with 252 additions and 1 deletions
18
app/helpers/pages_helper.rb
Normal file
18
app/helpers/pages_helper.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue