Skip to content
Snippets Groups Projects
Commit 9b0a8c01 authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

fix thumbnail display

parent c9d6beb8
No related branches found
No related tags found
No related merge requests found
......@@ -2,14 +2,14 @@ module LearningObjectsHelper
def display_object_type(learning_object)
case learning_object.object_type.name
when 'Áudio' then
audio_tag(learning_object.retrieve_link, controls: true)
when 'Vídeo' then
video_tag(learning_object.retrieve_link, autobuffer: true, poster: learning_object.thumbnail)
when 'PDF' then
"<iframe src=\"/pdfjs/web/viewer.html?file=#{learning_object.retrieve_link }\" style=\"border: 0 \" width=\"125%\" height=\"280\" frameborder=\"0\" scrolling=\"no\"></iframe>".html_safe
else
image_tag learning_object_thumbnail(learning_object, "large"), alt: learning_object_title(learning_object), class: "thumbnail"
when 'Áudio' then
audio_tag(learning_object.retrieve_link, controls: true)
when 'Vídeo' then
video_tag(learning_object.retrieve_link, autobuffer: true, poster: learning_object_thumbnail(learning_object))
when 'PDF' then
"<iframe src=\"/pdfjs/web/viewer.html?file=#{learning_object.retrieve_link }\" style=\"border: 0 \" width=\"125%\" height=\"280\" frameborder=\"0\" scrolling=\"no\"></iframe>".html_safe
else
image_tag learning_object_thumbnail(learning_object, 'large'), alt: learning_object_title(learning_object), class: 'thumbnail'
end
end
......@@ -18,53 +18,36 @@ module LearningObjectsHelper
end
def learning_object_thumbnail(learning_object, size = "")
if learning_object.thumbnail.blank?
thumbnail = learning_object.default_thumbnail
return thumbnail unless thumbnail.blank?
unless learning_object.object_type.blank?
case learning_object.object_type.name
when 'Vídeo' then
'video.png'
when 'Imagem' then
'image.png'
when 'Hipertexto' then
'text.png'
when 'Animação/simulação' then
'animation.png'
when 'Software Educacional' then
'software.png'
when 'Áudio' then
'audio.png'
when 'Experimento prático' then
'simulator.png'
else
size == 'large' ? 'learning-object-preview-large.png' : 'learning-object-preview.png'
when 'Vídeo' then return 'video.png'
when 'Imagem' then return 'image.png'
when 'Hipertexto' then return 'text.png'
when 'Animação/simulação' then return 'animation.png'
when 'Software Educacional' then return 'software.png'
when 'Áudio' then return 'audio.png'
when 'Experimento prático' then return 'simulator.png'
end
else
learning_object.thumbnail
end
(size == 'large') ? 'learning-object-preview-large.png' : 'learning-object-preview.png'
end
def learning_object_title(learning_object)
if learning_object.name.nil?
return 'Sem Título'
end
learning_object.name
end
def render_learning_object(orientation, learning_object)
case (orientation)
when "vertical"
render "learning_objects/learning_object_vertical", learning_object: learning_object
when "horizontal"
render "learning_objects/learning_object_horizontal", learning_object: learning_object
else
render "learning_objects/learning_object_horizontal", learning_object: learning_object
when 'vertical' then render 'learning_objects/learning_object_vertical', learning_object: learning_object
when 'horizontal' then render 'learning_objects/learning_object_horizontal', learning_object: learning_object
else render 'learning_objects/learning_object_horizontal', learning_object: learning_object
end
end
def collections_list(learning_object)
collections = @collections.diff(learning_object_collections(learning_object))
end
def social_share(learning_object)
set_meta_tags og: {
title: @learning_object.name,
......@@ -76,8 +59,5 @@ module LearningObjectsHelper
set_meta_tags fb: {
app_id: '745857965514514'
}
end
end
......@@ -22,7 +22,7 @@ class LearningObject < ActiveRecord::Base
validates_uniqueness_of :id_dspace
searchkick language: 'brazilian', match: :word_start, searchable: [:name, :description, :author, :object_type]
default_scope { includes(:object_type).order(score: :desc) }
default_scope { includes(:object_type, :attachments, :attachment, :publisher, :topics).order(score: :desc) }
scope :missing_thumbnail, ->() { where(thumbnail_file_name: nil) }
def search_data
......@@ -57,6 +57,14 @@ class LearningObject < ActiveRecord::Base
nil
end
def default_thumbnail
return thumbnail unless thumbnail.blank?
return nil if attachments.blank?
return default_attachment.thumbnail unless default_attachment.thumbnail.blank?
attachments.each { |a| return a.thumbnail unless a.thumbnail.blank? }
nil
end
def retrieve_link
"#{DspaceService.link}/rest#{default_attachment.retrieve_link}"
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment