Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:

Expand Down
2 changes: 2 additions & 0 deletions config/locales/pl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pl:
field_ui_theme: 'Szablon'
6 changes: 3 additions & 3 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
21 changes: 8 additions & 13 deletions lib/redmine_user_specific_theme.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
Expand All @@ -24,3 +21,4 @@ def body_css_classes_with_user_specific

end
end
Redmine::Themes.prepend(RedmineUserSpecificTheme::Patches::ApplicationHelperPatch)