# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module AspectGlobalHelper
def aspects_with_post(aspects, post)
aspects.select do |aspect|
AspectVisibility.exists?(:aspect_id => aspect.id, :post_id => post.id)
end
end
def aspects_without_post(aspects, post)
aspects.reject do |aspect|
AspectVisibility.exists?(:aspect_id => aspect.id, :post_id => post.id)
end
end
def aspect_badges(aspects, opts={})
str = ''
aspects.each do |aspect|
str << aspect_badge(aspect, opts)
end
str.html_safe
end
def aspect_badge(aspect, opts={})
str = ""
link = opts.delete(:link)
if !link
str << link_to(aspect.name, "#", 'data-guid' => aspect.id, :class => 'hard_aspect_link').html_safe
else
str << link_for_aspect(aspect).html_safe
end
str << ""
end
def aspect_links(aspects, opts={})
str = ""
aspects.each do |aspect|
str << '
'
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
"