Skip to content

Commit

Permalink
Plugin overhaul, general cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
duanejevon committed Dec 27, 2012
1 parent aeab37c commit 2367563
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 59 deletions.
47 changes: 0 additions & 47 deletions app/controllers/welcome_controller.rb

This file was deleted.

Binary file removed assets/images/RedmineWikiStartPage.png
Binary file not shown.
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# English strings go here for Rails i18n
en:
label_setting_examples: "See some configuration examples at "
label_example_url: http://gatatac.net/projects/redminewikistartpage/wiki
label_example_url: https://github.com/txinto/redmine_startpage
label_startpage_active: Active?
label_startpage_controller: Controller
label_startpage_action: Action
Expand Down
2 changes: 1 addition & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Spanish strings go here for Rails i18n
es:
label_setting_examples: "Vea algunos ejemplos de configuración en "
label_example_url: http://gatatac.net/projects/redminewikistartpage/wiki
label_example_url: https://github.com/txinto/redmine_startpage
label_startpage_active: Activado?
label_startpage_controller: Controlador
label_startpage_action: Acción
Expand Down
7 changes: 4 additions & 3 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
require 'redmine'

require_dependency 'welcome_controller_patch'

Redmine::Plugin.register :redmine_startpage do
name 'Redmine Startpage plugin'
author 'Txinto Vaz'
description 'This is a plugin for Redmine. It allows the user to select almost any redmine sub page as start page for a Redmine website'
version '0.0.2'
url 'http://gatatac.net/projects/redminewikistartpage'
author_url 'http://gatatac.net/users/3'
version '0.1.0'
url 'https://github.com/txinto/redmine_startpage'

settings :default => {
'startpage_active' => :false,
Expand Down
2 changes: 0 additions & 2 deletions lang/en.yml

This file was deleted.

57 changes: 57 additions & 0 deletions lib/welcome_controller_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module WelcomeControllerPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)

base.class_eval do

before_filter :forward_to_startpage, :only => :index

end
end

module InstanceMethods
def forward_to_startpage

if (Setting.plugin_redmine_startpage['startpage_active'] &&
!Setting.plugin_redmine_startpage['startpage_controller'].blank?)
if (Setting.plugin_redmine_startpage['startpage_action'].blank?)
action_to_redirect = nil
else
action_to_redirect = Setting.plugin_redmine_startpage['startpage_action']
end

if (Setting.plugin_redmine_startpage['startpage_id'].blank?)
id_to_redirect = nil
else
id_to_redirect = Setting.plugin_redmine_startpage['startpage_id']
end

if (Setting.plugin_redmine_startpage['startpage_argname'].blank? ||
Setting.plugin_redmine_startpage['startpage_argvalue'].blank?)
argname_to_redirect = nil
argvalue_to_redirect = nil
else
argname_to_redirect = Setting.plugin_redmine_startpage['startpage_argname']
argvalue_to_redirect = Setting.plugin_redmine_startpage['startpage_argvalue']
end

if (argname_to_redirect.nil?)
redirect_to(
:controller => Setting.plugin_redmine_startpage['startpage_controller'],
:action => action_to_redirect,
:id => id_to_redirect)
else
redirect_to(
:controller => Setting.plugin_redmine_startpage['startpage_controller'],
:action => action_to_redirect,
:id => id_to_redirect,
argname_to_redirect => argvalue_to_redirect
)
end
end
end
end
end

# Add module to Welcome Controller
WelcomeController.send(:include, WelcomeControllerPatch)
5 changes: 0 additions & 5 deletions test/test_helper.rb

This file was deleted.

0 comments on commit 2367563

Please sign in to comment.