Use text-only description in Open Graph tags

This commit is contained in:
Marcin Kulik 2015-03-30 17:54:43 +00:00
parent 724b79c371
commit 537846e372
2 changed files with 11 additions and 1 deletions

View File

@ -1,4 +1,6 @@
class AsciicastPagePresenter
include ActionView::Helpers::SanitizeHelper
include ActionView::Helpers::TextHelper
attr_reader :routes, :asciicast, :current_user, :policy, :playback_options
@ -100,6 +102,14 @@ class AsciicastPagePresenter
asciicast.description
end
def short_text_description
if asciicast.description.present?
truncate(strip_tags(asciicast.description).gsub(/\n+/, ' '), length: 200)
else
"Recorded by #{asciicast.user.display_name}"
end
end
def show_other_asciicasts_by_author?
author.asciicast_count > 1
end

View File

@ -7,5 +7,5 @@
<meta property="og:type" content="website" />
<meta property="og:url" content="<%= asciicast_url(page.asciicast) %>" />
<meta property="og:image" content="<%= asciicast_url(page.asciicast, format: :png) %>" />
<meta property="og:description" content="<%= page.description %>" />
<meta property="og:description" content="<%= page.short_text_description %>" />
<meta property="og:site_name" content="asciinema.org" />