Skip to content

Commit

Permalink
Embed facebook links to gif files.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed Apr 9, 2016
1 parent 451b092 commit 6c0aa36
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions views/facebook_feed.erb
Expand Up @@ -33,6 +33,11 @@ end
<content type="html">
<%= (post["message"] || post["description"]).to_paragraphs.esc %>
<%=
if /^https?:\/\/[a-z0-9\-._~:\/?#\[\]@!$&'()*+,;=]+\.gif/i =~ post["link"]
"<img src='#{post["link"]}'>".esc
end
%>
<%=
if /(?:youtu\.be\/(?<video_id>[^?&#]+)|youtube\.com\/)(?:.*?[?&#](v=(?<video_id>[^&#]+)|list=(?<list>[^&#]+)|t=(?<t>[^&#]+)))*/ =~ post["link"]
# https://www.youtube.com/watch?v=z5OGD5_9cA0&list=PL0QrZvg7QIgpoLdNFnEePRrU-YJfr9Be7&index=3&t=30s
embed_url = "https://www.youtube.com/embed/#{video_id}?rel=0"
Expand Down

0 comments on commit 6c0aa36

Please sign in to comment.