diff --git a/README.md b/README.md index 323db04..b0fa3d8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ # Redmine User-Specific Theme Plugin -[![Build Status](https://travis-ci.org/Restream/redmine_user_specific_theme.png)](https://travis-ci.org/Restream/redmine_user_specific_theme) -[![Code Climate](https://codeclimate.com/github/Restream/redmine_user_specific_theme.png)](https://codeclimate.com/github/Restream/redmine_user_specific_theme) - This plugin allows Redmine users to select themes in their account settings. The selected theme will be displayed for the user regardless of the system-wide theme settings. ## Compatibility @@ -22,7 +19,7 @@ This plugin version is compatible only with Redmine 2.1.x and later. Copy the plugin from GitHub using the following command: - git clone https://github.com/Restream/redmine_user_specific_theme.git plugins/redmine_user_specific_theme + git clone https://github.com/Barto-Paja/redmine_user_specific_theme plugins/redmine_user_specific_theme 2. Install the required gems using the command: diff --git a/config/locales/pl.yml b/config/locales/pl.yml new file mode 100644 index 0000000..d75425b --- /dev/null +++ b/config/locales/pl.yml @@ -0,0 +1,2 @@ +pl: + field_ui_theme: 'Szablon' \ No newline at end of file diff --git a/init.rb b/init.rb index cfd3adc..29b56a8 100644 --- a/init.rb +++ b/init.rb @@ -4,10 +4,10 @@ name 'Redmine User-Specific Theme Plugin' description 'This plugin allows users to set Redmine themes in the account settings.' author 'Restream' - version '1.2.0' + version '2.2.0' url 'https://github.com/Restream/redmine_user_specific_theme' - requires_redmine :version_or_higher => '2.1' + requires_redmine :version_or_higher => '4.0' end -require 'redmine_user_specific_theme' +require File.dirname(__FILE__) + '/lib/redmine_user_specific_theme' diff --git a/lib/redmine_user_specific_theme.rb b/lib/redmine_user_specific_theme.rb index dddb229..2e7dee3 100644 --- a/lib/redmine_user_specific_theme.rb +++ b/lib/redmine_user_specific_theme.rb @@ -1,18 +1,13 @@ module RedmineUserSpecificTheme end -require_dependency 'redmine_user_specific_theme/hooks/view_hooks' -require_dependency 'redmine_user_specific_theme/patches/user_preference_patch' -require_dependency 'redmine_user_specific_theme/patches/application_helper_patch' - -ActionDispatch::Callbacks.to_prepare do - - unless UserPreference.included_modules.include?(RedmineUserSpecificTheme::Patches::UserPreferencePatch) - UserPreference.send :prepend, RedmineUserSpecificTheme::Patches::UserPreferencePatch - end - - unless ApplicationHelper.included_modules.include?(RedmineUserSpecificTheme::Patches::ApplicationHelperPatch) - ApplicationHelper.send :include, RedmineUserSpecificTheme::Patches::ApplicationHelperPatch - end +require File.dirname(__FILE__) + '/redmine_user_specific_theme/hooks/view_hooks' +require File.dirname(__FILE__) + '/redmine_user_specific_theme/patches/user_preference_patch' +require File.dirname(__FILE__) + '/redmine_user_specific_theme/patches/application_helper_patch' +unless UserPreference.included_modules.include?(RedmineUserSpecificTheme::Patches::UserPreferencePatch) + UserPreference.send :prepend, RedmineUserSpecificTheme::Patches::UserPreferencePatch +end +unless ApplicationHelper.included_modules.include?(RedmineUserSpecificTheme::Patches::ApplicationHelperPatch) + ApplicationHelper.send :include, RedmineUserSpecificTheme::Patches::ApplicationHelperPatch end diff --git a/lib/redmine_user_specific_theme/patches/application_helper_patch.rb b/lib/redmine_user_specific_theme/patches/application_helper_patch.rb index 8df0eb9..4d16126 100644 --- a/lib/redmine_user_specific_theme/patches/application_helper_patch.rb +++ b/lib/redmine_user_specific_theme/patches/application_helper_patch.rb @@ -4,17 +4,14 @@ module RedmineUserSpecificTheme::Patches module ApplicationHelperPatch extend ActiveSupport::Concern - included do - alias_method_chain :current_theme, :user_specific - alias_method_chain :body_css_classes, :user_specific + def current_theme + user_theme = super + user_theme = Redmine::Themes.theme(User.current.pref.ui_theme, theme_directory: 'assets/themes') + user_theme || Redmine::Themes.theme(Setting.ui_theme, theme_directory: 'assets/themes') end - def current_theme_with_user_specific - user_theme = Redmine::Themes.theme(User.current.pref.ui_theme) - user_theme || Redmine::Themes.theme(Setting.ui_theme) - end - - def body_css_classes_with_user_specific + def body_css_classes + css_classes = super css_classes = body_css_classes_without_user_specific user_theme = Redmine::Themes.theme(User.current.pref.ui_theme) user_theme ? @@ -24,3 +21,4 @@ def body_css_classes_with_user_specific end end +Redmine::Themes.prepend(RedmineUserSpecificTheme::Patches::ApplicationHelperPatch)