RE: How to get a string from Proc.new ยป init.rb
1 |
require 'redmine' |
---|---|
2 |
|
3 |
RAILS_DEFAULT_LOGGER.info 'Menu Link plugin 0.0.1 for Redmine' |
4 |
|
5 |
Redmine::Plugin.register :menu_link do |
6 |
name 'Menu Link Plugin' |
7 |
author 'Tide' |
8 |
description 'A plugin which adds a link to the top menu of Redmine.' |
9 |
version '0.0.1' |
10 |
|
11 |
settings :default => { |
12 |
'link_item_text' => 'http://www.redmine.org', |
13 |
'link_item_name' => 'Example Link', |
14 |
'new_window' => '0' |
15 |
|
16 |
}, :partial => 'settings/menulink_settings' |
17 |
menu(:top_menu, |
18 |
:link, |
19 |
"http://www.google.com", |
20 |
:caption => Proc.new { Setting.plugin_menu_link['link_item_name'] }) |
21 |
end
|
22 |
|
23 |
class MenuListener < Redmine::Hook::ViewListener |
24 |
def view_layouts_base_html_head(context) |
25 |
if Setting.plugin_menu_link['new_window'] == "0" |
26 |
Redmine::MenuManager.map(:top_menu).find(:link).html_options[:target] = nil |
27 |
else
|
28 |
Redmine::MenuManager.map(:top_menu).find(:link).html_options[:target] = '_blank' |
29 |
end
|
30 |
nil
|
31 |
end
|
32 |
end
|