Commit 88e6388f423f8ec0dcb6e2bad2b1a87e94f61485

Authored by Braulio Bhavamitra
1 parent 72d90efd

responsive: fix html_safe issues

app/helpers/application_helper.rb
@@ -593,8 +593,8 @@ module ApplicationHelper @@ -593,8 +593,8 @@ module ApplicationHelper
593 end 593 end
594 594
595 if block 595 if block
596 - field_html ||= ''  
597 - field_html += capture(&block) 596 + field_html ||= ''.html_safe
  597 + field_html = [field_html, capture(&block)].safe_join
598 end 598 end
599 599
600 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?) 600 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 @@ -603,7 +603,9 @@ module ApplicationHelper
603 end 603 end
604 else 604 else
605 if profile.active_fields.include?(name) 605 if profile.active_fields.include?(name)
606 - result = content_tag('div', field_html + profile_field_privacy_selector(profile, name), :class => 'field-with-privacy-selector') 606 + result = content_tag :div, class: 'field-with-privacy-selector' do
  607 + [field_html, profile_field_privacy_selector(profile, name)].safe_join
  608 + end
607 end 609 end
608 end 610 end
609 611
@@ -611,10 +613,6 @@ module ApplicationHelper @@ -611,10 +613,6 @@ module ApplicationHelper
611 result = required(result) 613 result = required(result)
612 end 614 end
613 615
614 - if block  
615 - concat(result)  
616 - end  
617 -  
618 result 616 result
619 end 617 end
620 618
plugins/responsive/lib/ext/application_helper.rb
@@ -5,7 +5,7 @@ module ApplicationHelper @@ -5,7 +5,7 @@ module ApplicationHelper
5 protected 5 protected
6 6
7 module ResponsiveMethods 7 module ResponsiveMethods
8 - FORM_CONTROL_CLASS = "form-control" 8 + FORM_CONTROL_CLASS = 'form-control'
9 9
10 def button(type, label, url, html_options = {}) 10 def button(type, label, url, html_options = {})
11 return super unless theme_responsive? 11 return super unless theme_responsive?
@@ -13,15 +13,14 @@ module ApplicationHelper @@ -13,15 +13,14 @@ module ApplicationHelper
13 option = html_options.delete(:option) || 'default' 13 option = html_options.delete(:option) || 'default'
14 size = html_options.delete(:size) || 'xs' 14 size = html_options.delete(:size) || 'xs'
15 the_class = "with-text btn btn-#{size} btn-#{option} icon-#{type}" 15 the_class = "with-text btn btn-#{size} btn-#{option} icon-#{type}"
16 - if html_options.has_key?(:class)  
17 - the_class << ' ' << html_options[:class]  
18 - end  
19 - #button_without_text type, label, url, html_options.merge(:class => the_class) 16 + the_class << ' ' << html_options[:class] if html_options.has_key?(:class)
  17 +
  18 + #button_without_text type, label, url, html_options.merge(class: the_class)
20 the_title = html_options[:title] || label 19 the_title = html_options[:title] || label
21 if html_options[:disabled] 20 if html_options[:disabled]
22 - content_tag('a', content_tag('span', label), html_options.merge(class: the_class, title: the_title)) 21 + content_tag(:a, content_tag(:span, label), html_options.merge(class: the_class, title: the_title))
23 else 22 else
24 - link_to(content_tag('span', label), url, html_options.merge(class: the_class, title: the_title)) 23 + link_to(content_tag(:span, label), url, html_options.merge(class: the_class, title: the_title))
25 end 24 end
26 end 25 end
27 26
@@ -36,7 +35,7 @@ module ApplicationHelper @@ -36,7 +35,7 @@ module ApplicationHelper
36 end 35 end
37 the_title = html_options[:title] || label 36 the_title = html_options[:title] || label
38 if html_options[:disabled] 37 if html_options[:disabled]
39 - content_tag('a', '', html_options.merge(class: the_class, title: the_title)) 38 + content_tag(:a, '', html_options.merge(class: the_class, title: the_title))
40 else 39 else
41 link_to('', url, html_options.merge(class: the_class, title: the_title)) 40 link_to('', url, html_options.merge(class: the_class, title: the_title))
42 end 41 end
@@ -91,7 +90,7 @@ module ApplicationHelper @@ -91,7 +90,7 @@ module ApplicationHelper
91 if html_options.has_key?(:class) 90 if html_options.has_key?(:class)
92 the_class << ' ' << html_options[:class] 91 the_class << ' ' << html_options[:class]
93 end 92 end
94 - content_tag('div', '', html_options.merge(class: the_class)) 93 + content_tag(:div, '', html_options.merge(class: the_class))
95 end 94 end
96 95
97 def icon_button(type, text, url, html_options = {}) 96 def icon_button(type, text, url, html_options = {})
@@ -104,16 +103,21 @@ module ApplicationHelper @@ -104,16 +103,21 @@ module ApplicationHelper
104 the_class << ' ' << html_options[:class] 103 the_class << ' ' << html_options[:class]
105 end 104 end
106 105
107 - link_to(content_tag('span', text), url, html_options.merge(class: the_class, title: text)) 106 + link_to(content_tag(:span, text), url, html_options.merge(class: the_class, title: text))
108 end 107 end
109 108
110 - def button_bar(options = {}, &block) 109 + def button_bar options = {}, &block
111 return super unless theme_responsive? 110 return super unless theme_responsive?
112 111
113 - options[:class].nil? ?  
114 - options[:class]='button-bar' :  
115 - options[:class]+=' button-bar'  
116 - concat(content_tag('div', capture(&block).to_s + tag('br', style: 'clear: left;'), options)) 112 + options[:class] ||= ''
  113 + options[:class] << 'button-bar'
  114 +
  115 + content_tag :div, options do
  116 + [
  117 + capture(&block).to_s,
  118 + tag('br', style: 'clear: left;'),
  119 + ].safe_join
  120 + end
117 end 121 end
118 122
119 def expirable_button(content, action, text, url, html_options = {}) 123 def expirable_button(content, action, text, url, html_options = {})
@@ -128,143 +132,93 @@ module ApplicationHelper @@ -128,143 +132,93 @@ module ApplicationHelper
128 def search_contents_menu 132 def search_contents_menu
129 return super unless theme_responsive? 133 return super unless theme_responsive?
130 134
131 - host = environment.default_hostname  
132 -  
133 - output = '<li class="dropdown">'  
134 - output += link_to(_('Contents'), '#', :class=>"dropdown-toggle icon-menu-articles", title: _('Contents'), :'data-toggle'=>"dropdown", :'data-hover'=>"dropdown")  
135 - output += '<ul class="dropdown-menu" role="menu">'  
136 -  
137 - output += '<li>' + link_to(_('All contents'), {host: host, controller: "search", action: 'contents', category_path: ''}) + '</li>'  
138 - 135 + host = environment.default_hostname
139 links = [ 136 links = [
140 - {s_('contents|More recent') => {:href => url_for({host: host, :controller => 'search', :action => 'contents', :filter => 'more_recent'})}},  
141 - {s_('contents|More viewed') => {:href => url_for({host: host, :controller => 'search', :action => 'contents', :filter => 'more_popular'})}},  
142 - {s_('contents|Most commented') => {:href => url_for({host: host, :controller => 'search', :action => 'contents', :filter => 'more_comments'})}} 137 + [_('All contents'), {host: host, controller: :search, action: :contents, category_path: ''}],
  138 + [s_('contents|More recent'), {host: host, controller: :search, action: :contents, filter: 'more_recent'}],
  139 + [s_('contents|More viewed'), {host: host, controller: :search, action: :contents, filter: 'more_popular'}],
  140 + [s_('contents|Most commented'), {host: host, controller: :search, action: :contents, filter: 'more_comments'}],
143 ] 141 ]
144 if logged_in? 142 if logged_in?
145 - links.push(_('New content') => modal_options({href: url_for({controller: 'cms', action: 'new', profile: current_user.login, cms: true})})) 143 + links.push [_('New content'), '', modal_options({href: url_for({controller: 'cms', action: 'new', profile: current_user.login, cms: true})})]
146 end 144 end
147 145
148 - links.each do |link|  
149 - link.each do |name, options|  
150 - output += content_tag(:li,content_tag(:a,name,options))  
151 - end 146 + content_tag :li, class: 'dropdown' do
  147 + [
  148 + link_to('#', class: 'dropdown-toggle icon-menu-articles', title: _('Contents'), data: {toggle: 'dropdown', hover: 'dropdown'}) do
  149 + content_tag :span, _('Contents')
  150 + end,
  151 + content_tag(:ul, class: 'dropdown-menu', role: 'menu') do
  152 + links.map do |(name, url)|
  153 + content_tag :li do
  154 + link_to name, url
  155 + end
  156 + end.safe_join
  157 + end,
  158 + ].safe_join
152 end 159 end
153 -  
154 - output += '</ul>'  
155 - output += '</li>'  
156 - output  
157 end 160 end
158 161
159 def search_people_menu 162 def search_people_menu
160 return super unless theme_responsive? 163 return super unless theme_responsive?
161 164
162 - host = environment.default_hostname  
163 -  
164 - output = '<li class="dropdown">'  
165 - output += link_to(_('People'), '#', :class=>"dropdown-toggle icon-menu-people", title: _('People'), :'data-toggle'=>"dropdown", :'data-hover'=>"dropdown")  
166 - output += '<ul class="dropdown-menu" role="menu">'  
167 -  
168 - output += '<li>' + link_to(_('All people'), {host: host, controller: "search", action: 'people', category_path: ''}) + '</li>'  
169 - 165 + host = environment.default_hostname
170 links = [ 166 links = [
171 - {s_('people|More recent') => {:href => url_for({host: host, :controller => 'search', :action => 'people', :filter => 'more_recent'})}},  
172 - {s_('people|More active') => {:href => url_for({host: host, :controller => 'search', :action => 'people', :filter => 'more_active'})}},  
173 - {s_('people|More popular') => {:href => url_for({host: host, :controller => 'search', :action => 'people', :filter => 'more_popular'})}} 167 + [_('All people'), {host: host, controller: :search, action: :people, category_path: ''}],
  168 + [s_('people|More recent'), {host: host, controller: :search, action: :people, filter: 'more_recent'}],
  169 + [s_('people|More active'), {host: host, controller: :search, action: :people, filter: 'more_active'}],
  170 + [s_('people|More popular'), {host: host, controller: :search, action: :people, filter: 'more_popular'}],
174 ] 171 ]
175 if logged_in? 172 if logged_in?
176 - links.push(_('My friends') => {href: url_for({profile: current_user.login, controller: 'friends'})})  
177 - links.push(_('Invite friends') => {href: url_for({profile: current_user.login, controller: 'invite', action: 'friends'})}) 173 + links.push [_('My friends'), {profile: current_user.login, controller: 'friends'}]
  174 + links.push [_('Invite friends'), {profile: current_user.login, controller: 'invite', action: 'friends'}]
178 end 175 end
179 176
180 - links.each do |link|  
181 - link.each do |name, url|  
182 - output += '<li><a href="'+url[:href]+'">' + name + '</a></li>'  
183 - end 177 + content_tag :li, class: 'dropdown' do
  178 + [
  179 + link_to('#', class: "dropdown-toggle icon-menu-people", title: _('People'), data: {toggle: 'dropdown', hover: 'dropdown'}) do
  180 + content_tag :span, _('People')
  181 + end,
  182 + content_tag(:ul, class: 'dropdown-menu', role: 'menu') do
  183 + links.map do |params|
  184 + content_tag :li do
  185 + link_to *params
  186 + end
  187 + end.safe_join
  188 + end
  189 + ].safe_join
184 end 190 end
185 -  
186 - output += '</ul>'  
187 - output += '</li>'  
188 - output  
189 end 191 end
190 192
191 def search_communities_menu 193 def search_communities_menu
192 return super unless theme_responsive? 194 return super unless theme_responsive?
193 195
194 - host = environment.default_hostname  
195 -  
196 - output = '<li class="dropdown">'  
197 - output += link_to(_('Communities'), '#', :class=>"dropdown-toggle icon-menu-community", title: _('Communities'), :'data-toggle'=>"dropdown", :'data-hover'=>"dropdown")  
198 - output += '<ul class="dropdown-menu" role="menu">'  
199 -  
200 - output += '<li>' + link_to(_('All communities'), {host: host, controller: "search", action: 'communities', category_path: ''}) + '</li>'  
201 - 196 + host = environment.default_hostname
202 links = [ 197 links = [
203 - {s_('communities|More recent') => {:href => url_for({host: host, :controller => 'search', :action => 'communities', :filter => 'more_recent'})}},  
204 - {s_('communities|More active') => {:href => url_for({host: host, :controller => 'search', :action => 'communities', :filter => 'more_active'})}},  
205 - {s_('communities|More popular') => {:href => url_for({host: host, :controller => 'search', :action => 'communities', :filter => 'more_popular'})}} 198 + [_('All communities'), {host: host, controller: :search, action: :communities, category_path: ''}],
  199 + [s_('communities|More recent'), {host: host, controller: :search, action: :communities, filter: 'more_recent'}],
  200 + [s_('communities|More active'), {host: host, controller: :search, action: :communities, filter: 'more_active'}],
  201 + [s_('communities|More popular'), {host: host, controller: :search, action: :communities, filter: 'more_popular'}],
206 ] 202 ]
207 if logged_in? 203 if logged_in?
208 - links.push(_('My communities') => {href: url_for({profile: current_user.login, controller: 'memberships'})})  
209 - links.push(_('New community') => {href: url_for({profile: current_user.login, controller: 'memberships', action: 'new_community'})}) 204 + links.push [_('My communities'), {profile: current_user.login, controller: 'memberships'}]
  205 + links.push [_('New community'), {profile: current_user.login, controller: 'memberships', action: 'new_community'}]
210 end 206 end
211 207
212 - links.each do |link|  
213 - link.each do |name, url|  
214 - output += '<li><a href="'+url[:href]+'">' + name + '</a></li>'  
215 - end  
216 - end  
217 -  
218 - output += '</ul>'  
219 - output += '</li>'  
220 - output  
221 - end  
222 -  
223 - def usermenu_logged_in  
224 - return super unless theme_responsive?  
225 -  
226 - output = '<li class="dropdown">'  
227 -  
228 - pending_tasks_count = ''  
229 - count = user ? Task.to(user).pending.count : -1  
230 - if count > 0  
231 - pending_tasks_count = "<span class=\"badge\" onclick=\"document.location='#{url_for(user.tasks_url)}'\" title=\"#{_("Manage your pending tasks")}\">" + count.to_s + '</span>' 208 + content_tag :li, class: 'dropdown' do
  209 + [
  210 + link_to('#', class: 'dropdown-toggle icon-menu-community', title: _('Communities'), data: {toggle: 'dropdown', hover: 'dropdown'}) do
  211 + content_tag :span, _('Communities')
  212 + end,
  213 + content_tag(:ul, class: 'dropdown-menu', role: 'menu') do
  214 + links.map do |params|
  215 + content_tag :li do
  216 + link_to *params
  217 + end
  218 + end.safe_join
  219 + end
  220 + ].safe_join
232 end 221 end
233 -  
234 - output += link_to("<img class=\"menu-user-gravatar\" src=\"#{user.profile_custom_icon(gravatar_default)}\"><strong>#{user.identifier}</strong> #{pending_tasks_count}", '#', id: "homepage-link", title: _('Go to your homepage'), :class=>"dropdown-toggle", :'data-toggle'=>"dropdown", :'data-target'=>"", :'data-hover'=>"dropdown")  
235 -  
236 -  
237 - output += '<ul class="dropdown-menu" role="menu">'  
238 - output += '<li>' + link_to('<span class="icon-person">'+_('Profile')+'</span>', user.public_profile_url, id: "homepage-link", title: _('Go to your homepage')) + '</li>'  
239 -  
240 - output += '<li class="divider"></li>'  
241 -  
242 - #TODO  
243 - #render_environment_features(:usermenu) +  
244 -  
245 - #admin_link  
246 - admin_link_str = admin_link  
247 - output += admin_link_str.present? ? '<li>' + admin_link_str + '</li>' : ''  
248 -  
249 - #control_panel link  
250 - output += '<li>' + link_to('<i class="icon-menu-ctrl-panel"></i><strong>' + _('Control panel') + '</strong>', user.admin_url, class: 'ctrl-panel', title: _("Configure your personal account and content")) + '</li>'  
251 -  
252 - output += chat_user_status_menu('icon-menu-offline', _('Offline'))  
253 -  
254 - #manage_enterprises  
255 - manage_enterprises_str = manage_enterprises  
256 - output += manage_enterprises_str.present? ? '<li>' + manage_enterprises_str + '</li>' : ''  
257 -  
258 - #manage_communities  
259 - manage_communities_str = manage_communities  
260 - output += manage_communities_str.present? ? '<li>' + manage_communities_str + '</li>' : ''  
261 -  
262 - output += '<li class="divider"></li>'  
263 -  
264 - output += '<li>' + link_to('<i class="icon-menu-logout"></i><strong>' + _('Logout') + '</strong>', { controller: 'account', action: 'logout'} , id: "logout", title: _("Leave the system")) + '</li>'  
265 -  
266 - output += '</ul>'  
267 - output  
268 end 222 end
269 223
270 def manage_link(list, kind, title) 224 def manage_link(list, kind, title)
@@ -274,17 +228,22 @@ module ApplicationHelper @@ -274,17 +228,22 @@ module ApplicationHelper
274 link_to_all = nil 228 link_to_all = nil
275 if list.count > 5 229 if list.count > 5
276 list = list.first(5) 230 list = list.first(5)
277 - link_to_all = link_to(content_tag('strong', _('See all')), :controller => 'memberships', :profile => user.identifier) 231 + link_to_all = link_to(content_tag(:strong, _('See all')), controller: 'memberships', profile: user.identifier)
278 end 232 end
279 link = list.map do |element| 233 link = list.map do |element|
280 - 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) 234 + 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)
281 end 235 end
282 if link_to_all 236 if link_to_all
283 link << link_to_all 237 link << link_to_all
284 end 238 end
285 - content_tag('li', nil, class: 'divider') +  
286 - content_tag('li', title, class: 'dropdown-header') +  
287 - link.map{ |l| content_tag 'li', l }.join 239 +
  240 + [
  241 + content_tag(:li, nil, class: 'divider'),
  242 + content_tag(:li, title, class: 'dropdown-header'),
  243 + link.map do |l|
  244 + content_tag :li, l
  245 + end.safe_join
  246 + ].safe_join
288 end 247 end
289 end 248 end
290 249
@@ -301,15 +260,24 @@ module ApplicationHelper @@ -301,15 +260,24 @@ module ApplicationHelper
301 unless html_options[:style].present? and html_options[:style] =~ /display *: *none/ 260 unless html_options[:style].present? and html_options[:style] =~ /display *: *none/
302 menu_content << '<br/>' unless first 261 menu_content << '<br/>' unless first
303 first = false 262 first = false
304 - menu_content << content_tag(:a,link_label,html_options) 263 + menu_content << content_tag(:a, link_label,html_options)
305 end 264 end
306 end 265 end
307 end 266 end
308 end 267 end
309 268
310 option = html_options.delete(:option) || 'default' 269 option = html_options.delete(:option) || 'default'
311 - size = html_options.delete(:size) || 'xs'  
312 - "<button class='btn btn-#{size} btn-#{option} btn-popover-menu icon-parent-folder' data-toggle='popover' data-html='true' data-placement='top' data-trigger='focus' data-content=\""+CGI::escapeHTML(menu_content)+'" data-title="'+menu_title+'"></button>' 270 + size = html_options.delete(:size) || 'xs'
  271 + button_tag '',
  272 + class: "btn btn-#{size} btn-#{option} btn-popover-menu icon-parent-folder",
  273 + data: {
  274 + html: 'true',
  275 + toggle: 'popover',
  276 + placement: 'top',
  277 + trigger: 'focus',
  278 + content: menu_content,
  279 + title: menu_title,
  280 + }
313 end 281 end
314 282
315 283
@@ -406,12 +374,7 @@ module ApplicationHelper @@ -406,12 +374,7 @@ module ApplicationHelper
406 end 374 end
407 375
408 include ResponsiveChecks 376 include ResponsiveChecks
409 - if RUBY_VERSION >= '2.0.0'  
410 - prepend ResponsiveMethods  
411 - else  
412 - extend ActiveSupport::Concern  
413 - included { include ResponsiveMethods }  
414 - end 377 + prepend ResponsiveMethods
415 378
416 # TODO: apply theme_responsive? condition 379 # TODO: apply theme_responsive? condition
417 class NoosferoFormBuilder 380 class NoosferoFormBuilder
@@ -440,13 +403,16 @@ module ApplicationHelper @@ -440,13 +403,16 @@ module ApplicationHelper
440 403
441 if options[:horizontal] 404 if options[:horizontal]
442 label_html = content_tag :label, gettext(text), class: 'control-label col-sm-3 col-md-2 col-lg-2', for: field_id 405 label_html = content_tag :label, gettext(text), class: 'control-label col-sm-3 col-md-2 col-lg-2', for: field_id
443 - result = content_tag :div, label_html + content_tag('div',field_html, class: 'col-sm-9 col-md-6 col-lg-6'), class: 'form-group' 406 + content = [
  407 + label_html,
  408 + content_tag(:div, field_html.html_safe, class: 'col-sm-9 col-md-6 col-lg-6'),
  409 + ].safe_join
  410 + content_tag :div, content, class: 'form-group'
444 else 411 else
445 label_html = content_tag :label, gettext(text), class: 'control-label', for: field_id 412 label_html = content_tag :label, gettext(text), class: 'control-label', for: field_id
446 - result = content_tag :div, label_html + field_html, class: 'form-group' 413 + content = [label_html, field_html.html_safe].safe_join
  414 + content_tag :div, content, class: 'form-group'
447 end 415 end
448 -  
449 - result  
450 end 416 end
451 end 417 end
452 418
plugins/responsive/lib/ext/boxes_helper.rb
@@ -62,12 +62,16 @@ module BoxesHelper @@ -62,12 +62,16 @@ module BoxesHelper
62 end 62 end
63 63
64 include ResponsiveChecks 64 include ResponsiveChecks
  65 +<<<<<<< HEAD
65 if RUBY_VERSION >= '2.0.0' 66 if RUBY_VERSION >= '2.0.0'
66 prepend ResponsiveMethods 67 prepend ResponsiveMethods
67 else 68 else
68 extend ActiveSupport::Concern 69 extend ActiveSupport::Concern
69 included { include ResponsiveMethods } 70 included { include ResponsiveMethods }
70 end 71 end
  72 +=======
  73 + prepend ResponsiveMethods
  74 +>>>>>>> 2ef3a43... responsive: fix html_safe issues
71 75
72 end 76 end
73 77
plugins/responsive/lib/ext/chat_helper.rb
@@ -23,12 +23,7 @@ module ChatHelper @@ -23,12 +23,7 @@ module ChatHelper
23 end 23 end
24 24
25 include ResponsiveChecks 25 include ResponsiveChecks
26 - if RUBY_VERSION >= '2.0.0'  
27 - prepend ResponsiveMethods  
28 - else  
29 - extend ActiveSupport::Concern  
30 - included { include ResponsiveMethods }  
31 - end 26 + prepend ResponsiveMethods
32 27
33 end 28 end
34 29
plugins/responsive/lib/ext/forms_helper.rb
@@ -11,8 +11,20 @@ module FormsHelper @@ -11,8 +11,20 @@ module FormsHelper
11 return super unless theme_responsive? 11 return super unless theme_responsive?
12 12
13 options[:id] ||= 'radio-' + FormsHelper.next_id_number 13 options[:id] ||= 'radio-' + FormsHelper.next_id_number
  14 +<<<<<<< HEAD
14 content_tag( 'label', radio_button_tag( name, value, checked, options ) + ' ' + 15 content_tag( 'label', radio_button_tag( name, value, checked, options ) + ' ' +
15 human_name, for: options[:id], class: 'radio-inline' ) 16 human_name, for: options[:id], class: 'radio-inline' )
  17 +=======
  18 + content_tag :div, class:'radio-inline' do
  19 + content_tag :label, for: options[:id] do
  20 + [
  21 + radio_button_tag(name, value, checked, options),
  22 + ' ',
  23 + human_name,
  24 + ].safe_join
  25 + end
  26 + end
  27 +>>>>>>> 2ef3a43... responsive: fix html_safe issues
16 end 28 end
17 29
18 # add -inline class 30 # add -inline class
@@ -20,8 +32,23 @@ module FormsHelper @@ -20,8 +32,23 @@ module FormsHelper
20 return super unless theme_responsive? 32 return super unless theme_responsive?
21 33
22 options[:id] ||= 'checkbox-' + FormsHelper.next_id_number 34 options[:id] ||= 'checkbox-' + FormsHelper.next_id_number
  35 +<<<<<<< HEAD
23 hidden_field_tag(name, '0') + 36 hidden_field_tag(name, '0') +
24 content_tag( 'label', check_box_tag( name, value, checked, options ) + ' ' + human_name, for: options[:id], class: 'checkbox-inline') 37 content_tag( 'label', check_box_tag( name, value, checked, options ) + ' ' + human_name, for: options[:id], class: 'checkbox-inline')
  38 +=======
  39 + [
  40 + hidden_field_tag(name, '0'),
  41 + content_tag(:div, class:'checkbox-inline') do
  42 + content_tag :label, for: options[:id] do
  43 + [
  44 + check_box_tag(name, value, checked, options),
  45 + ' ',
  46 + human_name,
  47 + ].safe_join
  48 + end
  49 + end
  50 + ].safe_join
  51 +>>>>>>> 2ef3a43... responsive: fix html_safe issues
25 end 52 end
26 53
27 def submit_button(type, label, html_options = {}) 54 def submit_button(type, label, html_options = {})
@@ -42,10 +69,17 @@ module FormsHelper @@ -42,10 +69,17 @@ module FormsHelper
42 69
43 html_options.delete(:cancel) 70 html_options.delete(:cancel)
44 bt_submit = button_tag(label, html_options.merge(class: the_class)) 71 bt_submit = button_tag(label, html_options.merge(class: the_class))
  72 +<<<<<<< HEAD
  73 +=======
  74 +
  75 + [bt_submit + bt_cancel].safe_join
  76 + end
  77 +>>>>>>> 2ef3a43... responsive: fix html_safe issues
45 78
46 bt_submit + bt_cancel 79 bt_submit + bt_cancel
47 end 80 end
48 81
  82 +<<<<<<< HEAD
49 %w[select select_tag text_field_tag number_field_tag password_field_tag].each do |method| 83 %w[select select_tag text_field_tag number_field_tag password_field_tag].each do |method|
50 define_method method do |*args, &block| 84 define_method method do |*args, &block|
51 #return super(*args, &block) unless theme_responsive? 85 #return super(*args, &block) unless theme_responsive?
@@ -57,28 +91,39 @@ module FormsHelper @@ -57,28 +91,39 @@ module FormsHelper
57 options[:class] = "#{options[:class]} form-control" 91 options[:class] = "#{options[:class]} form-control"
58 end 92 end
59 super(*(args << options), &block) 93 super(*(args << options), &block)
  94 +=======
  95 + %w[
  96 + select_tag
  97 + text_field_tag text_area_tag
  98 + number_field_tag password_field_tag url_field_tag email_field_tag
  99 + month_field_tag date_field_tag
  100 + ].each do |method|
  101 + define_method method do |name, value=nil, options={}, &block|
  102 + responsive_add_field_class! options
  103 + super(name, value, options, &block).html_safe
  104 +>>>>>>> 2ef3a43... responsive: fix html_safe issues
60 end 105 end
61 end 106 end
62 %w[select_month select_year].each do |method| 107 %w[select_month select_year].each do |method|
63 define_method method do |date, options={}, html_options={}| 108 define_method method do |date, options={}, html_options={}|
  109 +<<<<<<< HEAD
64 if html_options['class'] 110 if html_options['class']
65 html_options['class'] = "#{html_options['class']} form-control" 111 html_options['class'] = "#{html_options['class']} form-control"
66 else 112 else
67 html_options[:class] = "#{html_options[:class]} form-control" 113 html_options[:class] = "#{html_options[:class]} form-control"
68 end 114 end
69 super date, options, html_options 115 super date, options, html_options
  116 +=======
  117 + responsive_add_field_class! html_options
  118 + super(date, options, html_options).html_safe
  119 +>>>>>>> 2ef3a43... responsive: fix html_safe issues
70 end 120 end
71 end 121 end
72 122
73 end 123 end
74 124
75 include ResponsiveChecks 125 include ResponsiveChecks
76 - if RUBY_VERSION >= '2.0.0'  
77 - prepend ResponsiveMethods  
78 - else  
79 - extend ActiveSupport::Concern  
80 - included { include ResponsiveMethods }  
81 - end 126 + prepend ResponsiveMethods
82 127
83 end 128 end
84 129
plugins/responsive/lib/ext/input_helper.rb
@@ -4,16 +4,29 @@ module InputHelper @@ -4,16 +4,29 @@ module InputHelper
4 protected 4 protected
5 5
6 def input_group_addon addon, options = {}, &block 6 def input_group_addon addon, options = {}, &block
  7 +<<<<<<< HEAD
7 content_tag :div, 8 content_tag :div,
8 content_tag(:span, addon, class: 'input-group-addon') + yield, 9 content_tag(:span, addon, class: 'input-group-addon') + yield,
9 class: 'input-group' 10 class: 'input-group'
  11 +=======
  12 + content_tag :div, class: 'input-group' do
  13 + [
  14 + content_tag(:span, addon, class: 'input-group-addon'),
  15 + capture(&block),
  16 + ].safe_join
  17 + end
  18 +>>>>>>> 2ef3a43... responsive: fix html_safe issues
10 end 19 end
11 20
12 end 21 end
13 22
  23 +<<<<<<< HEAD
14 module ApplicationHelper 24 module ApplicationHelper
15 25
16 include InputHelper 26 include InputHelper
17 27
18 end 28 end
  29 +=======
  30 +ApplicationHelper.include InputHelper
  31 +>>>>>>> 2ef3a43... responsive: fix html_safe issues
19 32
plugins/responsive/lib/responsive_plugin.rb
@@ -13,7 +13,7 @@ class ResponsivePlugin &lt; Noosfero::Plugin @@ -13,7 +13,7 @@ class ResponsivePlugin &lt; Noosfero::Plugin
13 end 13 end
14 14
15 def head_ending 15 def head_ending
16 - '<meta name="viewport" content="width=device-width, initial-scale=1">' 16 + '<meta name="viewport" content="width=device-width, initial-scale=1">'.html_safe
17 end 17 end
18 18
19 def body_ending 19 def body_ending
plugins/responsive/views/layouts/_menu_responsive.html.erb
@@ -1,71 +0,0 @@ @@ -1,71 +0,0 @@
1 -<div>  
2 -<nav id="top-bar" class="navbar navbar-default" role="navigation">  
3 - <div class="container">  
4 - <!-- Brand and toggle get grouped for better mobile display -->  
5 - <div class="navbar-header">  
6 - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-user-collapse">  
7 - <span class="sr-only"><%= _('User menu') %></span>  
8 - <span class="fa fa-user navbar-toggle-icon"></span>  
9 - </button>  
10 - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-search-collapse">  
11 - <span class="sr-only"><%= _('Search') %></span>  
12 - <span class="fa fa-search navbar-toggle-icon"></span>  
13 - </button>  
14 - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-navigation-collapse">  
15 - <span class="sr-only"><%= _('Navigation') %></span>  
16 - <span class="icon-bar"></span>  
17 - <span class="icon-bar"></span>  
18 - <span class="icon-bar"></span>  
19 - </button>  
20 -  
21 - </div>  
22 -  
23 - <!-- Collect the nav links, forms, and other content for toggling -->  
24 - <div class="collapse navbar-collapse" id="navbar-navigation-collapse">  
25 - <ul class="nav navbar-nav menu-navigation">  
26 - <%= theme_extra_navigation %>  
27 - <li class="dropdown" id="search-dropdown-menu">  
28 - <a href="#" class="dropdown-toggle icon-search" data-hover="dropdown" data-toggle="dropdown" title="<%= _('Search') %>"><span><%= _('Search') %></span></a>  
29 - <ul class="dropdown-menu" role="menu">  
30 - <li>  
31 - <form action="/search" id="top-search" method="get" role="search">  
32 - <div class="form-group col-lg-12 col-md-12 col-sm-12">  
33 - <input name="query" title="<%=_('Search...')%>" placeholder="<%=_('Search...')%>" type="text" class="form-control input-sm"/>  
34 - </div>  
35 - </form>  
36 - </li>  
37 - </ul>  
38 - </li>  
39 - </ul>  
40 - </div>  
41 - <div class="collapse navbar-collapse" id="navbar-search-collapse">  
42 - <form action="/search" id="top-search" class="navbar-form navbar-left" method="get" role="search">  
43 - <div class="form-group">  
44 - <input name="query" title="<%=_('Search...')%>" placeholder="<%=_('Search...')%>" type="text" class="form-control"/>  
45 - </div>  
46 - </form>  
47 - </div>  
48 - <div class="collapse navbar-collapse" id="navbar-user-collapse">  
49 - <ul class="nav navbar-nav pull-right">  
50 - <% if user.present? %>  
51 - <%= usermenu_logged_in %>  
52 - <% else %>  
53 - <li>  
54 - <%= modal_inline_link_to('<i class="icon-menu-login"></i><strong>' + _('Login') + '</strong>', login_url, '#inlineLoginBox', :id => 'link_login') %>  
55 - <%= @plugins.dispatch(:alternative_authentication_link).collect { |content| instance_exec(&content) }.join("") #TODO review this  
56 - %>  
57 - </li>  
58 - <% unless @plugins.dispatch(:allow_user_registration).include?(false) %>  
59 - <li>  
60 - <%= link_to('<strong>' + _('Sign up') + '</strong>', :controller => 'account', :action => 'signup')%>  
61 - </li>  
62 - <% end %>  
63 - <% end %>  
64 - </ul>  
65 - </div><!-- /.navbar-collapse -->  
66 - </div><!-- /.container-fluid -->  
67 -</nav>  
68 -</div>  
69 -<div id='inlineLoginBox' style='display: none;'>  
70 - <%= render :file => 'account/login', :locals => { :is_thickbox => true } %>  
71 -</div>  
plugins/responsive/views/layouts/_menu_responsive.html.slim 0 → 100644
@@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
  1 +div
  2 + nav#top-bar.navbar.navbar-default.navbar-static-top role="navigation"
  3 + .container
  4 + /! Brand and toggle get grouped for better mobile display
  5 + .navbar-header
  6 + button.navbar-toggle data-target="#navbar-user-collapse" data-toggle="collapse" type="button"
  7 + span.sr-only= _('User menu')
  8 + span.fa.fa-user.navbar-toggle-icon
  9 +
  10 + button.navbar-toggle data-target="#navbar-search-collapse" data-toggle="collapse" type="button"
  11 + span.sr-only= _('Search')
  12 + span.fa.fa-search.navbar-toggle-icon
  13 +
  14 + button.navbar-toggle data-target="#navbar-navigation-collapse" data-toggle="collapse" type="button"
  15 + span.sr-only= _('Navigation')
  16 + span.icon-bar
  17 + span.icon-bar
  18 + span.icon-bar
  19 + a.navbar-brand href="#{environment.top_url}"
  20 + = theme_site_title
  21 + span#navbar-brand-site-title
  22 + = h @environment.name
  23 +
  24 + /! Collect the nav links, forms, and other content for toggling
  25 + #navbar-navigation-collapse.collapse.navbar-collapse
  26 + ul.nav.navbar-nav.menu-navigation
  27 + = theme_extra_navigation
  28 + li#search-dropdown-menu.dropdown
  29 + a.dropdown-toggle.icon-search data-hover="dropdown" data-toggle="dropdown" href="#" title="#{_('Search')}"
  30 + span= _('Search')
  31 + ul.dropdown-menu role="menu"
  32 + li
  33 + form#top-search action="/search" method="get" role="search"
  34 + .form-group.col-lg-12.col-md-12.col-sm-12
  35 + input.form-control.input-sm name="query" placeholder="#{_('Search...')}" title="#{_('Search...')}" type="text" /
  36 +
  37 + #navbar-search-collapse.collapse.navbar-collapse
  38 + form#top-search.navbar-form.navbar-left action="/search" method="get" role="search"
  39 + .form-group
  40 + input.form-control name="query" placeholder="#{_('Search...')}" title="#{_('Search...')}" type="text" /
  41 +
  42 + #navbar-user-collapse.collapse.navbar-collapse
  43 + ul.nav.navbar-nav.pull-right
  44 + - if user.present?
  45 + = render 'layouts/usermenu_logged_in'
  46 + - else
  47 + li
  48 + = modal_inline_link_to "<i class='icon-menu-login'></i><strong>#{_('Login')}</strong>".html_safe, login_url, '#inlineLoginBox', id: 'link_login'
  49 + = @plugins.dispatch(:alternative_authentication_link).collect{ |content| instance_exec(&content) }.safe_join
  50 + - unless @plugins.dispatch(:allow_user_registration).include? false
  51 + li= link_to content_tag(:strong, _('Sign up')), controller: :account, action: :signup
  52 +
  53 +#inlineLoginBox style="display: none;"
  54 + = render file: 'account/login', locals: {is_thickbox: true}
plugins/responsive/views/layouts/_usermenu_logged_in.html.slim 0 → 100644
@@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
  1 +- pending_tasks_count = Task.to(user).pending.count if user
  2 +
  3 +li.dropdown
  4 + = link_to '#', id: "homepage-link", title: _('Go to your homepage'), class: 'dropdown-toggle', data: {toggle: 'dropdown', hover: 'dropdown'}
  5 + = image_tag user.profile_custom_icon(gravatar_default), class: 'menu-user-gravatar'
  6 + = content_tag :strong, user.identifier
  7 + - if pending_tasks_count
  8 + span class='badge' onclick="document.location='#{url_for(user.tasks_url)}'" title="#{_("Manage your pending tasks")}"
  9 + count
  10 +
  11 + ul class='dropdown-menu' role='menu'
  12 + li
  13 + = link_to user.public_profile_url, id: "homepage-link", title: _('Go to your homepage')
  14 + span class='icon-person' = _('Profile')
  15 + li.divider
  16 +
  17 + /TODO
  18 + /= render_environment_features(:usermenu)
  19 +
  20 + li = admin_link
  21 +
  22 + li
  23 + = link_to user.admin_url, class: 'ctrl-panel', title: _("Configure your personal account and content")
  24 + i class='icon-menu-ctrl-panel'
  25 + strong = _('Control panel')
  26 +
  27 + - if environment.enabled? 'xmpp_chat'
  28 + = responsive_chat_user_status_menu 'icon-menu-offline', _('Offline')
  29 +
  30 + li = manage_enterprises
  31 + li = manage_communities
  32 +
  33 + li.divider
  34 +
  35 + li
  36 + = link_to({controller: 'account', action: 'logout'}, id: "logout", title: _("Leave the system"))
  37 + i class='icon-menu-logout'
  38 + strong = _('Logout')
  39 +
plugins/responsive/views/layouts/application-responsive.html.erb
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= html_language %>" lang="<%= html_language %>" class="<%= h html_tag_classes %>"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= html_language %>" lang="<%= html_language %>" class="<%= h html_tag_classes %>">
3 <head> 3 <head>
4 - <title><%= h page_title %></title> 4 + <title><%= h page_title.html_safe %></title>
5 <%= yield(:feeds) %> 5 <%= yield(:feeds) %>
6 <!--<meta http-equiv="refresh" content="1"/>--> 6 <!--<meta http-equiv="refresh" content="1"/>-->
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 <%= 22 <%=
23 @plugins.dispatch(:head_ending).map do |content| 23 @plugins.dispatch(:head_ending).map do |content|
24 if content.respond_to?(:call) then instance_exec(&content).to_s.html_safe else content.to_s.html_safe end 24 if content.respond_to?(:call) then instance_exec(&content).to_s.html_safe else content.to_s.html_safe end
25 - end.join("\n") 25 + end.safe_join
26 %> 26 %>
27 27
28 <script type="text/javascript"> 28 <script type="text/javascript">
@@ -68,7 +68,7 @@ @@ -68,7 +68,7 @@
68 <%= 68 <%=
69 @plugins.dispatch(:body_ending).map do |content| 69 @plugins.dispatch(:body_ending).map do |content|
70 if content.respond_to?(:call) then instance_exec(&content).html_safe else content.html_safe end 70 if content.respond_to?(:call) then instance_exec(&content).html_safe else content.html_safe end
71 - end.join("\n") 71 + end.safe_join
72 %> 72 %>
73 </body> 73 </body>
74 </html> 74 </html>