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