gem list可以查看redmine安装版本信息(本机安装环境rails 2.3.11,redmine-1.2.0)
redmine集成ckeditor
redmine安装CKEDITOR出错(undefined method 'reply' for class 'IssuesController')
解决办法:
下载redmine_ckeditor(https://github.com/a-ono/redmine_ckeditor)
解压文件,修改文件夹名称为redmine_ckeditor
进入redmine_ckeditor/lib,将issues_controller_patch.rb文件重名为journals_controller_patch.rb
采用文本编辑器打开journals_controller_patch.rb,修改文件内容为:
require_dependency 'journals_controller'
module RedmineCkeditor
module JournalsControllerPatch
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
alias_method_chain :new, :ckeditor
end
end
module InstanceMethods
def new_with_ckeditor
unless Setting.text_formatting == "CKEditor"
reply_without_ckeditor
return
end
journal = Journal.find(params[:journal_id]) if params[:journal_id]
if journal
user = journal.user
text = journal.notes
else
user = @issue.author
text = @issue.description
end
content = "<p>#{ll(Setting.default_language, :text_user_wrote, user)}</p>"
content << "<blockquote>#{ActionView::Base.full_sanitizer.sanitize(text)}</blockquote><p/>"
render(:update) {|page|
page.<< "CKEDITOR.instances['notes'].setData(#{content.inspect});"
page << "showAndScrollTo('update', 'notes');"
}
end
end
end
end
修改redmine_ckeditor/lib/redmine_ckeditor.rb,文件内容为
require 'redmine_ckeditor/journals_controller_patch'
require 'redmine_ckeditor/toolbar_helper'
module RedmineCkeditor
include ToolbarHelper
PLUGIN_DIR = File.expand_path(File.dirname(File.dirname(__FILE__)))
ALLOWED_TAGS = %w[
a abbr acronym address blockquote b big br caption cite code dd del dfn
div dt em h1 h2 h3 h4 h5 h6 hr i img ins kbd li ol p pre samp small span
strike strong sub sup table tbody td tfoot th thead tr tt u ul var
]
ALLOWED_ATTRIBUTES = %w[
href src width height alt cite datetime title class name xml:lang abbr
style align valign border cellpadding cellspacing colspan rowspan nowrap
]
DEFAULT_TOOLBAR = [
%w[Source - Preview - Maximize ShowBlocks - Template - PasteFromWord -
Undo Redo - Find Replace
], '/',
%w[Bold Italic Underline Strike - Subscript Superscript -
NumberedList BulletedList - Outdent Indent Blockquote -
JustifyLeft JustifyCenter JustifyRight JustifyBlock -
Link Unlink Anchor - Image Table HorizontalRule SpecialChar
], '/',
%w[Styles Format Font FontSize - TextColor BGColor]
]
def self.apply_patch
JournalsController.send(:include, JournalsControllerPatch)
end
end
安装
拷贝redmine_ckeditor到vendor/plugins目录下
启动Redmine
管理员登陆redmine,进入管理-->配置-->文本格式,选择CKEDITOR
修改CKEDITOR配置可以进入 管理-->插件--配置
https://github.com/a-ono/redmine_ckeditor/issues/2#issuecomment-384929