Fixed I18n.locale bu in wiki page.
This commit is contained in:
parent
cc4e925c1a
commit
8e04074cd3
1 changed files with 16 additions and 6 deletions
|
@ -6,8 +6,11 @@ module PagesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def wikified_body(body, title = nil)
|
def wikified_body(body, title = nil)
|
||||||
render_opts = {:locale => I18n.locale} # workaround for wikicloth 0.8.0 https://github.com/nricciar/wikicloth/pull/59
|
WikiCloth.new(:data => body+"\n",
|
||||||
WikiCloth.new({:data => body+"\n", :link_handler => Wikilink.new, :params => {:referer => title}}).to_html(render_opts).html_safe
|
:link_handler => Wikilink.new,
|
||||||
|
:params => {:referer => title})
|
||||||
|
.to_html(wikicloth_render_options)
|
||||||
|
.html_safe
|
||||||
rescue => e
|
rescue => e
|
||||||
"<span class='alert alert-error'>#{t('.wikicloth_exception', :msg => e)}</span>".html_safe # try the following with line breaks: === one === == two == = three =
|
"<span class='alert alert-error'>#{t('.wikicloth_exception', :msg => e)}</span>".html_safe # try the following with line breaks: === one === == two == = three =
|
||||||
end
|
end
|
||||||
|
@ -44,11 +47,12 @@ module PagesHelper
|
||||||
|
|
||||||
toc << "*" * number + " #{name}\n"
|
toc << "*" * number + " #{name}\n"
|
||||||
end
|
end
|
||||||
logger.debug toc.inspect
|
|
||||||
unless toc.blank?
|
|
||||||
toc = WikiCloth.new({:data => toc, :link_handler => Wikilink.new}).to_html
|
|
||||||
|
|
||||||
toc.gsub(/<li>([^<>\n]*)/) do
|
unless toc.blank?
|
||||||
|
WikiCloth.new(:data => toc,
|
||||||
|
:link_handler => Wikilink.new)
|
||||||
|
.to_html(wikicloth_render_options)
|
||||||
|
.gsub(/<li>([^<>\n]*)/) do
|
||||||
name = $1
|
name = $1
|
||||||
anchor = name.gsub(/\s/, '_').gsub(/[^a-zA-Z_]/, '')
|
anchor = name.gsub(/\s/, '_').gsub(/[^a-zA-Z_]/, '')
|
||||||
"<li><a href='##{anchor}'>#{name.truncate(20)}</a>"
|
"<li><a href='##{anchor}'>#{name.truncate(20)}</a>"
|
||||||
|
@ -69,4 +73,10 @@ module PagesHelper
|
||||||
token = TokenVerifier.new(['wiki', 'all']).generate
|
token = TokenVerifier.new(['wiki', 'all']).generate
|
||||||
all_pages_url({:format => 'rss', :token => token}.merge(options))
|
all_pages_url({:format => 'rss', :token => token}.merge(options))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def wikicloth_render_options
|
||||||
|
{:locale => I18n.locale} # workaround for wikicloth 0.8.0 https://github.com/nricciar/wikicloth/pull/59
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue