2009-03-25 19:54:04 +01:00
|
|
|
module PagesHelper
|
2009-08-11 14:30:35 +02:00
|
|
|
include WikiCloth
|
2009-03-25 19:54:04 +01:00
|
|
|
|
2009-08-11 14:30:35 +02:00
|
|
|
# def build_anchors(body)
|
|
|
|
# body.gsub(/(<h\d{1}>(.+)<\/h\d{1}>)/) do
|
|
|
|
# header = $1
|
|
|
|
# token = $2.downcase.gsub(' ', '-')
|
|
|
|
# "<a name='#{token}'> </a>#{header}"
|
|
|
|
# end
|
|
|
|
# end
|
2009-06-11 22:40:56 +02:00
|
|
|
|
2009-08-12 18:41:25 +02:00
|
|
|
def wikified_body(page)
|
2009-08-12 18:47:33 +02:00
|
|
|
WikiCloth.new({:data => page.body+"\n", :link_handler => Wikilink.new, :params => {:referer => page.title}}).to_html
|
2009-06-11 22:40:56 +02:00
|
|
|
end
|
2009-05-20 14:06:40 +02:00
|
|
|
|
2009-08-12 18:41:25 +02:00
|
|
|
def link_to_wikipage(page)
|
|
|
|
link_to page.title, "/wiki/#{page.title}"
|
|
|
|
end
|
2009-08-11 14:30:35 +02:00
|
|
|
# def generate_toc(body)
|
|
|
|
# toc = ""
|
|
|
|
# body.gsub(/^([=]{1,6})\s*(.*?)\s*(\1)/) do
|
|
|
|
# number = $1.length - 1
|
|
|
|
# name = $2
|
|
|
|
#
|
|
|
|
# toc << "#" * number + " #{name}\n"
|
|
|
|
# end
|
|
|
|
# toc = WikiCloth.new({:data => toc, :link_handler => Wikilink.new}).to_html
|
|
|
|
#
|
|
|
|
# toc.gsub(/<li>([^<>\n]*)/) do
|
|
|
|
# name = $1
|
|
|
|
# token = name.downcase.gsub(' ', '-')
|
|
|
|
#
|
|
|
|
# "<li><a href='##{token}'>#{name}</a>"
|
|
|
|
# end
|
|
|
|
# end
|
2009-05-20 14:06:40 +02:00
|
|
|
|
2009-03-25 19:54:04 +01:00
|
|
|
end
|