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 ...@@ -2,10 +2,14 @@ module LearningObjectsHelper
def display_object_type(learning_object) def display_object_type(learning_object)
case learning_object.default_attachment.mime_type case learning_object.default_attachment.mime_type
when /audio\/*/i then audio_tag(learning_object.cache_link, controls: true) when /audio\/*/i then
when /video\/mp4/i then video_tag(learning_object.cache_link.to_s, autobuffer: true, poster: learning_object_thumbnail(learning_object)) audio_tag(learning_object.cache_link, controls: true)
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 when /video\/mp4/i then
else image_tag learning_object_thumbnail(learning_object, 'large'), alt: learning_object_title(learning_object), class: 'thumbnail' 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
end end
...@@ -19,13 +23,20 @@ module LearningObjectsHelper ...@@ -19,13 +23,20 @@ module LearningObjectsHelper
unless learning_object.object_type.blank? unless learning_object.object_type.blank?
case learning_object.object_type.name case learning_object.object_type.name
when 'Vídeo' then return 'video.png' when 'Vídeo' then
when 'Imagem' then return 'image.png' return 'video.png'
when 'Hipertexto' then return 'text.png' when 'Imagem' then
when 'Animação/simulação' then return 'animation.png' return 'image.png'
when 'Software Educacional' then return 'software.png' when 'Hipertexto' then
when 'Áudio' then return 'audio.png' return 'text.png'
when 'Experimento prático' then return 'simulator.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
end end
...@@ -38,22 +49,44 @@ module LearningObjectsHelper ...@@ -38,22 +49,44 @@ module LearningObjectsHelper
def render_learning_object(orientation, learning_object) def render_learning_object(orientation, learning_object)
case (orientation) case (orientation)
when 'vertical' then render 'learning_objects/learning_object_vertical', learning_object: learning_object when 'vertical' then
when 'horizontal' then render 'learning_objects/learning_object_horizontal', learning_object: learning_object render 'learning_objects/learning_object_vertical', learning_object: learning_object
else render 'learning_objects/learning_object_horizontal', 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
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) def social_share(learning_object)
set_meta_tags og: { set_meta_tags og: {
title: learning_object.name, title: learning_object.name,
type: 'website', type: 'website',
description: learning_object.description, description: learning_object.description,
image: learning_object.default_thumbnail image: learning_object.default_thumbnail
} }
set_meta_tags fb: { set_meta_tags fb: {
app_id: '745857965514514' app_id: '745857965514514'
} }
end 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 end
# == Schema Information
#
# Table name: object_types
#
# id :integer not null, primary key
# name :string
#
class ObjectType < ActiveRecord::Base class ObjectType < ActiveRecord::Base
has_many :learning_objects has_many :learning_objects
has_and_belongs_to_many :mime_types has_and_belongs_to_many :mime_types
......
...@@ -60,11 +60,11 @@ ...@@ -60,11 +60,11 @@
<div class="rating-panel"> <div class="rating-panel">
<% if user_signed_in? %> <% if user_signed_in? %>
<div class="actions"> <div class="actions">
<div class="action download"> <div class="action download">
<%= link_to download_learning_object_path, class: 'download btn btn-success', target: "_blank" do %> <%= display_download_button(@learning_object) %>
<i class="fa fa-download"></i>FAZER DOWNLOAD
<%end%>
</div> </div>
<div class="action"> <div class="action">
<%= link_to like_learning_object_path(id: @learning_object.id), class: 'vote btn btn-primary',method: :post, remote: true do %> <%= link_to like_learning_object_path(id: @learning_object.id), class: 'vote btn btn-primary',method: :post, remote: true do %>
<% if @liked %> <% 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