From cbb4b40bc02034ef9442c230cfd45d80a3931791 Mon Sep 17 00:00:00 2001 From: Christian Bruckmayer Date: Wed, 19 Mar 2014 17:22:48 +0100 Subject: [PATCH] Implement more embed code Supported Media Files: - Youtube - Vimeo - Instagram - Flickr - Slidershare - Speakerdeck close #26 --- app/assets/javascripts/osem.js | 5 ++++ app/models/event.rb | 8 +++++- app/views/proposal/_proposal_form.html.haml | 10 +++++++- app/views/proposal/show.html.haml | 25 +++++++++++++------ ...9143547_rename_video_to_media_on_events.rb | 11 ++++++++ db/schema.rb | 7 +++--- 6 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 db/migrate/20140319143547_rename_video_to_media_on_events.rb diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index 21dd66c8..225453bc 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -1,4 +1,9 @@ $(function() { + $("#event_media_type").change(function () { + $(".media-type").hide(); + $('#' + $(this).val().toLowerCase() + '-help').show(); + }); + $('.dropdown-toggle').dropdown(); $("#conference-start-datepicker").datepicker({ dateFormat: 'yy/mm/dd', diff --git a/app/models/event.rb b/app/models/event.rb index 9abc4521..e87325d8 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -1,7 +1,7 @@ class Event < ActiveRecord::Base include ActiveRecord::Transitions has_paper_trail - attr_accessible :title, :subtitle, :abstract, :description, :event_type_id, :people_attributes, :person, :proposal_additional_speakers, :track_id, :video_id, :video_type, :require_registration, :difficulty_level_id + attr_accessible :title, :subtitle, :abstract, :description, :event_type_id, :people_attributes, :person, :proposal_additional_speakers, :track_id, :media_id, :media_type, :require_registration, :difficulty_level_id acts_as_commentable @@ -25,10 +25,16 @@ class Event < ActiveRecord::Base accepts_nested_attributes_for :people before_create :generate_guid + def self.media_types + media_types = {:youtube => 'YouTube', :slideshare => 'SlideShare', :flickr => 'Flickr', :vimeo => 'Vimeo', :speakerdeck => 'Speakerdeck', :instagram => 'Instagram'} + return media_types + end + validate :abstract_limit validate :biography_exists validates :title, :presence => true validates :abstract, :presence => true + validates :media_type, inclusion: {in: self.media_types.values} scope :confirmed, where(:state => "confirmed") diff --git a/app/views/proposal/_proposal_form.html.haml b/app/views/proposal/_proposal_form.html.haml index 762ff6ac..51194f0b 100644 --- a/app/views/proposal/_proposal_form.html.haml +++ b/app/views/proposal/_proposal_form.html.haml @@ -31,7 +31,15 @@ %br %br = f.input :description, :input_html => {:rows => 5, :class=> "span11"}, :hint => "This will only be shown to organizers, not to attendees." - = f.input :video_id, :as => :string, :hint => "Go to your youtube video, click on \"share\" and copy everything behind http://youtu.be/" + = f.input :media_type, :as => :select, :label => "Media Type", :collection => Event.media_types.values, :include_blank => false + %p{:class => "help-block media-type", :id => "youtube-help"} Go to your YouTube video, click on "share" and copy everything behind http://youtu.be/" + %p{:class => "help-block media-type", :id => "slideshare-help", :style => "display:none"} Go to your SlideShare, click on "share" -> "embed" and copy the id + %p{:class => "help-block media-type", :id => "flickr-help", :style => "display:none"} Go to your flickr image, click on "Grab the link" -> "Show short url" and copy everything behind https://flic.kr/p/ + %p{:class => "help-block media-type", :id => "vimeo-help", :style => "display:none"} Go to your vimeo video, click on "share" and copy everything behind http://vimeo.com/ + %p{:class => "help-block media-type", :id => "speakerdeck-help", :style => "display:none"} Go to your SpeakerDeck, click on "share" -> "embed" and copy the data-id + %p{:class => "help-block media-type", :id => "instagram-help", :style => "display:none"} Go to your Instagram photo page and copy everything behind instagram.com/p/ (without trailing /# hash symbol) + = f.input :media_id, :label => "Media ID", :as => :string + %section#information = f.inputs :name => "Your Information" do = semantic_fields_for @person do |p| diff --git a/app/views/proposal/show.html.haml b/app/views/proposal/show.html.haml index 143e47cb..9d085b0a 100644 --- a/app/views/proposal/show.html.haml +++ b/app/views/proposal/show.html.haml @@ -23,18 +23,29 @@ %span.label{:style =>"background-color: #{@event.track.color};"} = @event.track.name .col-md-9 - -unless @event.video_id + -unless @event.media_id .row .col-md-12 %h5.text-error No video of the event yet, sorry! Meanwhile... .row - .col-md-12 - .flexvideo - -if @event.video_id - %iframe{:width=>"560", :height=>"315", :frameborder=>"0", :allowfullscreen=>"true", :src=>"http://www.youtube.com/embed/#{@event.video_id}?rel=0"} - -else - %iframe{:width=>"560", :height=>"315", :frameborder=>"0", :allowfullscreen=>"true", :src=>"http://www.youtube.com/embed/Eiv4e5ZxTmg?rel=0"} + .col-md-13 + -if not @event.media_id.blank? + .flexvideo + -if @event.media_type == Event.media_types[:slideshare] + %iframe{:width=>"560", :height=>"315", :frameborder=>"0", :allowfullscreen=>"true", :src=> request.ssl? ? "https://" : "http://" + "www.slideshare.net/slideshow/embed_code/#{@event.media_id}"} + -elsif @event.media_type == Event.media_types[:flickr] + %iframe{:width=>"560", :height=>"315", :frameborder=>"0", :allowfullscreen=>"true", :src=> request.ssl? ? "https://" : "http://" + "flic.kr/p/#{@event.media_id}/player/268a054da2"} + -elsif @event.media_type == Event.media_types[:vimeo] + %iframe{:width=>"560", :height=>"315", :frameborder=>"0", :allowfullscreen=>"true", :src=> "//player.vimeo.com/video/#{@event.media_id}"} + -elsif @event.media_type == Event.media_types[:speakerdeck] + %iframe{:width=>"560", :height=>"315", :frameborder=>"0", :allowfullscreen=>"true", :src=> "//speakerdeck.com/player/#{@event.media_id}?"} + -elsif @event.media_type == Event.media_types[:instagram] + %iframe{:width=>"560", :height=>"315", :frameborder=>"0", :allowfullscreen=>"true", :scrolling =>"no", :allowtransparency=>"true", :src=> "//instagram.com/p/#{@event.media_id}/embed/"} + -else + %iframe{:width=>"560", :height=>"315", :frameborder=>"0", :allowfullscreen=>"true", :src=> request.ssl? ? "https://" : "http://" + "www.youtube.com/embed/#{@event.media_id}?rel=0"} + -else + %div.well.well-lg="No video of the event yet, sorry! Meanwhile..." .row .col-md-8 %h3 diff --git a/db/migrate/20140319143547_rename_video_to_media_on_events.rb b/db/migrate/20140319143547_rename_video_to_media_on_events.rb new file mode 100644 index 00000000..754c8af4 --- /dev/null +++ b/db/migrate/20140319143547_rename_video_to_media_on_events.rb @@ -0,0 +1,11 @@ +class RenameVideoToMediaOnEvents < ActiveRecord::Migration + def up + rename_column :events, :video_id, :media_id + rename_column :events, :video_type, :media_type + end + + def down + rename_column :events, :media_id, :video_id + rename_column :events, :media_type, :video_type + end +end diff --git a/db/schema.rb b/db/schema.rb index 0632d711..a586313b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140305102505) do +ActiveRecord::Schema.define(:version => 20140319143547) do create_table "answers", :force => true do |t| t.string "title" @@ -75,6 +75,7 @@ ActiveRecord::Schema.define(:version => 20140305102505) do t.boolean "use_vpositions", :default => false t.boolean "use_vdays", :default => false t.boolean "use_difficulty_levels", :default => false + t.boolean "use_volunteers" end create_table "conferences_questions", :id => false, :force => true do |t| @@ -169,8 +170,8 @@ ActiveRecord::Schema.define(:version => 20140305102505) do t.integer "room_id" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.string "video_id" - t.string "video_type" + t.string "media_id" + t.string "media_type" t.boolean "require_registration" t.integer "difficulty_level_id" end