@@ -1,117 +1,118 | |||||
1 | source 'https://rubygems.org' |
|
1 | source 'https://rubygems.org' | |
2 |
|
2 | |||
3 | if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.5.0') |
|
3 | if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.5.0') | |
4 | abort "Redmine requires Bundler 1.5.0 or higher (you're using #{Bundler::VERSION}).\nPlease update with 'gem update bundler'." |
|
4 | abort "Redmine requires Bundler 1.5.0 or higher (you're using #{Bundler::VERSION}).\nPlease update with 'gem update bundler'." | |
5 | end |
|
5 | end | |
6 |
|
6 | |||
7 | gem "rails", "4.2.6" |
|
7 | gem "rails", "4.2.6" | |
8 | gem "jquery-rails", "~> 3.1.4" |
|
8 | gem "jquery-rails", "~> 3.1.4" | |
9 | gem "coderay", "~> 1.1.0" |
|
9 | gem "coderay", "~> 1.1.0" | |
10 | gem "builder", ">= 3.0.4" |
|
10 | gem "builder", ">= 3.0.4" | |
11 | gem "request_store", "1.0.5" |
|
11 | gem "request_store", "1.0.5" | |
12 | gem "mime-types", (RUBY_VERSION >= "2.0" ? "~> 3.0" : "~> 2.99") |
|
12 | gem "mime-types", (RUBY_VERSION >= "2.0" ? "~> 3.0" : "~> 2.99") | |
13 | gem "protected_attributes" |
|
13 | gem "protected_attributes" | |
14 | gem "actionpack-action_caching" |
|
14 | gem "actionpack-action_caching" | |
15 | gem "actionpack-xml_parser" |
|
15 | gem "actionpack-xml_parser" | |
16 | gem "roadie-rails" |
|
16 | gem "roadie-rails" | |
|
17 | gem "mimemagic" | |||
17 |
|
18 | |||
18 | # Request at least nokogiri 1.6.7.2 because of security advisories |
|
19 | # Request at least nokogiri 1.6.7.2 because of security advisories | |
19 | gem "nokogiri", ">= 1.6.7.2" |
|
20 | gem "nokogiri", ">= 1.6.7.2" | |
20 |
|
21 | |||
21 | # Request at least rails-html-sanitizer 1.0.3 because of security advisories |
|
22 | # Request at least rails-html-sanitizer 1.0.3 because of security advisories | |
22 | gem "rails-html-sanitizer", ">= 1.0.3" |
|
23 | gem "rails-html-sanitizer", ">= 1.0.3" | |
23 |
|
24 | |||
24 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem |
|
25 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem | |
25 | gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin, :jruby] |
|
26 | gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin, :jruby] | |
26 | gem "rbpdf", "~> 1.19.0" |
|
27 | gem "rbpdf", "~> 1.19.0" | |
27 |
|
28 | |||
28 | # Optional gem for LDAP authentication |
|
29 | # Optional gem for LDAP authentication | |
29 | group :ldap do |
|
30 | group :ldap do | |
30 | gem "net-ldap", "~> 0.12.0" |
|
31 | gem "net-ldap", "~> 0.12.0" | |
31 | end |
|
32 | end | |
32 |
|
33 | |||
33 | # Optional gem for OpenID authentication |
|
34 | # Optional gem for OpenID authentication | |
34 | group :openid do |
|
35 | group :openid do | |
35 | gem "ruby-openid", "~> 2.3.0", :require => "openid" |
|
36 | gem "ruby-openid", "~> 2.3.0", :require => "openid" | |
36 | gem "rack-openid" |
|
37 | gem "rack-openid" | |
37 | end |
|
38 | end | |
38 |
|
39 | |||
39 | platforms :mri, :mingw, :x64_mingw do |
|
40 | platforms :mri, :mingw, :x64_mingw do | |
40 | # Optional gem for exporting the gantt to a PNG file, not supported with jruby |
|
41 | # Optional gem for exporting the gantt to a PNG file, not supported with jruby | |
41 | group :rmagick do |
|
42 | group :rmagick do | |
42 | gem "rmagick", ">= 2.14.0" |
|
43 | gem "rmagick", ">= 2.14.0" | |
43 | end |
|
44 | end | |
44 |
|
45 | |||
45 | # Optional Markdown support, not for JRuby |
|
46 | # Optional Markdown support, not for JRuby | |
46 | group :markdown do |
|
47 | group :markdown do | |
47 | gem "redcarpet", "~> 3.3.2" |
|
48 | gem "redcarpet", "~> 3.3.2" | |
48 | end |
|
49 | end | |
49 | end |
|
50 | end | |
50 |
|
51 | |||
51 | platforms :jruby do |
|
52 | platforms :jruby do | |
52 | # jruby-openssl is bundled with JRuby 1.7.0 |
|
53 | # jruby-openssl is bundled with JRuby 1.7.0 | |
53 | gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0' |
|
54 | gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0' | |
54 | gem "activerecord-jdbc-adapter", "~> 1.3.2" |
|
55 | gem "activerecord-jdbc-adapter", "~> 1.3.2" | |
55 | end |
|
56 | end | |
56 |
|
57 | |||
57 | # Include database gems for the adapters found in the database |
|
58 | # Include database gems for the adapters found in the database | |
58 | # configuration file |
|
59 | # configuration file | |
59 | require 'erb' |
|
60 | require 'erb' | |
60 | require 'yaml' |
|
61 | require 'yaml' | |
61 | database_file = File.join(File.dirname(__FILE__), "config/database.yml") |
|
62 | database_file = File.join(File.dirname(__FILE__), "config/database.yml") | |
62 | if File.exist?(database_file) |
|
63 | if File.exist?(database_file) | |
63 | database_config = YAML::load(ERB.new(IO.read(database_file)).result) |
|
64 | database_config = YAML::load(ERB.new(IO.read(database_file)).result) | |
64 | adapters = database_config.values.map {|c| c['adapter']}.compact.uniq |
|
65 | adapters = database_config.values.map {|c| c['adapter']}.compact.uniq | |
65 | if adapters.any? |
|
66 | if adapters.any? | |
66 | adapters.each do |adapter| |
|
67 | adapters.each do |adapter| | |
67 | case adapter |
|
68 | case adapter | |
68 | when 'mysql2' |
|
69 | when 'mysql2' | |
69 | gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw, :x64_mingw] |
|
70 | gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw, :x64_mingw] | |
70 | gem "activerecord-jdbcmysql-adapter", :platforms => :jruby |
|
71 | gem "activerecord-jdbcmysql-adapter", :platforms => :jruby | |
71 | when 'mysql' |
|
72 | when 'mysql' | |
72 | gem "activerecord-jdbcmysql-adapter", :platforms => :jruby |
|
73 | gem "activerecord-jdbcmysql-adapter", :platforms => :jruby | |
73 | when /postgresql/ |
|
74 | when /postgresql/ | |
74 | gem "pg", "~> 0.18.1", :platforms => [:mri, :mingw, :x64_mingw] |
|
75 | gem "pg", "~> 0.18.1", :platforms => [:mri, :mingw, :x64_mingw] | |
75 | gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby |
|
76 | gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby | |
76 | when /sqlite3/ |
|
77 | when /sqlite3/ | |
77 | gem "sqlite3", :platforms => [:mri, :mingw, :x64_mingw] |
|
78 | gem "sqlite3", :platforms => [:mri, :mingw, :x64_mingw] | |
78 | gem "jdbc-sqlite3", ">= 3.8.10.1", :platforms => :jruby |
|
79 | gem "jdbc-sqlite3", ">= 3.8.10.1", :platforms => :jruby | |
79 | gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby |
|
80 | gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby | |
80 | when /sqlserver/ |
|
81 | when /sqlserver/ | |
81 | gem "tiny_tds", "~> 0.6.2", :platforms => [:mri, :mingw, :x64_mingw] |
|
82 | gem "tiny_tds", "~> 0.6.2", :platforms => [:mri, :mingw, :x64_mingw] | |
82 | gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw, :x64_mingw] |
|
83 | gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw, :x64_mingw] | |
83 | else |
|
84 | else | |
84 | warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems") |
|
85 | warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems") | |
85 | end |
|
86 | end | |
86 | end |
|
87 | end | |
87 | else |
|
88 | else | |
88 | warn("No adapter found in config/database.yml, please configure it first") |
|
89 | warn("No adapter found in config/database.yml, please configure it first") | |
89 | end |
|
90 | end | |
90 | else |
|
91 | else | |
91 | warn("Please configure your config/database.yml first") |
|
92 | warn("Please configure your config/database.yml first") | |
92 | end |
|
93 | end | |
93 |
|
94 | |||
94 | group :development do |
|
95 | group :development do | |
95 | gem "rdoc", ">= 2.4.2" |
|
96 | gem "rdoc", ">= 2.4.2" | |
96 | gem "yard" |
|
97 | gem "yard" | |
97 | end |
|
98 | end | |
98 |
|
99 | |||
99 | group :test do |
|
100 | group :test do | |
100 | gem "minitest" |
|
101 | gem "minitest" | |
101 | gem "rails-dom-testing" |
|
102 | gem "rails-dom-testing" | |
102 | gem "mocha" |
|
103 | gem "mocha" | |
103 | gem "simplecov", "~> 0.9.1", :require => false |
|
104 | gem "simplecov", "~> 0.9.1", :require => false | |
104 | # For running UI tests |
|
105 | # For running UI tests | |
105 | gem "capybara" |
|
106 | gem "capybara" | |
106 | gem "selenium-webdriver" |
|
107 | gem "selenium-webdriver" | |
107 | end |
|
108 | end | |
108 |
|
109 | |||
109 | local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local") |
|
110 | local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local") | |
110 | if File.exists?(local_gemfile) |
|
111 | if File.exists?(local_gemfile) | |
111 | eval_gemfile local_gemfile |
|
112 | eval_gemfile local_gemfile | |
112 | end |
|
113 | end | |
113 |
|
114 | |||
114 | # Load plugins' Gemfiles |
|
115 | # Load plugins' Gemfiles | |
115 | Dir.glob File.expand_path("../plugins/*/{Gemfile,PluginGemfile}", __FILE__) do |file| |
|
116 | Dir.glob File.expand_path("../plugins/*/{Gemfile,PluginGemfile}", __FILE__) do |file| | |
116 | eval_gemfile file |
|
117 | eval_gemfile file | |
117 | end |
|
118 | end |
@@ -1,55 +1,60 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require 'fileutils' |
|
18 | require 'fileutils' | |
|
19 | require 'mimemagic' | |||
19 |
|
20 | |||
20 | module Redmine |
|
21 | module Redmine | |
21 | module Thumbnail |
|
22 | module Thumbnail | |
22 | extend Redmine::Utils::Shell |
|
23 | extend Redmine::Utils::Shell | |
23 |
|
24 | |||
24 | CONVERT_BIN = (Redmine::Configuration['imagemagick_convert_command'] || 'convert').freeze |
|
25 | CONVERT_BIN = (Redmine::Configuration['imagemagick_convert_command'] || 'convert').freeze | |
25 |
|
26 | |||
26 | # Generates a thumbnail for the source image to target |
|
27 | # Generates a thumbnail for the source image to target | |
27 | def self.generate(source, target, size) |
|
28 | def self.generate(source, target, size) | |
28 | return nil unless convert_available? |
|
29 | return nil unless convert_available? | |
29 | unless File.exists?(target) |
|
30 | unless File.exists?(target) | |
|
31 | # Make sure we only invoke Imagemagick if this is actually an image | |||
|
32 | unless File.open(source) {|f| MimeMagic.by_magic(f).try(:image?)} | |||
|
33 | return nil | |||
|
34 | end | |||
30 | directory = File.dirname(target) |
|
35 | directory = File.dirname(target) | |
31 | unless File.exists?(directory) |
|
36 | unless File.exists?(directory) | |
32 | FileUtils.mkdir_p directory |
|
37 | FileUtils.mkdir_p directory | |
33 | end |
|
38 | end | |
34 | size_option = "#{size}x#{size}>" |
|
39 | size_option = "#{size}x#{size}>" | |
35 | cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -thumbnail #{shell_quote size_option} #{shell_quote target}" |
|
40 | cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -thumbnail #{shell_quote size_option} #{shell_quote target}" | |
36 | unless system(cmd) |
|
41 | unless system(cmd) | |
37 | logger.error("Creating thumbnail failed (#{$?}):\nCommand: #{cmd}") |
|
42 | logger.error("Creating thumbnail failed (#{$?}):\nCommand: #{cmd}") | |
38 | return nil |
|
43 | return nil | |
39 | end |
|
44 | end | |
40 | end |
|
45 | end | |
41 | target |
|
46 | target | |
42 | end |
|
47 | end | |
43 |
|
48 | |||
44 | def self.convert_available? |
|
49 | def self.convert_available? | |
45 | return @convert_available if defined?(@convert_available) |
|
50 | return @convert_available if defined?(@convert_available) | |
46 | @convert_available = system("#{shell_quote CONVERT_BIN} -version") rescue false |
|
51 | @convert_available = system("#{shell_quote CONVERT_BIN} -version") rescue false | |
47 | logger.warn("Imagemagick's convert binary (#{CONVERT_BIN}) not available") unless @convert_available |
|
52 | logger.warn("Imagemagick's convert binary (#{CONVERT_BIN}) not available") unless @convert_available | |
48 | @convert_available |
|
53 | @convert_available | |
49 | end |
|
54 | end | |
50 |
|
55 | |||
51 | def self.logger |
|
56 | def self.logger | |
52 | Rails.logger |
|
57 | Rails.logger | |
53 | end |
|
58 | end | |
54 | end |
|
59 | end | |
55 | end |
|
60 | end |
General Comments 0
You need to be logged in to leave comments.
Login now