From 86559fad2017aa5543037aa88639c80901af818b Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Sun, 29 Mar 2015 18:43:32 +0000 Subject: [PATCH] Add oEmbed discovery tags to asciicast page --- app/presenters/asciicast_page_presenter.rb | 4 ++++ app/views/asciicasts/show.html.slim | 3 +++ app/views/layouts/application.html.slim | 1 + 3 files changed, 8 insertions(+) diff --git a/app/presenters/asciicast_page_presenter.rb b/app/presenters/asciicast_page_presenter.rb index 9e14530..c7b208b 100644 --- a/app/presenters/asciicast_page_presenter.rb +++ b/app/presenters/asciicast_page_presenter.rb @@ -107,6 +107,10 @@ class AsciicastPagePresenter author.asciicasts_excluding(asciicast, 3).decorate end + def asciicast_oembed_url(routes, format) + routes.oembed_url(url: routes.asciicast_url(asciicast), format: format) + end + private def author diff --git a/app/views/asciicasts/show.html.slim b/app/views/asciicasts/show.html.slim index d152d93..5310ae6 100644 --- a/app/views/asciicasts/show.html.slim +++ b/app/views/asciicasts/show.html.slim @@ -1,4 +1,7 @@ - content_for(:title, page.title) +- content_for(:head) do + link rel="alternate" type="application/json+oembed" href="#{page.asciicast_oembed_url(self, :json)}" + link rel="alternate" type="text/xml+oembed" href="#{page.asciicast_oembed_url(self, :xml)}" .asciicast-page section.cinema diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim index 4bcbebe..5595a71 100644 --- a/app/views/layouts/application.html.slim +++ b/app/views/layouts/application.html.slim @@ -11,6 +11,7 @@ html[lang="en"] = javascript_include_tag "player" = favicon_link_tag 'favicon.png' = render 'layouts/ga' if Rails.env.production? + = content_for(:head) body = render 'layouts/header' = render 'shared/flash'