diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e2eebfa412..dd1a810878 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1879,4 +1879,15 @@ module ApplicationHelper wiki_pages: auto_complete_wiki_pages_path(project_id: project, q: ''), } end + + def render_top_banner(id, wide) + return if Setting.login_required? && !User.current.logged? + + parsed_banner_text = textilizable(Setting.banner_text) + return if parsed_banner_text.blank? + + tag.div(id: id, class: "wiki top-banner #{wide ? 'mobile-hide' : 'mobile-show'}") do + parsed_banner_text + end + end end diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index 8114ff9e0c..6736734b03 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -67,6 +67,8 @@ <%= render_menu :top_menu if User.current.logged? || !Setting.login_required? -%> +<%= render_top_banner('top-banner', true) %> +
+ <%= render_top_banner('top-banner-in-content', false) %> <%= render_flash_messages %> <%= yield %> <%= call_hook :view_layouts_base_content %> diff --git a/app/views/settings/_general.html.erb b/app/views/settings/_general.html.erb index 043067f180..0d729f3c1e 100644 --- a/app/views/settings/_general.html.erb +++ b/app/views/settings/_general.html.erb @@ -6,6 +6,8 @@

<%= setting_text_area :welcome_text, :cols => 60, :rows => 5, :class => 'wiki-edit' %>

<%= wikitoolbar_for 'settings_welcome_text' %> +

<%= setting_text_area :banner_text, :cols => 60, :rows => 5, :class => 'wiki-edit' %>

+<%= wikitoolbar_for 'settings_banner_text' %>

<%= setting_text_field :per_page_options, :size => 20 %> <%= l(:text_comma_separated) %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index 5fee1e2251..1a35c22c25 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -417,6 +417,7 @@ en: setting_app_title: Application title setting_welcome_text: Welcome text + setting_banner_text: Banner text setting_default_language: Default language setting_login_required: Authentication required setting_self_registration: Self-registration diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 3a250c6c3d..eda6f3dceb 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -346,6 +346,7 @@ ja: setting_app_title: アプリケーションのタイトル setting_welcome_text: ウェルカムメッセージ + setting_banner_text: バナーメッセージ setting_default_language: デフォルトの言語 setting_login_required: 認証が必要 setting_self_registration: ユーザーによるアカウント登録 diff --git a/config/settings.yml b/config/settings.yml index 0c41b7eda1..30c1594dbc 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -23,6 +23,8 @@ app_title: default: Redmine welcome_text: default: +banner_text: + default: login_required: default: 0 security_notifications: 1 diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 6d7402f661..1377639c05 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1151,6 +1151,15 @@ img.ui-datepicker-trigger { margin-bottom: 15px; } +/***** Banner *****/ + +div.top-banner { + padding: 0px 20px; + margin: 0px; + background-color: #eee; + border: 1px solid #ddd; +} + /***** Progress bar *****/ table.progress { border-collapse: collapse; diff --git a/public/stylesheets/responsive.css b/public/stylesheets/responsive.css index 3d3a41fff8..61cc3afb3d 100644 --- a/public/stylesheets/responsive.css +++ b/public/stylesheets/responsive.css @@ -584,6 +584,8 @@ .mobile-hide {display:none;} .mobile-show {display:initial;} + .top-banner.mobile-show { display: block; } + /* Contextual Buttons */ #content>.contextual { diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 93a434e40d..69bf424779 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -64,6 +64,22 @@ class AccountControllerTest < Redmine::ControllerTest assert_equal 2, @request.session[:user_id] end + def test_login_should_not_view_banner_if_required_login + with_settings :banner_text => 'h1. banner text' do + with_settings :login_required => '0' do + get :login + assert_response :success + assert_select '#top-banner h1', text: /banner text/ + end + + with_settings :login_required => '1' do + get :login + assert_response :success + assert_select '#top-banner', count: 0 + end + end + end + def test_login_should_redirect_to_back_url_param # request.uri is "test.host" in test environment back_urls = [