diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/application_helper.rb | 29 | ||||
-rw-r--r-- | app/helpers/gitlab_markdown_helper.rb | 1 | ||||
-rw-r--r-- | app/helpers/preferences_helper.rb | 31 | ||||
-rw-r--r-- | app/views/layouts/application.html.haml | 6 | ||||
-rw-r--r-- | app/views/layouts/errors.html.haml | 2 | ||||
-rw-r--r-- | app/views/profiles/preferences/update.js.erb | 2 |
6 files changed, 37 insertions, 34 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 62794bc5f4c..10d7aa11209 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2,26 +2,6 @@ require 'digest/md5' require 'uri' module ApplicationHelper - COLOR_SCHEMES = { - 1 => 'white', - 2 => 'dark', - 3 => 'solarized-light', - 4 => 'solarized-dark', - 5 => 'monokai', - } - COLOR_SCHEMES.default = 'white' - - # Helper method to access the COLOR_SCHEMES - # - # The keys are the `color_scheme_ids` - # The values are the `name` of the scheme. - # - # The preview images are `name-scheme-preview.png` - # The stylesheets should use the css class `.name` - def color_schemes - COLOR_SCHEMES.freeze - end - # Check if a particular controller is the current one # # args - One or more controller names to check @@ -138,15 +118,6 @@ module ApplicationHelper Emoji.names.to_s end - def app_theme - theme = Gitlab::Themes.by_id(current_user.try(:theme_id)) - theme.css_class - end - - def user_color_scheme_class - COLOR_SCHEMES[current_user.try(:color_scheme_id)] if defined?(current_user) - end - # Define whenever show last push event # with suggestion to create MR def show_last_push_widget?(event) diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index 2777944fc9d..9aabe01f60e 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -2,6 +2,7 @@ require 'nokogiri' module GitlabMarkdownHelper include Gitlab::Markdown + include PreferencesHelper # Use this in places where you would normally use link_to(gfm(...), ...). # diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb new file mode 100644 index 00000000000..04873b9bd00 --- /dev/null +++ b/app/helpers/preferences_helper.rb @@ -0,0 +1,31 @@ +# Helper methods for per-User preferences +module PreferencesHelper + COLOR_SCHEMES = { + 1 => 'white', + 2 => 'dark', + 3 => 'solarized-light', + 4 => 'solarized-dark', + 5 => 'monokai', + } + COLOR_SCHEMES.default = 'white' + + # Helper method to access the COLOR_SCHEMES + # + # The keys are the `color_scheme_ids` + # The values are the `name` of the scheme. + # + # The preview images are `name-scheme-preview.png` + # The stylesheets should use the css class `.name` + def color_schemes + COLOR_SCHEMES.freeze + end + + def user_application_theme + theme = Gitlab::Themes.by_id(current_user.try(:theme_id)) + theme.css_class + end + + def user_color_scheme_class + COLOR_SCHEMES[current_user.try(:color_scheme_id)] if defined?(current_user) + end +end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 173033f7eab..678ed3c2c1f 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,10 +1,10 @@ !!! 5 %html{ lang: "en"} = render "layouts/head" - %body{class: "#{app_theme}", :'data-page' => body_data_page} - / Ideally this would be inside the head, but turbolinks only evaluates page-specific JS in the body. + %body{class: "#{user_application_theme}", 'data-page' => body_data_page} + -# Ideally this would be inside the head, but turbolinks only evaluates page-specific JS in the body. = yield :scripts_body_top - + - if current_user = render "layouts/header/default", title: header_title - else diff --git a/app/views/layouts/errors.html.haml b/app/views/layouts/errors.html.haml index 2e3a2b16eb7..2af265a2296 100644 --- a/app/views/layouts/errors.html.haml +++ b/app/views/layouts/errors.html.haml @@ -1,7 +1,7 @@ !!! 5 %html{ lang: "en"} = render "layouts/head" - %body{class: "#{app_theme} application"} + %body{class: "#{user_application_theme} application"} = render "layouts/header/empty" .container.navless-container = render "layouts/flash" diff --git a/app/views/profiles/preferences/update.js.erb b/app/views/profiles/preferences/update.js.erb index 830df228557..cd2c5b632e0 100644 --- a/app/views/profiles/preferences/update.js.erb +++ b/app/views/profiles/preferences/update.js.erb @@ -1,3 +1,3 @@ // Remove body class for any previous theme, re-add current one $('body').removeClass('<%= Gitlab::Themes.body_classes %>') -$('body').addClass('<%= app_theme %>') +$('body').addClass('<%= user_application_theme %>') |