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 += link_to(_('Contents'), '#', :class=>"dropdown-toggle icon-menu-articles", title: _('Contents'), :'data-toggle'=>"dropdown", :'data-hover'=>"dropdown")
- output += ''
- output += ''
- output
end
def search_people_menu
return super unless theme_responsive?
- host = environment.default_hostname
-
- output = ''
- output += link_to(_('People'), '#', :class=>"dropdown-toggle icon-menu-people", title: _('People'), :'data-toggle'=>"dropdown", :'data-hover'=>"dropdown")
- output += ''
- output += ''
- output
end
def search_communities_menu
return super unless theme_responsive?
- host = environment.default_hostname
-
- output = ''
- output += link_to(_('Communities'), '#', :class=>"dropdown-toggle icon-menu-community", title: _('Communities'), :'data-toggle'=>"dropdown", :'data-hover'=>"dropdown")
- output += ''
- output += ''
- output
- end
-
- def usermenu_logged_in
- return super unless theme_responsive?
-
- output = ''
-
- pending_tasks_count = ''
- count = user ? Task.to(user).pending.count : -1
- if count > 0
- pending_tasks_count = "" + count.to_s + ''
+ content_tag :li, class: 'dropdown' do
+ [
+ link_to('#', class: 'dropdown-toggle icon-menu-community', title: _('Communities'), data: {toggle: 'dropdown', hover: 'dropdown'}) do
+ content_tag :span, _('Communities')
+ end,
+ content_tag(:ul, class: 'dropdown-menu', role: 'menu') do
+ links.map do |params|
+ content_tag :li do
+ link_to *params
+ end
+ end.safe_join
+ end
+ ].safe_join
end
-
- output += link_to("#{user.identifier} #{pending_tasks_count}", '#', id: "homepage-link", title: _('Go to your homepage'), :class=>"dropdown-toggle", :'data-toggle'=>"dropdown", :'data-target'=>"", :'data-hover'=>"dropdown")
-
-
- output += ''
- output
end
def manage_link(list, kind, title)
@@ -274,17 +228,22 @@ module ApplicationHelper
link_to_all = nil
if list.count > 5
list = list.first(5)
- link_to_all = link_to(content_tag('strong', _('See all')), :controller => 'memberships', :profile => user.identifier)
+ link_to_all = link_to(content_tag(:strong, _('See all')), controller: 'memberships', profile: user.identifier)
end
link = list.map do |element|
- link_to(content_tag('strong', element.short_name(25)), element.admin_url, :class => "icon-menu-"+element.class.identification.underscore, :title => _('Manage %s') % element.short_name)
+ link_to(content_tag(:strong, element.short_name(25)), element.admin_url, class: "icon-menu-"+element.class.identification.underscore, title: _('Manage %s') % element.short_name)
end
if link_to_all
link << link_to_all
end
- content_tag('li', nil, class: 'divider') +
- content_tag('li', title, class: 'dropdown-header') +
- link.map{ |l| content_tag 'li', l }.join
+
+ [
+ content_tag(:li, nil, class: 'divider'),
+ content_tag(:li, title, class: 'dropdown-header'),
+ link.map do |l|
+ content_tag :li, l
+ end.safe_join
+ ].safe_join
end
end
@@ -301,15 +260,24 @@ module ApplicationHelper
unless html_options[:style].present? and html_options[:style] =~ /display *: *none/
menu_content << '
' unless first
first = false
- menu_content << content_tag(:a,link_label,html_options)
+ menu_content << content_tag(:a, link_label,html_options)
end
end
end
end
option = html_options.delete(:option) || 'default'
- size = html_options.delete(:size) || 'xs'
- "'
+ size = html_options.delete(:size) || 'xs'
+ button_tag '',
+ class: "btn btn-#{size} btn-#{option} btn-popover-menu icon-parent-folder",
+ data: {
+ html: 'true',
+ toggle: 'popover',
+ placement: 'top',
+ trigger: 'focus',
+ content: menu_content,
+ title: menu_title,
+ }
end
@@ -406,12 +374,7 @@ module ApplicationHelper
end
include ResponsiveChecks
- if RUBY_VERSION >= '2.0.0'
- prepend ResponsiveMethods
- else
- extend ActiveSupport::Concern
- included { include ResponsiveMethods }
- end
+ prepend ResponsiveMethods
# TODO: apply theme_responsive? condition
class NoosferoFormBuilder
@@ -440,13 +403,16 @@ module ApplicationHelper
if options[:horizontal]
label_html = content_tag :label, gettext(text), class: 'control-label col-sm-3 col-md-2 col-lg-2', for: field_id
- result = content_tag :div, label_html + content_tag('div',field_html, class: 'col-sm-9 col-md-6 col-lg-6'), class: 'form-group'
+ content = [
+ label_html,
+ content_tag(:div, field_html.html_safe, class: 'col-sm-9 col-md-6 col-lg-6'),
+ ].safe_join
+ content_tag :div, content, class: 'form-group'
else
label_html = content_tag :label, gettext(text), class: 'control-label', for: field_id
- result = content_tag :div, label_html + field_html, class: 'form-group'
+ content = [label_html, field_html.html_safe].safe_join
+ content_tag :div, content, class: 'form-group'
end
-
- result
end
end
diff --git a/plugins/responsive/lib/ext/boxes_helper.rb b/plugins/responsive/lib/ext/boxes_helper.rb
index 59581ef..e16012f 100644
--- a/plugins/responsive/lib/ext/boxes_helper.rb
+++ b/plugins/responsive/lib/ext/boxes_helper.rb
@@ -62,12 +62,16 @@ module BoxesHelper
end
include ResponsiveChecks
+<<<<<<< HEAD
if RUBY_VERSION >= '2.0.0'
prepend ResponsiveMethods
else
extend ActiveSupport::Concern
included { include ResponsiveMethods }
end
+=======
+ prepend ResponsiveMethods
+>>>>>>> 2ef3a43... responsive: fix html_safe issues
end
diff --git a/plugins/responsive/lib/ext/chat_helper.rb b/plugins/responsive/lib/ext/chat_helper.rb
index 2d9aef3..110bb4f 100644
--- a/plugins/responsive/lib/ext/chat_helper.rb
+++ b/plugins/responsive/lib/ext/chat_helper.rb
@@ -23,12 +23,7 @@ module ChatHelper
end
include ResponsiveChecks
- if RUBY_VERSION >= '2.0.0'
- prepend ResponsiveMethods
- else
- extend ActiveSupport::Concern
- included { include ResponsiveMethods }
- end
+ prepend ResponsiveMethods
end
diff --git a/plugins/responsive/lib/ext/forms_helper.rb b/plugins/responsive/lib/ext/forms_helper.rb
index 9e6d4f5..4c98ca3 100644
--- a/plugins/responsive/lib/ext/forms_helper.rb
+++ b/plugins/responsive/lib/ext/forms_helper.rb
@@ -11,8 +11,20 @@ module FormsHelper
return super unless theme_responsive?
options[:id] ||= 'radio-' + FormsHelper.next_id_number
+<<<<<<< HEAD
content_tag( 'label', radio_button_tag( name, value, checked, options ) + ' ' +
human_name, for: options[:id], class: 'radio-inline' )
+=======
+ content_tag :div, class:'radio-inline' do
+ content_tag :label, for: options[:id] do
+ [
+ radio_button_tag(name, value, checked, options),
+ ' ',
+ human_name,
+ ].safe_join
+ end
+ end
+>>>>>>> 2ef3a43... responsive: fix html_safe issues
end
# add -inline class
@@ -20,8 +32,23 @@ module FormsHelper
return super unless theme_responsive?
options[:id] ||= 'checkbox-' + FormsHelper.next_id_number
+<<<<<<< HEAD
hidden_field_tag(name, '0') +
content_tag( 'label', check_box_tag( name, value, checked, options ) + ' ' + human_name, for: options[:id], class: 'checkbox-inline')
+=======
+ [
+ hidden_field_tag(name, '0'),
+ content_tag(:div, class:'checkbox-inline') do
+ content_tag :label, for: options[:id] do
+ [
+ check_box_tag(name, value, checked, options),
+ ' ',
+ human_name,
+ ].safe_join
+ end
+ end
+ ].safe_join
+>>>>>>> 2ef3a43... responsive: fix html_safe issues
end
def submit_button(type, label, html_options = {})
@@ -42,10 +69,17 @@ module FormsHelper
html_options.delete(:cancel)
bt_submit = button_tag(label, html_options.merge(class: the_class))
+<<<<<<< HEAD
+=======
+
+ [bt_submit + bt_cancel].safe_join
+ end
+>>>>>>> 2ef3a43... responsive: fix html_safe issues
bt_submit + bt_cancel
end
+<<<<<<< HEAD
%w[select select_tag text_field_tag number_field_tag password_field_tag].each do |method|
define_method method do |*args, &block|
#return super(*args, &block) unless theme_responsive?
@@ -57,28 +91,39 @@ module FormsHelper
options[:class] = "#{options[:class]} form-control"
end
super(*(args << options), &block)
+=======
+ %w[
+ select_tag
+ text_field_tag text_area_tag
+ number_field_tag password_field_tag url_field_tag email_field_tag
+ month_field_tag date_field_tag
+ ].each do |method|
+ define_method method do |name, value=nil, options={}, &block|
+ responsive_add_field_class! options
+ super(name, value, options, &block).html_safe
+>>>>>>> 2ef3a43... responsive: fix html_safe issues
end
end
%w[select_month select_year].each do |method|
define_method method do |date, options={}, html_options={}|
+<<<<<<< HEAD
if html_options['class']
html_options['class'] = "#{html_options['class']} form-control"
else
html_options[:class] = "#{html_options[:class]} form-control"
end
super date, options, html_options
+=======
+ responsive_add_field_class! html_options
+ super(date, options, html_options).html_safe
+>>>>>>> 2ef3a43... responsive: fix html_safe issues
end
end
end
include ResponsiveChecks
- if RUBY_VERSION >= '2.0.0'
- prepend ResponsiveMethods
- else
- extend ActiveSupport::Concern
- included { include ResponsiveMethods }
- end
+ prepend ResponsiveMethods
end
diff --git a/plugins/responsive/lib/ext/input_helper.rb b/plugins/responsive/lib/ext/input_helper.rb
index f7ef3ee..86e6034 100644
--- a/plugins/responsive/lib/ext/input_helper.rb
+++ b/plugins/responsive/lib/ext/input_helper.rb
@@ -4,16 +4,29 @@ module InputHelper
protected
def input_group_addon addon, options = {}, &block
+<<<<<<< HEAD
content_tag :div,
content_tag(:span, addon, class: 'input-group-addon') + yield,
class: 'input-group'
+=======
+ content_tag :div, class: 'input-group' do
+ [
+ content_tag(:span, addon, class: 'input-group-addon'),
+ capture(&block),
+ ].safe_join
+ end
+>>>>>>> 2ef3a43... responsive: fix html_safe issues
end
end
+<<<<<<< HEAD
module ApplicationHelper
include InputHelper
end
+=======
+ApplicationHelper.include InputHelper
+>>>>>>> 2ef3a43... responsive: fix html_safe issues
diff --git a/plugins/responsive/lib/responsive_plugin.rb b/plugins/responsive/lib/responsive_plugin.rb
index 2f42490..c10edd5 100644
--- a/plugins/responsive/lib/responsive_plugin.rb
+++ b/plugins/responsive/lib/responsive_plugin.rb
@@ -13,7 +13,7 @@ class ResponsivePlugin < Noosfero::Plugin
end
def head_ending
- ''
+ ''.html_safe
end
def body_ending
diff --git a/plugins/responsive/views/layouts/_menu_responsive.html.erb b/plugins/responsive/views/layouts/_menu_responsive.html.erb
deleted file mode 100644
index e1a633a..0000000
--- a/plugins/responsive/views/layouts/_menu_responsive.html.erb
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-
-
- <%= render :file => 'account/login', :locals => { :is_thickbox => true } %>
-
diff --git a/plugins/responsive/views/layouts/_menu_responsive.html.slim b/plugins/responsive/views/layouts/_menu_responsive.html.slim
new file mode 100644
index 0000000..64b7925
--- /dev/null
+++ b/plugins/responsive/views/layouts/_menu_responsive.html.slim
@@ -0,0 +1,54 @@
+div
+ nav#top-bar.navbar.navbar-default.navbar-static-top role="navigation"
+ .container
+ /! Brand and toggle get grouped for better mobile display
+ .navbar-header
+ button.navbar-toggle data-target="#navbar-user-collapse" data-toggle="collapse" type="button"
+ span.sr-only= _('User menu')
+ span.fa.fa-user.navbar-toggle-icon
+
+ button.navbar-toggle data-target="#navbar-search-collapse" data-toggle="collapse" type="button"
+ span.sr-only= _('Search')
+ span.fa.fa-search.navbar-toggle-icon
+
+ button.navbar-toggle data-target="#navbar-navigation-collapse" data-toggle="collapse" type="button"
+ span.sr-only= _('Navigation')
+ span.icon-bar
+ span.icon-bar
+ span.icon-bar
+ a.navbar-brand href="#{environment.top_url}"
+ = theme_site_title
+ span#navbar-brand-site-title
+ = h @environment.name
+
+ /! Collect the nav links, forms, and other content for toggling
+ #navbar-navigation-collapse.collapse.navbar-collapse
+ ul.nav.navbar-nav.menu-navigation
+ = theme_extra_navigation
+ li#search-dropdown-menu.dropdown
+ a.dropdown-toggle.icon-search data-hover="dropdown" data-toggle="dropdown" href="#" title="#{_('Search')}"
+ span= _('Search')
+ ul.dropdown-menu role="menu"
+ li
+ form#top-search action="/search" method="get" role="search"
+ .form-group.col-lg-12.col-md-12.col-sm-12
+ input.form-control.input-sm name="query" placeholder="#{_('Search...')}" title="#{_('Search...')}" type="text" /
+
+ #navbar-search-collapse.collapse.navbar-collapse
+ form#top-search.navbar-form.navbar-left action="/search" method="get" role="search"
+ .form-group
+ input.form-control name="query" placeholder="#{_('Search...')}" title="#{_('Search...')}" type="text" /
+
+ #navbar-user-collapse.collapse.navbar-collapse
+ ul.nav.navbar-nav.pull-right
+ - if user.present?
+ = render 'layouts/usermenu_logged_in'
+ - else
+ li
+ = modal_inline_link_to "#{_('Login')}".html_safe, login_url, '#inlineLoginBox', id: 'link_login'
+ = @plugins.dispatch(:alternative_authentication_link).collect{ |content| instance_exec(&content) }.safe_join
+ - unless @plugins.dispatch(:allow_user_registration).include? false
+ li= link_to content_tag(:strong, _('Sign up')), controller: :account, action: :signup
+
+#inlineLoginBox style="display: none;"
+ = render file: 'account/login', locals: {is_thickbox: true}
diff --git a/plugins/responsive/views/layouts/_usermenu_logged_in.html.slim b/plugins/responsive/views/layouts/_usermenu_logged_in.html.slim
new file mode 100644
index 0000000..6d3b6d5
--- /dev/null
+++ b/plugins/responsive/views/layouts/_usermenu_logged_in.html.slim
@@ -0,0 +1,39 @@
+- pending_tasks_count = Task.to(user).pending.count if user
+
+li.dropdown
+ = link_to '#', id: "homepage-link", title: _('Go to your homepage'), class: 'dropdown-toggle', data: {toggle: 'dropdown', hover: 'dropdown'}
+ = image_tag user.profile_custom_icon(gravatar_default), class: 'menu-user-gravatar'
+ = content_tag :strong, user.identifier
+ - if pending_tasks_count
+ span class='badge' onclick="document.location='#{url_for(user.tasks_url)}'" title="#{_("Manage your pending tasks")}"
+ count
+
+ ul class='dropdown-menu' role='menu'
+ li
+ = link_to user.public_profile_url, id: "homepage-link", title: _('Go to your homepage')
+ span class='icon-person' = _('Profile')
+ li.divider
+
+ /TODO
+ /= render_environment_features(:usermenu)
+
+ li = admin_link
+
+ li
+ = link_to user.admin_url, class: 'ctrl-panel', title: _("Configure your personal account and content")
+ i class='icon-menu-ctrl-panel'
+ strong = _('Control panel')
+
+ - if environment.enabled? 'xmpp_chat'
+ = responsive_chat_user_status_menu 'icon-menu-offline', _('Offline')
+
+ li = manage_enterprises
+ li = manage_communities
+
+ li.divider
+
+ li
+ = link_to({controller: 'account', action: 'logout'}, id: "logout", title: _("Leave the system"))
+ i class='icon-menu-logout'
+ strong = _('Logout')
+
diff --git a/plugins/responsive/views/layouts/application-responsive.html.erb b/plugins/responsive/views/layouts/application-responsive.html.erb
index 76184fd..ad96fd6 100644
--- a/plugins/responsive/views/layouts/application-responsive.html.erb
+++ b/plugins/responsive/views/layouts/application-responsive.html.erb
@@ -1,7 +1,7 @@
- <%= h page_title %>
+ <%= h page_title.html_safe %>
<%= yield(:feeds) %>
@@ -22,7 +22,7 @@
<%=
@plugins.dispatch(:head_ending).map do |content|
if content.respond_to?(:call) then instance_exec(&content).to_s.html_safe else content.to_s.html_safe end
- end.join("\n")
+ end.safe_join
%>