From 88e6388f423f8ec0dcb6e2bad2b1a87e94f61485 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Fri, 20 May 2016 20:51:52 -0300 Subject: [PATCH] responsive: fix html_safe issues --- app/helpers/application_helper.rb | 12 +++++------- plugins/responsive/lib/ext/application_helper.rb | 250 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------- plugins/responsive/lib/ext/boxes_helper.rb | 4 ++++ plugins/responsive/lib/ext/chat_helper.rb | 7 +------ plugins/responsive/lib/ext/forms_helper.rb | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++------ plugins/responsive/lib/ext/input_helper.rb | 13 +++++++++++++ plugins/responsive/lib/responsive_plugin.rb | 2 +- plugins/responsive/views/layouts/_menu_responsive.html.erb | 71 ----------------------------------------------------------------------- plugins/responsive/views/layouts/_menu_responsive.html.slim | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ plugins/responsive/views/layouts/_usermenu_logged_in.html.slim | 39 +++++++++++++++++++++++++++++++++++++++ plugins/responsive/views/layouts/application-responsive.html.erb | 6 +++--- 11 files changed, 279 insertions(+), 236 deletions(-) delete mode 100644 plugins/responsive/views/layouts/_menu_responsive.html.erb create mode 100644 plugins/responsive/views/layouts/_menu_responsive.html.slim create mode 100644 plugins/responsive/views/layouts/_usermenu_logged_in.html.slim diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c2aba18..e7fc154 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -593,8 +593,8 @@ module ApplicationHelper end if block - field_html ||= '' - field_html += capture(&block) + field_html ||= ''.html_safe + field_html = [field_html, capture(&block)].safe_join end if controller.action_name == 'signup' || controller.action_name == 'new_community' || (controller.controller_name == "enterprise_registration" && controller.action_name == 'index') || (controller.controller_name == 'home' && controller.action_name == 'index' && user.nil?) @@ -603,7 +603,9 @@ module ApplicationHelper end else if profile.active_fields.include?(name) - result = content_tag('div', field_html + profile_field_privacy_selector(profile, name), :class => 'field-with-privacy-selector') + result = content_tag :div, class: 'field-with-privacy-selector' do + [field_html, profile_field_privacy_selector(profile, name)].safe_join + end end end @@ -611,10 +613,6 @@ module ApplicationHelper result = required(result) end - if block - concat(result) - end - result end diff --git a/plugins/responsive/lib/ext/application_helper.rb b/plugins/responsive/lib/ext/application_helper.rb index e36ff67..c1e6675 100644 --- a/plugins/responsive/lib/ext/application_helper.rb +++ b/plugins/responsive/lib/ext/application_helper.rb @@ -5,7 +5,7 @@ module ApplicationHelper protected module ResponsiveMethods - FORM_CONTROL_CLASS = "form-control" + FORM_CONTROL_CLASS = 'form-control' def button(type, label, url, html_options = {}) return super unless theme_responsive? @@ -13,15 +13,14 @@ module ApplicationHelper option = html_options.delete(:option) || 'default' size = html_options.delete(:size) || 'xs' the_class = "with-text btn btn-#{size} btn-#{option} icon-#{type}" - if html_options.has_key?(:class) - the_class << ' ' << html_options[:class] - end - #button_without_text type, label, url, html_options.merge(:class => the_class) + the_class << ' ' << html_options[:class] if html_options.has_key?(:class) + + #button_without_text type, label, url, html_options.merge(class: the_class) the_title = html_options[:title] || label if html_options[:disabled] - content_tag('a', content_tag('span', label), html_options.merge(class: the_class, title: the_title)) + content_tag(:a, content_tag(:span, label), html_options.merge(class: the_class, title: the_title)) else - link_to(content_tag('span', label), url, html_options.merge(class: the_class, title: the_title)) + link_to(content_tag(:span, label), url, html_options.merge(class: the_class, title: the_title)) end end @@ -36,7 +35,7 @@ module ApplicationHelper end the_title = html_options[:title] || label if html_options[:disabled] - content_tag('a', '', html_options.merge(class: the_class, title: the_title)) + content_tag(:a, '', html_options.merge(class: the_class, title: the_title)) else link_to('', url, html_options.merge(class: the_class, title: the_title)) end @@ -91,7 +90,7 @@ module ApplicationHelper if html_options.has_key?(:class) the_class << ' ' << html_options[:class] end - content_tag('div', '', html_options.merge(class: the_class)) + content_tag(:div, '', html_options.merge(class: the_class)) end def icon_button(type, text, url, html_options = {}) @@ -104,16 +103,21 @@ module ApplicationHelper the_class << ' ' << html_options[:class] end - link_to(content_tag('span', text), url, html_options.merge(class: the_class, title: text)) + link_to(content_tag(:span, text), url, html_options.merge(class: the_class, title: text)) end - def button_bar(options = {}, &block) + def button_bar options = {}, &block return super unless theme_responsive? - options[:class].nil? ? - options[:class]='button-bar' : - options[:class]+=' button-bar' - concat(content_tag('div', capture(&block).to_s + tag('br', style: 'clear: left;'), options)) + options[:class] ||= '' + options[:class] << 'button-bar' + + content_tag :div, options do + [ + capture(&block).to_s, + tag('br', style: 'clear: left;'), + ].safe_join + end end def expirable_button(content, action, text, url, html_options = {}) @@ -128,143 +132,93 @@ module ApplicationHelper def search_contents_menu return super unless theme_responsive? - host = environment.default_hostname - - output = '' - output end def search_people_menu return super unless theme_responsive? - host = environment.default_hostname - - output = '' - output end def search_communities_menu return super unless theme_responsive? - host = environment.default_hostname - - output = '' - output - end - - def usermenu_logged_in - return super unless theme_responsive? - - output = '