diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 1e65f6b59..2842774ec 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -15,8 +15,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-require 'rake'
-require 'rails/info'
class AdminController < ApplicationController
layout 'admin'
@@ -77,55 +75,9 @@ class AdminController < ApplicationController
end
def info
- @checklist = [
- [:text_default_administrator_account_changed, User.find(:first, :conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?],
- [:text_file_repository_writable, File.writable?(Attachment.storage_path)],
- [:text_plugin_assets_writable, File.writable?(Engines.public_directory)],
- [:text_rmagick_available, Object.const_defined?(:Magick)]
- ]
-
- app_servers = {
- 'Mongrel' => {:name => 'Mongrel', :version => Proc.new{Mongrel::Const::MONGREL_VERSION}},
- 'Thin' => {:name => 'Thin', :version => Proc.new{Thin::VERSION::STRING}},
- 'Unicorn' => {:name => 'Unicorn', :version => Proc.new{Unicorn::Const::UNICORN_VERSION}},
- 'PhusionPassenger' => {:name => 'Phusion Passenger', :version => Proc.new{PhusionPassenger::VERSION_STRING}},
- 'RailsFCGIHandler' => {:name => 'FastCGI'}
- # TOOD: find a way to test for CGI
- }
- app_server = (Object.constants & app_servers.keys).collect do |server|
- name = app_servers[server][:name].underscore.humanize
- version = app_servers[server][:version].call if app_servers[server][:version]
- [name, version].compact.join(" ")
- end.join(",")
- app_server = l(:label_unknown) unless app_server.present?
-
- # Find database connection encoding
- encoding = case ActiveRecord::Base.connection.adapter_name
- when 'Mysql'
- ActiveRecord::Base.connection.show_variable('character_set%')
- when 'PostgreSQL'
- ActiveRecord::Base.connection.encoding
- when 'SQLite'
- # works like ActiveRecord::ConnectionAdapters::SQLite3Adapter.encoding
- # of the Rails3 Sqlite3 adapter
- if ActiveRecord::Base.connection.respond_to?(:encoding)
- ActiveRecord::Base.connection.encoding[0]['encoding']
- else
- result = ActiveRecord::Base.connection.select_all("PRAGMA 'encoding'")
- result.present? ? result.first['encoding'] : nil
- end
- end || l(:label_unknown)
-
- @infolist = Rails::Info.properties.dup
- @infolist.insert(3, ['Rake version', RAKEVERSION])
- @infolist.insert(11, [:text_log_file, Rails.configuration.log_path])
- @infolist.insert(13, [:text_database_encoding, encoding])
-
- @infolist += [
- [:text_app_server, app_server],
- [:text_redmine_username, Etc.getlogin]
- ]
-
- @pluginlist = Redmine::Plugin.all
+ environment = Redmine::About.environment
+ environment.each_pair do |key, value|
+ instance_variable_set("@env_#{key.to_s}", value)
+ end
end
end
diff --git a/app/views/admin/info.rhtml b/app/views/admin/info.rhtml
index 5bad6b16d..0b414de22 100644
--- a/app/views/admin/info.rhtml
+++ b/app/views/admin/info.rhtml
@@ -3,7 +3,7 @@
<%= Redmine::Info.versioned_name %>
-<% @checklist.each do |label, result| %>
+<% @env_checklist.each do |label, result| %>
| <%= l(label) %> |
<%= image_tag((result ? 'true.png' : 'exclamation.png'), :style => "vertical-align:bottom;") %> |
@@ -13,7 +13,7 @@
<%=l(:label_environment)%>
-<% @infolist.each do |label, info| %>
+<% @env_rails.each do |label, info| %>
| <%= label.is_a?(Symbol) ? l(label) : h(label) %> |
<%= h(info) %> |
@@ -22,9 +22,9 @@
-<% if @pluginlist.any? %>
+<% if @env_plugins.any? %>
<%= l(:label_plugins) %>
-<%= render :partial => 'admin/plugins', :locals => {:plugins => @pluginlist} %>
+<%= render :partial => 'admin/plugins', :locals => {:plugins => @env_plugins} %>
<% end %>
<% html_title(l(:label_information_plural)) -%>
diff --git a/lib/redmine/about.rb b/lib/redmine/about.rb
index 0fcc29a97..b65f67f19 100644
--- a/lib/redmine/about.rb
+++ b/lib/redmine/about.rb
@@ -1,15 +1,101 @@
+require 'rake'
+require 'rails/info'
+
module Redmine
class About
- def self.print_plugin_info
- plugins = Redmine::Plugin.registered_plugins
+ include Redmine::I18n
+
+ class << self
+ def to_s
+ print_plugin_info
+ end
+
+ def print(header, properties, column_width)
+ ["\n", header, '-' * header.length, *properties.map do |property|
+ "%-#{column_width}s %s" % property
+ end] * "\n"
+ end
+
+ def print_plugin_info
+ environment = self.environment
- if !plugins.empty?
- column_with = plugins.map {|internal_name, plugin| plugin.name.length}.max
- puts "\nAbout your Redmine plugins"
+ output = "About your Redmine's environment\n"
+ output << "================================"
- plugins.each do |internal_name, plugin|
- puts sprintf("%-#{column_with}s %s", plugin.name, plugin.version)
+ checklist = environment[:checklist].collect {|label, value| [l(label), value ? "Yes" : "No"]}
+ info = environment[:rails].collect {|label, value| [(label.is_a?(Symbol) ? l(label) : label), value]}
+ plugins = environment[:plugins].collect {|plugin| [plugin.name, plugin.version] }
+
+ # get overall width of label column
+ column_width = [
+ checklist.collect {|label, value| label.length }.max,
+ info.collect {|label, value| label.length }.max,
+ plugins.collect {|label, value| label.length }.max
+ ].max
+
+ output += print("Checklist", checklist, column_width)
+ output += print("Rails info", info, column_width)
+ output += print("Plugins", plugins, column_width)
+
+ output
+ end
+
+ def environment
+ environment = {}
+ environment[:checklist] = [
+ [:text_default_administrator_account_changed, User.find(:first, :conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?],
+ [:text_file_repository_writable, File.writable?(Attachment.storage_path)],
+ [:text_plugin_assets_writable, File.writable?(Engines.public_directory)],
+ [:text_rmagick_available, Object.const_defined?(:Magick)]
+ ]
+
+ app_servers = {
+ 'Mongrel' => {:name => 'Mongrel', :version => Proc.new{Mongrel::Const::MONGREL_VERSION}},
+ 'Thin' => {:name => 'Thin', :version => Proc.new{Thin::VERSION::STRING}},
+ 'Unicorn' => {:name => 'Unicorn', :version => Proc.new{Unicorn::Const::UNICORN_VERSION}},
+ 'PhusionPassenger' => {:name => 'Phusion Passenger', :version => Proc.new{PhusionPassenger::VERSION_STRING}},
+ 'RailsFCGIHandler' => {:name => 'FastCGI'}
+ # TOOD: find a way to test for CGI
+ }
+ app_server = (Object.constants & app_servers.keys).collect do |server|
+ name = app_servers[server][:name].underscore.humanize
+ version = app_servers[server][:version].call if app_servers[server][:version]
+ [name, version].compact.join(" ")
+ end.join(",")
+ app_server = l(:label_unknown) unless app_server.present?
+
+ # Find database connection encoding
+ encoding = case ActiveRecord::Base.connection.adapter_name
+ when 'Mysql'
+ ActiveRecord::Base.connection.show_variable('character_set%')
+ when 'PostgreSQL'
+ ActiveRecord::Base.connection.encoding
+ when 'SQLite'
+ # works like ActiveRecord::ConnectionAdapters::SQLite3Adapter.encoding
+ # of the Rails3 Sqlite3 adapter
+ if ActiveRecord::Base.connection.respond_to?(:encoding)
+ ActiveRecord::Base.connection.encoding[0]['encoding']
+ else
+ result = ActiveRecord::Base.connection.select_all("PRAGMA 'encoding'")
+ result.present? ? result.first['encoding'] : nil
+ end
+ end || l(:label_unknown)
+
+ environment[:rails] = Rails::Info.properties.dup
+ environment[:rails].tap do |info|
+ info.insert(3, ['Rake version', RAKEVERSION])
+ info.insert(11, [:text_log_file, Rails.configuration.log_path])
+ info.insert(13, [:text_database_encoding, encoding])
end
+
+ environment[:rails] += [
+ [:text_app_server, app_server],
+ [:text_redmine_username, Etc.getlogin]
+ ]
+
+ environment[:plugins] = Redmine::Plugin.all
+
+ environment
end
end
end
diff --git a/script/about b/script/about
index 00ae734e3..ee888b864 100755
--- a/script/about
+++ b/script/about
@@ -1,6 +1,5 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
-$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
-require 'commands/about'
+require "#{RAILS_ROOT}/config/environment"
-Redmine::About.print_plugin_info
+puts Redmine::About
\ No newline at end of file