diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4061d12ec..b161c515f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -9,6 +9,38 @@ module ApplicationHelper false end + def aspects_with_post aspects, post + aspects.select do |a| + post.aspect_ids.include?(a.id) + end + end + def aspects_without_post aspects, post + aspects.reject do |a| + post.aspect_ids.include?(a.id) + end + end + def aspect_links aspects, opts={} + str = "" + aspects.each do |a| + str << aspect_li(a, opts) + end + str.html_safe + end + def aspect_li aspect, opts= {} + param_string = "" + if opts.size > 0 + param_string << '?' + opts.each_pair do |k,v| + param_string << "#{k}=#{v}" + end + end +"
  • + + #{aspect.name} + +
  • ".html_safe + end + def current_aspect?(aspect) !@aspect.nil? && !@aspect.is_a?(Symbol) && @aspect.id == aspect.id end diff --git a/app/views/shared/_reshare.haml b/app/views/shared/_reshare.haml index 092dccabe..15134ea6a 100644 --- a/app/views/shared/_reshare.haml +++ b/app/views/shared/_reshare.haml @@ -7,6 +7,5 @@ = link_to t('.reshare'), "#" %ul.reshare_box - - for aspect in aspects - %li.aspect_to_share= link_to aspect, :controller => "aspects", :action => "show", :id => aspect.id, :prefill => post.message + =aspect_links(aspects, :prefill => post.message) diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 72c3521e2..b6a18cd40 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -17,14 +17,12 @@ - if post.public? %li= t('the_world') - else - - for aspect in aspects.select{|a| post.aspect_ids.include?(a.id)} - %li - %a{:href => "/aspects/#{aspect.id}"}=aspect.name + =aspect_links(aspects_with_post(aspects, post)) .right - - reshare_aspects = aspects.reject{|a| post.aspect_ids.include?(a.id)} + - reshare_aspects = aspects_without_post(aspects, post) - unless reshare_aspects.empty? - = render 'shared/reshare', :current_user => current_user, :aspects => aspects, :post => post + = render 'shared/reshare', :current_user => current_user, :aspects => reshare_aspects, :post => post = link_to t('delete'), status_message_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete" = render 'status_messages/status_message', :post => post, :photos => post.photos