Cleanup wiki plugin a bit
This commit is contained in:
parent
b42672c06c
commit
be128243fc
4 changed files with 42 additions and 37 deletions
35
plugins/wiki/lib/foodsoft_wiki/wiki_parser.rb
Normal file
35
plugins/wiki/lib/foodsoft_wiki/wiki_parser.rb
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
module FoodsoftWiki
|
||||
class WikiParser < WikiCloth::Parser
|
||||
|
||||
url_for do |page|
|
||||
url_for page
|
||||
end
|
||||
|
||||
link_attributes_for do |page|
|
||||
permalink = Page.permalink(page)
|
||||
if Page.exists?(:permalink => permalink)
|
||||
{ href: url_for(:wiki_page_path, permalink: permalink) }
|
||||
else
|
||||
{ href: url_for(:new_page_path, title: page, parent: params[:referer]), class: 'new_wiki_link' }
|
||||
end
|
||||
end
|
||||
|
||||
section_link do |section|
|
||||
""
|
||||
end
|
||||
|
||||
def to_html(render_options = {})
|
||||
# workaround for wikicloth 0.8.0 https://github.com/nricciar/wikicloth/pull/59
|
||||
render_options[:locale] ||= I18n.locale
|
||||
super(render_options)
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def url_for(path_name, options={})
|
||||
Rails.application.routes.url_helpers.send path_name, options.merge({foodcoop: FoodsoftConfig.scope})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue