jamtur01 / redmine_tab

Add a named tab to Redmine that links to an iframe

This URL has Read+Write access

redmine_tab / init.rb
8d74539b » jamtur01 2009-02-07 0.2.0 - Refactoring to supp... 1 # Redmine - project management software
2 # Copyright (C) 2006-2009 Jean-Philippe Lang
72bec5f7 » root 2008-05-06 Initial commit 3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
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
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require 'redmine'
19
20 RAILS_DEFAULT_LOGGER.info 'Tab'
21
22 Redmine::Plugin.register :redmine_tab do
23 name 'Tab Plugin'
24 author 'James Turnbull'
25 description 'A plugin to allow users to add a new tab with a link to an iframe.'
fb2c6554 » jamtur01 2009-04-11 Bumped to 0.3.0 26 version '0.3.0'
72bec5f7 » root 2008-05-06 Initial commit 27
f0c942b2 » jamtur01 2008-12-27 Re-did settings 28 settings :default => {
29 'tab_text' => '',
19dbe659 » edavis10 2009-03-30 Added the ability to define... 30 'tab_name' => 'Tab Name',
31 'system_tab_text' => '',
32 'system_tab_name' => 'System Tab Name'
8d74539b » jamtur01 2009-02-07 0.2.0 - Refactoring to supp... 33
34 }, :partial => 'settings/redminetab_settings'
72bec5f7 » root 2008-05-06 Initial commit 35
36 # This plugin adds a project module
37 # It can be enabled/disabled at project level (Project settings -> Modules)
38 project_module :tab do
39 # This permission has to be explicitly given
40 # It will be listed on the permissions screen
41 permission :view_tab, {:tab => :show}
42 end
43
022587e1 » edavis10 2009-03-30 Moved the content of the sy... 44 # Translate or return the setting_name directly
45 string_or_translate = lambda {|setting_name|
46 string = Setting.plugin_redmine_tab[setting_name]
47 if !string.blank? && string.match(/\A:/) # uses symbol syntax, :string
48 string.gsub!(':','')
49 string = GLoc.l(string.to_sym) if Object.const_defined?('GLoc') # Rails 2.1.x
50 string = I18n.t(string.to_sym) if Object.const_defined?('I18n') # Rails 2.2.x
51 end
52 string
53 }
54
72bec5f7 » root 2008-05-06 Initial commit 55 # A new item is added to the project menu
0b942547 » edavis10 2009-03-30 Changed the project menu to... 56 menu(:project_menu,
57 :tab,
58 { :controller => 'tab', :action => 'show' },
59 :caption => Proc.new { string_or_translate.call('tab_name') },
60 :if => Proc.new { !Setting.plugin_redmine_tab['tab_name'].blank? })
19dbe659 » edavis10 2009-03-30 Added the ability to define... 61
62
63 menu(:top_menu,
64 :tab,
65 { :controller => 'tab', :action => 'system_show' },
022587e1 » edavis10 2009-03-30 Moved the content of the sy... 66 :caption => Proc.new { string_or_translate.call('system_tab_name') },
19dbe659 » edavis10 2009-03-30 Added the ability to define... 67 :if => Proc.new { !Setting.plugin_redmine_tab['system_tab_name'].blank? })
72bec5f7 » root 2008-05-06 Initial commit 68 end
69
70 Rails::Plugin.class_eval do
71 def reloadable!
72 load_paths.each { |p| Dependencies.load_once_paths.delete(p) }
73 end
74 end
75
76 reloadable!