From 89042078cae448375da464caef8dcbdccece3081 Mon Sep 17 00:00:00 2001 From: Ruxton Date: Tue, 22 Jan 2013 22:33:14 +0800 Subject: [PATCH] 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 ]