Module DocumentsHelper
In: app/helpers/documents_helper.rb

Methods

Public Instance methods

[Source]

    # File app/helpers/documents_helper.rb, line 31
31:   def absolute_path_for_photo(path)
32:     Document::MULTIMEDIA_PATH + relative_path_for_photo(path)
33:   end

[Source]

    # File app/helpers/documents_helper.rb, line 47
47:   def document_img_tag(original_photo_path, size, absolute=false)
48:     small_version = photo_path(original_photo_path, size)
49:     # logger.info "document_img_tag: Buscando #{small_version}"
50:     if original_photo_path.match(/#{default_preview_img}$/)
51:       # logger.info "document_img_tag: #{small_version} es el default"
52:       small_img_tag = original_photo_path  
53:     elsif File.exists?(absolute_path_for_photo(small_version))
54:       # logger.info "document_img_tag: #{small_version} ya existe"
55:       small_img_tag = url_for_photo(small_version)
56:     else 
57:       if absolute
58:         # logger.info "document_img_tag: #{small_version} generando absoluto :path => #{relative_path_for_photo(original_photo_path)}"
59:         small_img_tag = image_documents_url(:size => size, :path => relative_path_for_photo(original_photo_path)) 
60:       else
61:         # logger.info "document_img_tag: #{small_version} generando relativo :path => #{relative_path_for_photo(original_photo_path)}"
62:         small_img_tag = image_documents_path(:size => size, :path => relative_path_for_photo(original_photo_path)) 
63:       end
64:     end
65:     return small_img_tag
66:   end

[Source]

    # File app/helpers/documents_helper.rb, line 35
35:   def file_type(file)
36:     Pathname.new(file.file_file_name).extname.sub('.', '')
37:   end

[Source]

    # File app/helpers/documents_helper.rb, line 2
 2:   def icon_for_document(document, target="news", html_options={})
 3:     # if target.eql?("search")
 4:     #   img = "/images/doc_types/#{document.class.to_s.downcase}.gif"
 5:     # else
 6:       if document.icon
 7:         img = document.icon.photo.url(:tiny)
 8:         alt = document.icon.name
 9:       else
10:         if document.is_a?(Link)
11:           img = '/images/doc_types/link.gif'
12:           alt = t('documents.enlace_externo')
13:         else
14:           img = '/images/default_icon.gif'
15:           alt = "OpenIrekia"
16:         end
17:       end
18:     # end
19:     image_tag(img, {:width => 30, :height => 30, :alt => alt}.merge(html_options) )
20:   end

[Source]

    # File app/helpers/documents_helper.rb, line 68
68:   def news_img_and_alt(news, size="n85")
69:     small_img_tag = nil
70:     alt = nil
71:     if news.has_video?(subsite)
72:       # logger.info "news_img_and_alt: #{news.id} has video"
73:       photo = video_preview_img(news)
74:       small_img_tag = document_img_tag(photo, size, true)
75:       alt = small_img_tag.match(/([^(%2F)]+)\.jpg/).to_a[1].humanize.capitalize if small_img_tag.match(/([^(%2F)]+)\.jpg/)
76:     elsif news.has_cover_photo?
77:       # logger.info "news_img_and_alt: #{news.id} has cover photo"
78:       small_img_tag = "#{base_url}#{news.cover_photo.url(size.to_sym)}"
79:     elsif news.photos(subsite).length > 0
80:       # logger.info "news_img_and_alt: #{news.id} has secondary photos"
81:       photo = news.photos(subsite).first
82:       small_img_tag = document_img_tag(photo, size, true)
83:       alt = small_img_tag.match(/([^(%2F)]+)\.jpg/).to_a[1].humanize.capitalize if small_img_tag.match(/([^(%2F)]+)\.jpg/)
84:     end
85:     return {:img => small_img_tag, :alt => alt}
86:   end

[Source]

    # File app/helpers/documents_helper.rb, line 27
27:   def relative_path_for_photo(path)
28:     path.sub(/^#{Document::MULTIMEDIA_PATH}/,'').sub(/^#{Document::MULTIMEDIA_URL}/,'')
29:   end

[Source]

    # File app/helpers/documents_helper.rb, line 43
43:   def show_left_menu_for(document)
44:     document.has_videos?(subsite) || document.has_audios?(subsite) || document.has_photos?(subsite) || document.has_files? || document.has_transcriptions?
45:   end

[Source]

    # File app/helpers/documents_helper.rb, line 39
39:   def subtitle_for_iphone(news)
40:     news.subtitle.present? ? news.subtitle.strip_html : first_n_characters_wo_html(news.body).strip_html
41:   end

[Source]

    # File app/helpers/documents_helper.rb, line 22
22:   def url_for_photo(path)
23:     # logger.info "url_for_photo: :path => #{path}, relative => #{relative_path_for_photo(path)}. Complete => #{Document::MULTIMEDIA_URL + relative_path_for_photo(path)}"
24:     Document::MULTIMEDIA_URL + relative_path_for_photo(path)
25:   end

[Validate]