mirror of
https://github.com/meineerde/redmine.git
synced 2026-03-11 03:33:07 +00:00
Move info code to Redmine::About and add additonal outout to script/about
This commit is contained in:
parent
d3ade19fd1
commit
82807c0250
@ -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
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<p><strong><%= Redmine::Info.versioned_name %></strong></p>
|
||||
|
||||
<table class="list">
|
||||
<% @checklist.each do |label, result| %>
|
||||
<% @env_checklist.each do |label, result| %>
|
||||
<tr class="<%= cycle 'odd', 'even' %>">
|
||||
<td><%= l(label) %></td>
|
||||
<td width="30px"><%= image_tag((result ? 'true.png' : 'exclamation.png'), :style => "vertical-align:bottom;") %></td>
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
<h3><%=l(:label_environment)%></h3>
|
||||
<table class="list">
|
||||
<% @infolist.each do |label, info| %>
|
||||
<% @env_rails.each do |label, info| %>
|
||||
<tr class="<%= cycle 'odd', 'even' %>">
|
||||
<td><%= label.is_a?(Symbol) ? l(label) : h(label) %></td>
|
||||
<td><%= h(info) %></td>
|
||||
@ -22,9 +22,9 @@
|
||||
</table>
|
||||
|
||||
|
||||
<% if @pluginlist.any? %>
|
||||
<% if @env_plugins.any? %>
|
||||
<h3><%= l(:label_plugins) %></h3>
|
||||
<%= render :partial => 'admin/plugins', :locals => {:plugins => @pluginlist} %>
|
||||
<%= render :partial => 'admin/plugins', :locals => {:plugins => @env_plugins} %>
|
||||
<% end %>
|
||||
|
||||
<% html_title(l(:label_information_plural)) -%>
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user