Skip to content
Extraits de code Groupes Projets
application_helper.rb 2,05 ko
Newer Older
#    Copyright 2010 Diaspora Inc.
#
#    This file is part of Diaspora.
#
#    Diaspora is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Diaspora is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with Diaspora.  If not, see <http://www.gnu.org/licenses/>.
#


Raphael Sofaer's avatar
Raphael Sofaer a validé
module ApplicationHelper
Raphael's avatar
Raphael a validé
  def current_aspect?(aspect)
    !@aspect.is_a?(Symbol) && @aspect.id == aspect.id
  def object_path(object, opts = {})
    eval("#{object.class.to_s.underscore}_path(object, opts)")
  
  def type_partial(post)
    class_name = post.class.name.to_s.underscore
    "#{class_name.pluralize}/#{class_name}"
  end
maxwell's avatar
maxwell a validé
  
  def how_long_ago(obj)
    "#{time_ago_in_words(obj.created_at)} ago."
maxwell's avatar
maxwell a validé
  end

  def person_url(person)
    case person.class.to_s
    when "User"
      user_path(person)
  def owner_image_tag
    person_image_tag(current_user)
  end

  def owner_image_link
    person_image_link(current_user)
danielvincent's avatar
danielvincent a validé

  def person_image_tag(person)
    image_location = person.profile.image_url
    image_location ||= "/images/user/default.jpg"

Raphael's avatar
Raphael a validé
    image_tag image_location, :class => "avatar", :alt => person.real_name, :title => person.real_name
  end

  def person_image_link(person)
    link_to person_image_tag(person), object_path(person)
  end

  def new_request(request_count)
    "new_requests" if request_count > 0
  end
  
  def post_yield_tag(post)
    (':' + post.id.to_s).to_sym
  end
Raphael Sofaer's avatar
Raphael Sofaer a validé
end