添加wiki插件,修改项目讨论区模块回去格式化字符串不正确的BUG
This commit is contained in:
parent
ef6f239182
commit
582ccd2ecf
|
@ -685,7 +685,7 @@ module ApplicationHelper
|
||||||
when 2
|
when 2
|
||||||
obj = args.shift
|
obj = args.shift
|
||||||
attr = args.shift
|
attr = args.shift
|
||||||
text = obj.send(attr).to_s
|
text = obj.send(attr).html_safe.to_s
|
||||||
else
|
else
|
||||||
raise ArgumentError, 'invalid arguments to textilizable'
|
raise ArgumentError, 'invalid arguments to textilizable'
|
||||||
end
|
end
|
||||||
|
@ -716,6 +716,48 @@ module ApplicationHelper
|
||||||
text.html_safe
|
text.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
#格式化字符串,不转义html代码
|
||||||
|
def textAreailizable(*args)
|
||||||
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
||||||
|
case args.size
|
||||||
|
when 1
|
||||||
|
obj = options[:object]
|
||||||
|
text = args.shift
|
||||||
|
when 2
|
||||||
|
obj = args.shift
|
||||||
|
attr = args.shift
|
||||||
|
text = obj.send(attr).html_safe.to_s
|
||||||
|
else
|
||||||
|
raise ArgumentError, 'invalid arguments to textilizable'
|
||||||
|
end
|
||||||
|
return '' if text.blank?
|
||||||
|
project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
|
||||||
|
only_path = options.delete(:only_path) == false ? false : true
|
||||||
|
|
||||||
|
text = text.dup
|
||||||
|
macros = catch_macros(text)
|
||||||
|
text = Redmine::WikiFormatting.to_html("CKEditor", text, :object => obj, :attribute => attr)
|
||||||
|
|
||||||
|
@parsed_headings = []
|
||||||
|
@heading_anchors = {}
|
||||||
|
@current_section = 0 if options[:edit_section_links]
|
||||||
|
|
||||||
|
parse_sections(text, project, obj, attr, only_path, options)
|
||||||
|
text = parse_non_pre_blocks(text, obj, macros) do |text|
|
||||||
|
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name|
|
||||||
|
send method_name, text, project, obj, attr, only_path, options
|
||||||
|
end
|
||||||
|
end
|
||||||
|
parse_headings(text, project, obj, attr, only_path, options)
|
||||||
|
|
||||||
|
if @parsed_headings.any?
|
||||||
|
replace_toc(text, @parsed_headings)
|
||||||
|
end
|
||||||
|
|
||||||
|
text.html_safe
|
||||||
|
end
|
||||||
|
|
||||||
def parse_non_pre_blocks(text, obj, macros)
|
def parse_non_pre_blocks(text, obj, macros)
|
||||||
s = StringScanner.new(text)
|
s = StringScanner.new(text)
|
||||||
tags = []
|
tags = []
|
||||||
|
|
|
@ -40,4 +40,14 @@ module WikiHelper
|
||||||
link_to(h(parent.pretty_title), {:controller => 'wiki', :action => 'show', :id => parent.title, :project_id => parent.project, :version => nil})
|
link_to(h(parent.pretty_title), {:controller => 'wiki', :action => 'show', :id => parent.title, :project_id => parent.project, :version => nil})
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def wiki_content_format wiki
|
||||||
|
text = wiki.text.html_safe
|
||||||
|
text = parse_non_pre_blocks(text, wiki, text) do |text|
|
||||||
|
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name|
|
||||||
|
send method_name, text, project, wiki, attr, only_path, options
|
||||||
|
end
|
||||||
|
end
|
||||||
|
text
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -161,8 +161,8 @@
|
||||||
|
|
||||||
<td class="comments">
|
<td class="comments">
|
||||||
<div class="wiki">
|
<div class="wiki">
|
||||||
<%#= textilizable message,:content,:attachments => message.attachments %>
|
<%= textAreailizable message,:content,:attachments => message.attachments %>
|
||||||
<%= message.content.html_safe %>
|
<%#= message.content.html_safe %>
|
||||||
</div>
|
</div>
|
||||||
<%= link_to_attachments message, :author => false %> </td>
|
<%= link_to_attachments message, :author => false %> </td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="wiki wiki-page">
|
<div class="wiki wiki-page">
|
||||||
<%= textilizable content, :text, :attachments => content.page.attachments,
|
<%= textAreailizable content, :text, :attachments => content.page.attachments,
|
||||||
:edit_section_links => (@sections_editable && {:controller => 'wiki', :action => 'edit', :project_id => @page.project, :id => @page.title}) %>
|
:edit_section_links => (@sections_editable && {:controller => 'wiki', :action => 'edit', :project_id => @page.project, :id => @page.title}) %>
|
||||||
<%#= content.text.html_safe %>
|
<%#= content.text.html_safe %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140812032957) do
|
ActiveRecord::Schema.define(:version => 20140812065417) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -304,8 +304,9 @@ ActiveRecord::Schema.define(:version => 20140812032957) do
|
||||||
t.string "disk_directory"
|
t.string "disk_directory"
|
||||||
t.integer "attachtype"
|
t.integer "attachtype"
|
||||||
t.integer "is_public"
|
t.integer "is_public"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
|
t.integer "container_id", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "course_infos", :force => true do |t|
|
create_table "course_infos", :force => true do |t|
|
||||||
|
|
Loading…
Reference in New Issue