Created
February 6, 2009 18:49
-
-
Save MischaTheEvil/59545 to your computer and use it in GitHub Desktop.
This patch changes the URL-params and reintegrates pcf-value holder for iframe-links.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: app/controllers/tab_controller.rb | |
=================================================================== | |
--- app/controllers/tab_controller.rb (revision 210) | |
+++ app/controllers/tab_controller.rb (working copy) | |
@@ -1,38 +1,39 @@ | |
-# tab_controller.rb | |
-# | |
-# Copyright 2008 James Turnbull <[email protected]> | |
-# | |
-# This program is free software; you can redistribute it and/or modify | |
-# it under the terms of the GNU General Public License as published by | |
-# the Free Software Foundation; either version 2 of the License, or | |
-# (at your option) any later version. | |
-# | |
-# This program is distributed in the hope that it will be useful, | |
-# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
-# GNU General Public License for more details. | |
-# | |
-# You should have received a copy of the GNU General Public License | |
-# along with this program; if not, write to the Free Software | |
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
-# MA 02110-1301, USA. | |
+# tab_controller.rb | |
+# | |
+# Copyright (C) 2008-2009 James Turnbull <[email protected]> | |
+# | |
+# This program is free software; you can redistribute it and/or modify | |
+# it under the terms of the GNU General Public License as published by | |
+# the Free Software Foundation; either version 2 of the License, or | |
+# (at your option) any later version. | |
+# | |
+# This program is distributed in the hope that it will be useful, | |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
+# GNU General Public License for more details. | |
+# | |
+# You should have received a copy of the GNU General Public License | |
+# along with this program; if not, write to the Free Software | |
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
+# MA 02110-1301, USA. | |
class TabController < ApplicationController | |
unloadable | |
- | |
+ | |
layout 'base' | |
- | |
+ | |
before_filter :find_project, :authorize | |
- | |
+ | |
def show | |
- @project = Project.find(params[:project_id]) | |
- @tab_text = Setting.plugin_redmine_tab['tab_text'] | |
+ @tab_text = Tab.get_tab_text(@project) | |
end | |
- | |
+ | |
private | |
- | |
+ | |
def find_project | |
- # @project variable must be set before calling the authorize filter | |
- @project = Project.find(params[:project_id]) | |
+ # @project variable must be set before calling the authorize filter | |
+ @project = Project.find(params[:id]) | |
+ rescue ActiveRecord::RecordNotFound | |
+ render_404 | |
end | |
end | |
Index: app/models/tab.rb | |
=================================================================== | |
--- app/models/tab.rb (revision 0) | |
+++ app/models/tab.rb (revision 0) | |
@@ -0,0 +1,27 @@ | |
+# tab.rb | |
+# | |
+# Copyright (C) 2008-2009 James Turnbull <[email protected]> | |
+# | |
+# This program is free software; you can redistribute it and/or modify | |
+# it under the terms of the GNU General Public License as published by | |
+# the Free Software Foundation; either version 2 of the License, or | |
+# (at your option) any later version. | |
+# | |
+# This program is distributed in the hope that it will be useful, | |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
+# GNU General Public License for more details. | |
+# | |
+# You should have received a copy of the GNU General Public License | |
+# along with this program; if not, write to the Free Software | |
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
+# MA 02110-1301, USA. | |
+ | |
+class Tab | |
+ | |
+ # retrieve the value from the configured project custom field | |
+ def self.get_tab_text(project) | |
+ tab_text = project.custom_values.detect {|v| v.custom_field_id == Setting.plugin_redmine_tab['tab_text'].to_i} | |
+ tab_text = tab_text.value if tab_text | |
+ end | |
+end | |
Index: app/views/settings/_redminetab_settings.rhtml | |
=================================================================== | |
--- app/views/settings/_redminetab_settings.rhtml (revision 210) | |
+++ app/views/settings/_redminetab_settings.rhtml (working copy) | |
@@ -1,3 +1,5 @@ | |
+<% string_fields = ProjectCustomField.find :all %> | |
+ | |
<p><label>Tab Name</label> | |
<%= text_field_tag 'settings[tab_name]', @settings['tab_name'] %><br /> | |
</p> | |
@@ -3,4 +5,6 @@ | |
<p><label>Tab Text</label> | |
-<%= text_area_tag 'settings[tab_text]', @settings['tab_text'], :cols => 80, :rows => 10 %><br /> | |
+<%= select_tag 'settings[tab_text]', | |
+ '<option value="">(Select one)</option>' + | |
+ options_from_collection_for_select(string_fields, :id, :name, @settings['tab_text'].to_i) %><br /> | |
</p> | |
Index: app/views/settings/_settings.rhtml | |
=================================================================== | |
--- app/views/settings/_settings.rhtml (revision 210) | |
+++ app/views/settings/_settings.rhtml (working copy) | |
@@ -1,7 +0,0 @@ | |
-<p><label>Tab Name</label> | |
-<%= text_field_tag 'settings[tab_name]', @settings['tab_name'] %><br /> | |
-</p> | |
- | |
-<p><label>Tab Text</label> | |
-<%= text_area_tag 'settings[tab_text]', @settings['tab_text'], :cols => 80, :rows => 10 %><br /> | |
-</p> | |
Index: init.rb | |
=================================================================== | |
--- init.rb (revision 210) | |
+++ init.rb (working copy) | |
@@ -1,5 +1,5 @@ | |
-# redMine - project management software | |
-# Copyright (C) 2006-2007 Jean-Philippe Lang | |
+# Redmine - project management software | |
+# Copyright (C) 2006-2009 Jean-Philippe Lang | |
# | |
# This program is free software; you can redistribute it and/or | |
# modify it under the terms of the GNU General Public License | |
@@ -23,13 +23,14 @@ | |
name 'Tab Plugin' | |
author 'James Turnbull' | |
description 'A plugin to allow users to add a new tab with a link to an iframe.' | |
- version '0.1.0' | |
+ version '0.2.0' | |
settings :default => { | |
'tab_text' => '', | |
'tab_name' => 'Tab Name' | |
- }, :partial => 'settings/settings' | |
+ }, :partial => 'settings/redminetab_settings' | |
+ | |
# This plugin adds a project module | |
# It can be enabled/disabled at project level (Project settings -> Modules) | |
project_module :tab do | |
@@ -39,7 +40,7 @@ | |
end | |
# A new item is added to the project menu | |
- menu :project_menu, :tab, { :controller => 'tab', :action => 'show' }, :caption => Proc.new { Setting.plugin_redmine_tab['tab_name'] }, :if => Proc.new { !Setting.plugin_redmine_tab['tab_name'].blank? }, :param => :project_id | |
+ menu :project_menu, :tab, { :controller => 'tab', :action => 'show' }, :caption => Proc.new { Setting.plugin_redmine_tab['tab_name'] }, :if => Proc.new { !Setting.plugin_redmine_tab['tab_name'].blank? } | |
end | |
Rails::Plugin.class_eval do | |
Index: README | |
=================================================================== | |
--- README (revision 210) | |
+++ README (working copy) | |
@@ -1,14 +1,19 @@ | |
-= Tab Plugin For Redmine | |
+= Tab Plugin for Redmine | |
-A plugin to allow users to create a new Redmine tab and embed content from an iframe | |
+A plugin to allow users to create a new Redmine tab to embed content from an iframe on a per-project base. | |
== INSTALLATION == | |
To install from git: | |
-$ cd {RAILS_ROOT}/vendor/plugins | |
+$ cd {RAILS_ROOT}/vendor/plugins | |
$ git clone git://github.com/jamtur01/redmine_tab.git | |
== INSTRUCTIONS == | |
-This creates a single tab in which you can embed an iframe. You need to specify the Tab name and the iframe to embed in the Plugins -> Tab Plugin configuration options. | |
+This creates a single tab in which you can embed an iframe. You can globally configure the name of the tab in the Plugins -> Tab Plugin configuration options (default is "Tab Name"). The iframe-links can be configured on a per-project base using the value of a pre-configured project custom field. | |
+ | |
+1. You need to go to 'Admin -> Custom fields -> Project' and create a field of the type 'Long text' to hold the iframe-link. | |
+2. Select the field you've created in the plugin configuration by selecting Plugins -> Tab Plugin and clicking Configure. | |
+3. Inside your project you will need to add your iframe-link as the value of the field you've selected. For example to embed Google: <iframe src="http://www.google.com/" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe> | |
+4. Then use the project's Modules tab to enable the Tab module for the project. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment