From 537846e372e6895a5169b6e65eafacb9a0bbf8fd Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Mon, 30 Mar 2015 17:54:43 +0000 Subject: [PATCH] Use text-only description in Open Graph tags --- app/presenters/asciicast_page_presenter.rb | 10 ++++++++++ app/views/asciicasts/_discovery_tags.html.erb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/presenters/asciicast_page_presenter.rb b/app/presenters/asciicast_page_presenter.rb index 99a6096..5c015c6 100644 --- a/app/presenters/asciicast_page_presenter.rb +++ b/app/presenters/asciicast_page_presenter.rb @@ -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 diff --git a/app/views/asciicasts/_discovery_tags.html.erb b/app/views/asciicasts/_discovery_tags.html.erb index f2e50b7..ad00f77 100644 --- a/app/views/asciicasts/_discovery_tags.html.erb +++ b/app/views/asciicasts/_discovery_tags.html.erb @@ -7,5 +7,5 @@ - +