diff --git a/app/assets/stylesheets/login.css.scss b/app/assets/stylesheets/login.css.scss index 28d2c008..ed0bab56 100644 --- a/app/assets/stylesheets/login.css.scss +++ b/app/assets/stylesheets/login.css.scss @@ -6,6 +6,7 @@ body { @include make-xs-column(12); @include make-sm-column(6); @include make-sm-column-offset(3); + padding: 10px; } .login-wrapper { diff --git a/app/helpers/bootstrap_flash_helper.rb b/app/helpers/bootstrap_flash_helper.rb new file mode 100644 index 00000000..04ea47bf --- /dev/null +++ b/app/helpers/bootstrap_flash_helper.rb @@ -0,0 +1,36 @@ +module BootstrapFlashHelper + ALERT_MAPPING = { + :notice => :success, + :alert => :danger, + :error => :danger, + :info => :info, + :warning => :warning + } unless const_defined?(:ALERT_MAPPING) + + def bootstrap_flash(options = {:close_button => true}) + flash_messages = [] + flash.each do |type, message| + # Skip empty messages, e.g. for devise messages set to nothing in a locale file. + next if message.blank? + type = type.to_sym + next unless ALERT_MAPPING.keys.include?(type) + + + tag_class = options.extract!(:class)[:class] + tag_options = { + class: "alert fade in alert-#{ALERT_MAPPING[type]} #{tag_class}" + }.merge(options) + + close_button = "" + if options[:close_button] + close_button = content_tag(:button, raw("×"), type: "button", class: "close", "data-dismiss" => "alert") + end + + Array(message).each do |msg| + text = content_tag(:div, close_button + msg, tag_options) + flash_messages << text if msg + end + end + flash_messages.join("\n").html_safe + end +end diff --git a/app/views/login/login.html.erb b/app/views/login/login.html.erb index 6845876b..51d69e0e 100644 --- a/app/views/login/login.html.erb +++ b/app/views/login/login.html.erb @@ -1,7 +1,7 @@