Skip to content
Snippets Groups Projects
Commit b531c73c authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

improve download button

parent fa92ecab
No related branches found
No related tags found
No related merge requests found
......@@ -2,10 +2,14 @@ module LearningObjectsHelper
def display_object_type(learning_object)
case learning_object.default_attachment.mime_type
when /audio\/*/i then audio_tag(learning_object.cache_link, controls: true)
when /video\/mp4/i then video_tag(learning_object.cache_link.to_s, autobuffer: true, poster: learning_object_thumbnail(learning_object))
when /application\/(x-)?pdf/i 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 /audio\/*/i then
audio_tag(learning_object.cache_link, controls: true)
when /video\/mp4/i then
video_tag(learning_object.cache_link.to_s, autobuffer: true, poster: learning_object_thumbnail(learning_object))
when /application\/(x-)?pdf/i 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
......@@ -19,13 +23,20 @@ module LearningObjectsHelper
unless learning_object.object_type.blank?
case learning_object.object_type.name
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'
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
end
......@@ -38,22 +49,44 @@ module LearningObjectsHelper
def render_learning_object(orientation, learning_object)
case (orientation)
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
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 display_download_button(learning_object)
return external_website_btn(learning_object) if learning_object.has_url_reference?
download_btn learning_object
end
def social_share(learning_object)
set_meta_tags og: {
title: learning_object.name,
type: 'website',
description: learning_object.description,
image: learning_object.default_thumbnail
title: learning_object.name,
type: 'website',
description: learning_object.description,
image: learning_object.default_thumbnail
}
set_meta_tags fb: {
app_id: '745857965514514'
app_id: '745857965514514'
}
end
def external_website_btn(learning_object)
highlighted_btn learning_object.url_reference, 'Acessar website', 'fa-external-link'
end
def download_btn(learning_object)
highlighted_btn download_learning_object_path(learning_object), 'Download', 'fa-download'
end
def highlighted_btn(url, _label = nil, _class = nil)
link_to url, class: 'download btn btn-success', target: "_blank" do
"<i class='fa #{_class}'></i> #{_label}"
end
end
end
# == Schema Information
#
# Table name: object_types
#
# id :integer not null, primary key
# name :string
#
class ObjectType < ActiveRecord::Base
has_many :learning_objects
has_and_belongs_to_many :mime_types
......
......@@ -60,11 +60,11 @@
<div class="rating-panel">
<% if user_signed_in? %>
<div class="actions">
<div class="action download">
<%= link_to download_learning_object_path, class: 'download btn btn-success', target: "_blank" do %>
<i class="fa fa-download"></i>FAZER DOWNLOAD
<%end%>
<%= display_download_button(@learning_object) %>
</div>
<div class="action">
<%= link_to like_learning_object_path(id: @learning_object.id), class: 'vote btn btn-primary',method: :post, remote: true do %>
<% if @liked %>
......
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