module PhotosHelper

OpenIrekia v4.0.0

Copyright 2009-2013 eFaber, S.L. Copyright 2009-2013 Ejie, S.A. Copyrigth 2009-2013 Dirección de Gobierno Abierto y Comunicación en Internet;

Gobernu Irekirako eta Interneteko Komunikaziorako Zuzendaritza; Lehendakaritza.
Gobierno Vasco – Eusko Jaurlaritza

Licencia con arreglo a la EUPL, Versión 1.1 o –en cuanto sean aprobadas por la Comisión Europea– versiones posteriores de la EUPL (la Licencia); Solo podrá usarse esta obra si se respeta la Licencia. Puede obtenerse una copia de la Licencia en: ec.europa.eu/idabc/eupl Salvo cuando lo exija la legislación aplicable o se acuerde por escrito, el programa distribuido con arreglo a la Licencia se distribuye TAL CUAL, SIN GARANTÍAS NI CONDICIONES DE NINGÚN TIPO, ni expresas ni implícitas. Véase la Licencia en el idioma concreto que rige los permisos y limitaciones que establece la Licencia

http://open.irekia.net, openirekia@efaber.net

Public Instance Methods

aspect(photo) click to toggle source
# File app/helpers/photos_helper.rb, line 28
def aspect(photo)
  case 
  when photo.vertical?
    "vertical"
  when photo.square?
    "square"
  else
    "horizontal"
  end
end
photo_height(photo, size) click to toggle source
# File app/helpers/photos_helper.rb, line 50
def photo_height(photo, size)
  if photo.height.present?
    size = size.to_s.gsub(/[^\d]/, '').to_f 
    if photo.vertical?
      height = size.to_i
    else
      height = (size/photo.aspect).round
    end
  end
end
photo_width(photo, size) click to toggle source
# File app/helpers/photos_helper.rb, line 39
def photo_width(photo, size)
  if photo.width.present?
    size = size.to_s.gsub(/[^\d]/, '').to_f 
    if photo.horizontal?
      width = size.to_i
    else
      width = (size*photo.aspect).round
    end
  end
end
shorten(title, length=65) click to toggle source
# File app/helpers/photos_helper.rb, line 23
def shorten(title, length=65)
  # We use length-4 because are going to add "... "
  title.length > length ? "#{truncate(title, :length =>  length-4, :omission => "").sub(/[^\w]\w+$/, '')}… " : title
end