Merge branch 'wiki'
Conflicts: app/helpers/pages_helper.rb public/stylesheets/main.css public/stylesheets/print.css
This commit is contained in:
commit
529956ea5a
15 changed files with 381 additions and 180 deletions
|
|
@ -12,6 +12,10 @@ module ApplicationHelper
|
|||
def format_datetime(time = Time.now)
|
||||
I18n.l(time) unless time.nil?
|
||||
end
|
||||
|
||||
def format_datetime_timespec(time, format)
|
||||
I18n.l(time, :format => format) unless (time.nil? or format.nil?)
|
||||
end
|
||||
|
||||
# Creates ajax-controlled-links for pagination
|
||||
# see also the plugin "will_paginate"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,6 @@
|
|||
module PagesHelper
|
||||
include WikiCloth
|
||||
|
||||
# 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
|
||||
|
||||
def wikified_body(body, title = nil)
|
||||
WikiCloth.new({:data => body+"\n", :link_handler => Wikilink.new, :params => {:referer => title}}).to_html
|
||||
end
|
||||
|
|
@ -36,22 +28,24 @@ module PagesHelper
|
|||
end
|
||||
end
|
||||
end
|
||||
# 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
|
||||
|
||||
def generate_toc(body)
|
||||
toc = String.new
|
||||
body.gsub(/^([=]{1,6})\s*(.*?)\s*(\1)/) do
|
||||
number = $1.length - 1
|
||||
name = $2
|
||||
|
||||
toc << "*" * number + " #{name}\n"
|
||||
end
|
||||
logger.debug toc.inspect
|
||||
unless toc.blank?
|
||||
toc = WikiCloth.new({:data => toc, :link_handler => Wikilink.new}).to_html
|
||||
|
||||
section_count = 0
|
||||
toc.gsub(/<li>([^<>\n]*)/) do
|
||||
section_count += 1
|
||||
"<li><a href='#section-#{section_count}'>#{$1}</a>"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue