From 89042078cae448375da464caef8dcbdccece3081 Mon Sep 17 00:00:00 2001 From: Ruxton Date: Tue, 22 Jan 2013 22:33:14 +0800 Subject: [PATCH 1/4] Oembed Update - Added instagram, better display for rich/photo --- app/assets/javascripts/app/views/content_view.js | 8 +++++++- app/assets/templates/oembed_tpl.jst.hbs | 4 ++-- config/initializers/oembed.rb | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/app/views/content_view.js b/app/assets/javascripts/app/views/content_view.js index f8dc39388..68f5f26c8 100644 --- a/app/assets/javascripts/app/views/content_view.js +++ b/app/assets/javascripts/app/views/content_view.js @@ -82,8 +82,14 @@ app.views.OEmbed = app.views.Base.extend({ }, presenter:function () { + o_embed_cache = this.model.get("o_embed_cache") + if(o_embed_cache) { + typemodel = { rich: false, photo: false, video: false, link: false } + typemodel[o_embed_cache.data.type] = true + o_embed_cache.data.types = typemodel + } return _.extend(this.defaultPresenter(), { - o_embed_html : app.helpers.oEmbed.html(this.model.get("o_embed_cache")) + o_embed_html : app.helpers.oEmbed.html(o_embed_cache) }) }, diff --git a/app/assets/templates/oembed_tpl.jst.hbs b/app/assets/templates/oembed_tpl.jst.hbs index fba433935..57eafd54d 100644 --- a/app/assets/templates/oembed_tpl.jst.hbs +++ b/app/assets/templates/oembed_tpl.jst.hbs @@ -1,5 +1,5 @@ {{#if o_embed_cache}} - {{#if o_embed_cache.data.thumbnail_url}} + {{#if o_embed_cache.data.types.video }}
@@ -17,6 +17,6 @@
{{else}} - {{{o_embed_html}}} + {{{o_embed_html}}} {{/if}} {{/if}} \ No newline at end of file diff --git a/config/initializers/oembed.rb b/config/initializers/oembed.rb index 535e3a272..f86c5a9ed 100644 --- a/config/initializers/oembed.rb +++ b/config/initializers/oembed.rb @@ -9,11 +9,15 @@ require 'uri' OEmbedCubbies = OEmbed::Provider.new("http://cubbi.es/oembed") +# patch in support for new https soundcloud +OEmbed::Providers::SoundCloud << "https://*.soundcloud.com/*" + oembed_provider_list = [ OEmbed::Providers::Youtube, OEmbed::Providers::Vimeo, - OEmbed::Providers::Flickr, OEmbed::Providers::SoundCloud, + OEmbed::Providers::Instagram, + OEmbed::Providers::Flickr, OEmbedCubbies ] From 40fdf3819bc9171e16800d0f06b396b96938ec3b Mon Sep 17 00:00:00 2001 From: Ruxton Date: Fri, 25 Jan 2013 22:31:44 +0800 Subject: [PATCH 2/4] Added DailyMotion & Twitter oEmbeds --- config/initializers/oembed.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/initializers/oembed.rb b/config/initializers/oembed.rb index f86c5a9ed..d02d8236a 100644 --- a/config/initializers/oembed.rb +++ b/config/initializers/oembed.rb @@ -9,6 +9,13 @@ require 'uri' OEmbedCubbies = OEmbed::Provider.new("http://cubbi.es/oembed") +OEmbedDailyMotion = OEmbed::Provider.new("http://www.dailymotion.com/services/oembed") +OEmbedDailyMotion << "http://www.dailymotion.com/video/*" + +OEmbedTwitter = OEmbed::Provider.new("https://api.twitter.com/1/statuses/oembed.json") +OEmbedTwitter << "http://twitter.com/*/status/*" +OEmbedTwitter << "https://twitter.com/*/status/*" + # patch in support for new https soundcloud OEmbed::Providers::SoundCloud << "https://*.soundcloud.com/*" @@ -18,7 +25,9 @@ oembed_provider_list = [ OEmbed::Providers::SoundCloud, OEmbed::Providers::Instagram, OEmbed::Providers::Flickr, - OEmbedCubbies + OEmbedCubbies, + OEmbedDailyMotion, + OEmbedTwitter ] SECURE_ENDPOINTS = oembed_provider_list.map do |provider| From 60024d7e208b840976c025a05cabce0cfa3988a7 Mon Sep 17 00:00:00 2001 From: Ruxton Date: Fri, 25 Jan 2013 22:43:56 +0800 Subject: [PATCH 3/4] Someone isn't a StarWars fan. --- spec/javascripts/app/views/stream_faces_view_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/javascripts/app/views/stream_faces_view_spec.js b/spec/javascripts/app/views/stream_faces_view_spec.js index 956802492..259dcd074 100644 --- a/spec/javascripts/app/views/stream_faces_view_spec.js +++ b/spec/javascripts/app/views/stream_faces_view_spec.js @@ -5,7 +5,7 @@ describe("app.views.StreamFaces", function(){ this.post2 = factory.post({author : factory.author({name : "John Stamos", id : 1987})}) this.post3 = factory.post({author : factory.author({name : "Michelle Tanner", id : 1986})}) this.post4 = factory.post({author : factory.author({name : "Barack Obama", id : 2000})}) - this.post5 = factory.post({author : factory.author({name : "Obie-won Kenobie", id : 2020})}) + this.post5 = factory.post({author : factory.author({name : "Obi-wan Kenobi", id : 2020})}) this.post6 = factory.post({author : rebeccaBlack}) this.post7 = factory.post({author : rebeccaBlack}) From e8decc200ee496c99d3dff11b72da55c7aff08c5 Mon Sep 17 00:00:00 2001 From: Ruxton Date: Fri, 25 Jan 2013 23:07:44 +0800 Subject: [PATCH 4/4] Adding jasmine coverage for oEmbed updates --- Changelog.md | 1 + .../javascripts/app/views/oembed_view_spec.js | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 2662f78cb..855f1539b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -17,6 +17,7 @@ ## Features +* Updates to oEmbed, added new providers and fixed photo display. [#3880](https://github.com/diaspora/diaspora/pull/3880) * Add 'screenshot tool' for taking before/after images of stylesheet changes. [#3797](https://github.com/diaspora/diaspora/pull/3797) * Add possibility to contact the administrator. [#3792](https://github.com/diaspora/diaspora/pull/3792) * Add simple background for unread messages/conversations mobile. [#3724](https://github.com/diaspora/diaspora/pull/3724) diff --git a/spec/javascripts/app/views/oembed_view_spec.js b/spec/javascripts/app/views/oembed_view_spec.js index 6b635910b..7af824d20 100644 --- a/spec/javascripts/app/views/oembed_view_spec.js +++ b/spec/javascripts/app/views/oembed_view_spec.js @@ -13,7 +13,23 @@ describe("app.views.OEmbed", function(){ }); describe("rendering", function(){ - context("with thumb", function() { + + it("should set types on the data", function() { + this.view.render(); + expect(this.view.model.get("o_embed_cache").data.types).toBeDefined(); + }); + + context("is a video", function() { + + beforeEach(function(){ + this.statusMessage.set({"o_embed_cache" : {"data": {"html": "some html","thumbnail_url": "//example.com/thumb.jpg","type": "video"}}}); + }); + + it("should set types.video on the data", function() { + this.view.render(); + expect(this.view.model.get("o_embed_cache").data.types.video).toBe(true) + }); + it("shows the thumb with overlay", function(){ this.view.render(); @@ -31,7 +47,7 @@ describe("app.views.OEmbed", function(){ }); }); - context("no thumb", function() { + context("is not a video", function() { beforeEach(function(){ this.statusMessage.set({"o_embed_cache" : {"data": {"html": "some html"}}}); });