Don't load redcarpet with JRuby.

git-svn-id: http://svn.redmine.org/redmine/trunk@12453 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2013-12-23 17:07:51 +00:00
parent 471e01ca50
commit a657a12450
4 changed files with 21 additions and 5 deletions

10
Gemfile
View File

@ -5,8 +5,6 @@ gem "jquery-rails", "~> 2.0.2"
gem "coderay", "~> 1.1.0" gem "coderay", "~> 1.1.0"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0" gem "builder", "3.0.0"
# TODO: upgrade to redcarpet 3.x when ruby1.8 support is dropped
gem "redcarpet", "~> 2.3.0"
# Optional gem for LDAP authentication # Optional gem for LDAP authentication
group :ldap do group :ldap do
@ -19,14 +17,20 @@ group :openid do
gem "rack-openid" gem "rack-openid"
end end
# Optional gem for exporting the gantt to a PNG file, not supported with jruby
platforms :mri, :mingw do platforms :mri, :mingw do
# Optional gem for exporting the gantt to a PNG file, not supported with jruby
group :rmagick do group :rmagick do
# RMagick 2 supports ruby 1.9 # RMagick 2 supports ruby 1.9
# RMagick 1 would be fine for ruby 1.8 but Bundler does not support # RMagick 1 would be fine for ruby 1.8 but Bundler does not support
# different requirements for the same gem on different platforms # different requirements for the same gem on different platforms
gem "rmagick", ">= 2.0.0" gem "rmagick", ">= 2.0.0"
end end
# Optional Markdown support, not for JRuby
group :markdown do
# TODO: upgrade to redcarpet 3.x when ruby1.8 support is dropped
gem "redcarpet", "~> 2.3.0"
end
end end
platforms :jruby do platforms :jruby do

View File

@ -22,6 +22,11 @@ begin
rescue LoadError rescue LoadError
# RMagick is not available # RMagick is not available
end end
begin
require 'Redcarpet' unless Object.const_defined?(:Redcarpet)
rescue LoadError
# Redcarpet is not available
end
require 'redmine/scm/base' require 'redmine/scm/base'
require 'redmine/access_control' require 'redmine/access_control'
@ -267,8 +272,10 @@ end
Redmine::WikiFormatting.map do |format| Redmine::WikiFormatting.map do |format|
format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper
format.register :markdown, Redmine::WikiFormatting::Markdown::Formatter, Redmine::WikiFormatting::Markdown::Helper, if Object.const_defined?(:Redcarpet)
:label => 'Markdown (experimental)' format.register :markdown, Redmine::WikiFormatting::Markdown::Formatter, Redmine::WikiFormatting::Markdown::Helper,
:label => 'Markdown (experimental)'
end
end end
ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler

View File

@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'cgi' require 'cgi'
require 'redmine/scm/adapters'
if RUBY_VERSION < '1.9' if RUBY_VERSION < '1.9'
require 'iconv' require 'iconv'

View File

@ -20,6 +20,8 @@ require File.expand_path('../../../../../test_helper', __FILE__)
class Redmine::WikiFormatting::MarkdownFormatterTest < ActionView::TestCase class Redmine::WikiFormatting::MarkdownFormatterTest < ActionView::TestCase
include ApplicationHelper include ApplicationHelper
if Object.const_defined?(:Redcarpet)
def setup def setup
@formatter = Redmine::WikiFormatting::Markdown::Formatter @formatter = Redmine::WikiFormatting::Markdown::Formatter
end end
@ -59,4 +61,6 @@ STR
text = 'This is a [link](/issues)' text = 'This is a [link](/issues)'
assert_equal '<p>This is a <a href="/issues">link</a></p>', @formatter.new(text).to_html.strip assert_equal '<p>This is a <a href="/issues">link</a></p>', @formatter.new(text).to_html.strip
end end
end
end end