From 40a8dfa9152e339a8bde14ec77d52375f6e7fee8 Mon Sep 17 00:00:00 2001 From: Stefan Sundin Date: Tue, 15 Nov 2016 21:33:24 -0800 Subject: [PATCH] Fix some embedding problems. --- config/initializers/05-string.rb | 2 ++ views/facebook_feed.erb | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/config/initializers/05-string.rb b/config/initializers/05-string.rb index 3ac044c..5be8c78 100644 --- a/config/initializers/05-string.rb +++ b/config/initializers/05-string.rb @@ -166,6 +166,8 @@ def embed_html(request) "" elsif %r{^https?://(?:www\.)?vimeo\.com/(?\d+)} =~ self "" + elsif %r{^https?://(?:www\.)?instagram\.com/p/(?[^/?#]+)} =~ self + "" elsif %r{^https?://(?:www\.)?twitch\.tv/(?[^/]+)(?:/v/(?\d+))?.*(?:[?&#](?t=[^&#]+))?} =~ self # https://www.twitch.tv/gamesdonequick # https://www.twitch.tv/gamesdonequick/v/76877760?t=20h38m50s diff --git a/views/facebook_feed.erb b/views/facebook_feed.erb index cb96739..d316529 100644 --- a/views/facebook_feed.erb +++ b/views/facebook_feed.erb @@ -11,12 +11,24 @@ post["link"] = post["link"].resolve_url if post["link"] id = post["id"] id += ":#{post["live_status"]}" if post["live_status"] + /_(?\d+)$/ =~ (post["parent_id"] || post["id"]) + + type = post["type"] || @type + if type[-1] == "s" + type = type[0..-2] + end + + link = if @edge == "videos" or post["type"] == "video" + "https://www.facebook.com/video/embed?video_id=#{object_id}" + else + post["link"] || "https://www.facebook.com/#{post["id"]}" + end -%> facebook:post:<%= id %><%= ":#{params[:cachebuster]}" if params[:cachebuster] %> <%= -if post["live_status"] == "LIVE" or post["story"][" is live now"] +if (post["live_status"] and post["live_status"] != "VOD") or post["story"][" is live now"] "[LIVE] " elsif post["length"] "[#{post["length"].round.to_duration}] " @@ -47,10 +59,10 @@ if prefix and suffix elsif suffix or prefix suffix || prefix else - (post["type"] || @type[0..-2]).camelize + type.camelize end %> - " /> + <%= Time.parse(post["updated_time"]) %> <%= post["from"]["name"] %> @@ -59,17 +71,17 @@ end <%= post["link"].embed_html(request).esc if post["link"] %> <%= post["embed_html"].esc if post["embed_html"] %> <%= -if @type == "photos" and post["source"] +if type == "photo" and post["source"] "

".esc elsif @edge == "videos" and post["id"] <<-EOF.undent.esc

Open embed

Download video

EOF -elsif post["type"] == "photo" +elsif type == "photo" <<-EOF.undent.esc

-

Full size

+

Full size

EOF end %>