module DocumentsHelper

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

absolute_path_for_photo(path) click to toggle source
# File app/helpers/documents_helper.rb, line 35
def absolute_path_for_photo(path)
  Document::MULTIMEDIA_PATH + relative_path_for_photo(path)
end
document_img_tag(original_photo_path, size, absolute=false) click to toggle source
# File app/helpers/documents_helper.rb, line 52
def document_img_tag(original_photo_path, size, absolute=false)
  small_version = photo_path(original_photo_path, size)
  logger.info "document_img_tag: Buscando #{small_version}"
  if original_photo_path.match(/#{default_preview_img}$/) || original_photo_path.match(/#{default_preview_img('169')}$/)
    logger.info "document_img_tag: #{small_version} es el default"
    small_img_tag = original_photo_path  
  elsif File.exists?(absolute_path_for_photo(small_version))
    logger.info "document_img_tag: #{small_version} ya existe"
    small_img_tag = url_for_photo(small_version)
  else
    if absolute
      logger.info "document_img_tag: #{small_version} generando absoluto :path => #{relative_path_for_photo(original_photo_path)}"
      small_img_tag = image_news_url(:size => size, :path => relative_path_for_photo(original_photo_path)) 
    else
      logger.info "document_img_tag: #{small_version} generando relativo :path => #{relative_path_for_photo(original_photo_path)}"
      small_img_tag = image_news_path(:size => size, :path => relative_path_for_photo(original_photo_path)) 
    end
  end

  return small_img_tag
end
document_qr_code(document) click to toggle source
# File app/helpers/documents_helper.rb, line 103
def document_qr_code(document)
  url = document.is_a?(News) ? news_url(:id => document.id) : event_url(:id => document.id)
  unless File.exists?(document.qr_code_path)
    # Crear la imágen si no existe.
    FileUtils.mkdir_p(File.dirname(document.qr_code_path))
    system "qrencode -o #{document.qr_code_path} #{url}"
  end
  
  image_tag(document.qr_code_url)
end
file_type(file) click to toggle source
# File app/helpers/documents_helper.rb, line 39
def file_type(file)
  Pathname.new(file.file_file_name).extname.sub('.', '')
end
icon_for_document(document, html_options={}) click to toggle source
# File app/helpers/documents_helper.rb, line 23
def icon_for_document(document, html_options={})
  image_tag('/images/gv.gif', {:width => 30, :height => 30, :alt => "Irekia"}.merge(html_options) )
end
news_img_and_alt(news, size="n70") click to toggle source
# File app/helpers/documents_helper.rb, line 74
def news_img_and_alt(news, size="n70")
  small_img_tag = nil
  alt = nil
  if news.has_video?
    # logger.info "news_img_and_alt: #{news.id} has video"
    photo = video_preview_img(news)
    small_img_tag = document_img_tag(photo, size, true)
    alt = small_img_tag.match(/([^(%2F)]+)\.jpg/).to_a[1].humanize.capitalize if small_img_tag.match(/([^(%2F)]+)\.jpg/)
  elsif news.has_cover_photo?
    # logger.info "news_img_and_alt: #{news.id} has cover photo"
    small_img_tag = "#{base_url}#{news.cover_photo.url(size.to_sym)}"
  elsif news.photos.length > 0
    # logger.info "news_img_and_alt: #{news.id} has secondary photos"
    photo = news.photos.first
    small_img_tag = document_img_tag(photo, size, true)
    alt = small_img_tag.match(/([^(%2F)]+)\.jpg/).to_a[1].humanize.capitalize if small_img_tag.match(/([^(%2F)]+)\.jpg/)
  else
    small_img_tag = case size
    when 'n70'
      "default/news_img_default_70x39.png"
    else 
      # 320x240
      "default/news_img_default.png"
    end
    alt = news.title       
  end
  return {:img => small_img_tag, :alt => alt}
end
relative_path_for_photo(path) click to toggle source
# File app/helpers/documents_helper.rb, line 31
def relative_path_for_photo(path)
  path.sub(/^#{Document::MULTIMEDIA_PATH}/,'').sub(/^#{Document::MULTIMEDIA_URL}/,'')
end
show_left_menu_for(document) click to toggle source
# File app/helpers/documents_helper.rb, line 47
def show_left_menu_for(document)
  document.has_video? || document.has_cover_photo? || document.has_videos? || 
  document.has_audios? || document.has_photos? || document.has_files? || document.has_transcriptions?
end
subtitle_for_iphone(news) click to toggle source
# File app/helpers/documents_helper.rb, line 43
def subtitle_for_iphone(news)
  news.subtitle.present? ? news.subtitle.strip_html : pretty_n_characters_wo_html(news.body).strip_html
end
url_for_photo(path) click to toggle source
# File app/helpers/documents_helper.rb, line 27
def url_for_photo(path)
  Document::MULTIMEDIA_URL + relative_path_for_photo(path)
end