gist and system info support have been added

This commit is contained in:
Alexander Meindl 2015-10-20 14:20:23 +02:00
parent 3e12e904b3
commit 7939fe9eaa
11 changed files with 99 additions and 37 deletions

View File

@ -109,6 +109,11 @@ Note: Redmine must be restarted after changing "Custom Help URL"</tt> value befo
## Changelog
### 0.5.6
- system information uptime and uname have been added
- gist macro support
### 0.5.5
- dependency with deface (used to overview views)

View File

@ -0,0 +1,5 @@
Deface::Override.new virtual_path: 'admin/info',
name: 'add-system_info',
insert_after: 'table.list',
original: '2de504b0ea475c3c109480136e6bb2b83368acc2',
partial: 'admin/system_info'

View File

@ -0,0 +1,8 @@
<table class="list">
<tr class="<%= cycle 'odd', 'even' %>">
<td class="name"><%= l(:label_system_info) %>:</td><td class="name"><%= system_info %></td>
</tr>
<tr class="<%= cycle 'odd', 'even' %>">
<td class="name"><%= l(:label_uptime) %>:</td><td class="name"><%= system_uptime %></td>
</tr>
</table>

View File

@ -1,6 +1,6 @@
<%
if @users_by_role.any?
view_roles = get_memberbox_view_roles
view_roles = memberbox_view_roles
if view_roles.count>0
%>
<div class="members box">

View File

@ -64,6 +64,9 @@ de:
rule_issue_status_change_info: "Use Case: Zur Abnahme der Tickets sollen alle Tickets automatisch dem Ersteller des Tickets zugeordnet werden, sofern kein anderer Benutzer ausgewählt wird."
label_rule_issue_current_user_status: "Der Ticketstatus x ist nur erlaubt, wenn \"Zugewiesen an\" der aktuelle Benutzer zugewiesen wird."
rule_issue_current_user_status_info: "Use Case: Ein Benutzer soll nur den Status auf \"In Progress\" selbst stellen können, um damit anzuzeigen, dass er an dem Ticket (gerade) arbeitet."
days: Tage
label_system_info: Systeminformation
label_uptime: Betriebszeit
activerecord:
errors:
messages:

View File

@ -64,6 +64,9 @@ en:
rule_issue_status_change_info: "Use Case: issues should be automatically assigned to autor, if the status changes to \"Approval\"."
label_rule_issue_current_user_status: "Current issue status x is only allowed if \"Assignee\" is the current user."
rule_issue_current_user_status_info: "Use Case: Users are only allowed to change the status to \"In Progress\" if they are the person who is actually working on the issue right now."
days: days
label_system_info: System info
label_uptime: Uptime
activerecord:
errors:
messages:

View File

@ -17,6 +17,7 @@ if ActiveRecord::Base.connection.table_exists?(:settings)
require 'redmine_tweaks/patches/issue_patch'
require 'redmine_tweaks/patches/wiki_patch'
require 'redmine_tweaks/patches/wiki_controller_patch'
require 'redmine_tweaks/wiki_macros/gist'
require 'redmine_tweaks/wiki_macros/project_macros'
require 'redmine_tweaks/wiki_macros/user_macros'
require 'redmine_tweaks/wiki_macros/date_macros'

View File

@ -4,7 +4,27 @@
# Redmine Tweak helper functions
module RedmineTweaks
module Helper
def get_memberbox_view_roles
def system_uptime
if windows_platform?
`net stats srv | find "Statist"`
else
"#{`uptime | awk '{print $3}'`} #{l(:days)}"
end
end
def system_info
if windows_platform?
'unknown'
else
`uname -a`
end
end
def windows_platform?
true if /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
end
def memberbox_view_roles
view_roles = []
@users_by_role.keys.sort.each do |role|
if !role.permissions.include?(:hide_in_memberbox) ||

View File

@ -26,7 +26,7 @@ module RedmineTweaks
when 3 then file = RedmineTweaks.get_garfield(Date.parse(args[2] + '-' + args[1] + '-' + args[0]))
when 0 then file = RedmineTweaks.get_garfield(Time.zone.today)
else
out = '<pre>Error in garfield macro. The correct usage is {{garfield([&lt;yyyy&gt;,&lt;mm&gt;,&lt;dd&gt;])}}.</pre>'
return '<pre>Error in garfield macro. The correct usage is {{garfield([&lt;yyyy&gt;,&lt;mm&gt;,&lt;dd&gt;])}}.</pre>'
end
image = url_for(controller: 'garfield', action: 'show', name: file[:name], type: file[:type])

View File

@ -0,0 +1,15 @@
# Redmine Tweaks plugin for Redmine
# Copyright (C) 2013-2015 AlphaNodes GmbH
# Gist wiki macros
module RedmineTweaks
module WikiMacros
Redmine::WikiFormatting::Macros.register do
desc 'gist embed'
# Register gist macro
macro :gist do |_obj, args|
javascript_tag(nil, src: "https://gist.github.com/#{args[0]}.js") unless args.empty?
end
end
end
end

View File

@ -3,44 +3,46 @@
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
# Redmine Tweaks helper class for tests
class RedmineTweaks::TestCase
include ActionDispatch::TestProcess
def self.plugin_fixtures(plugin, *fixture_names)
plugin_fixture_path = "#{Redmine::Plugin.find(plugin).directory}/test/fixtures"
if fixture_names.first == :all
fixture_names = Dir["#{plugin_fixture_path}/**/*.{yml}"]
fixture_names.map! { |f| f[(plugin_fixture_path.size + 1)..-5] }
else
fixture_names = fixture_names.flatten.map { |n| n.to_s }
module RedmineTweaks
class TestCase
include ActionDispatch::TestProcess
def self.plugin_fixtures(plugin, *fixture_names)
plugin_fixture_path = "#{Redmine::Plugin.find(plugin).directory}/test/fixtures"
if fixture_names.first == :all
fixture_names = Dir["#{plugin_fixture_path}/**/*.{yml}"]
fixture_names.map! { |f| f[(plugin_fixture_path.size + 1)..-5] }
else
fixture_names = fixture_names.flatten.map(&:to_s)
end
ActiveRecord::Fixtures.create_fixtures(plugin_fixture_path, fixture_names)
end
ActiveRecord::Fixtures.create_fixtures(plugin_fixture_path, fixture_names)
end
def uploaded_test_file(name, mime)
ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime, true)
end
def self.arrays_equal?(a1, a2)
(a1 - a2) - (a2 - a1) == []
end
def self.create_fixtures(fixtures_directory, table_names, _class_names = {})
if ActiveRecord::VERSION::MAJOR >= 4
ActiveRecord::FixtureSet.create_fixtures(fixtures_directory, table_names, _class_names = {})
else
ActiveRecord::Fixtures.create_fixtures(fixtures_directory, table_names, _class_names = {})
end
end
def self.prepare
Role.where(id: [1, 2]).each do |r|
r.permissions << :view_issues
r.save
def uploaded_test_file(name, mime)
ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime, true)
end
Project.where(id: [1, 2]).each do |project|
EnabledModule.create(project: project, name: 'issue_tracking')
def self.arrays_equal?(a1, a2)
(a1 - a2) - (a2 - a1) == []
end
def self.create_fixtures(fixtures_directory, table_names, _class_names = {})
if ActiveRecord::VERSION::MAJOR >= 4
ActiveRecord::FixtureSet.create_fixtures(fixtures_directory, table_names, _class_names = {})
else
ActiveRecord::Fixtures.create_fixtures(fixtures_directory, table_names, _class_names = {})
end
end
def self.prepare
Role.where(id: [1, 2]).each do |r|
r.permissions << :view_issues
r.save
end
Project.where(id: [1, 2]).each do |project|
EnabledModule.create(project: project, name: 'issue_tracking')
end
end
end
end