diff options
author | Matt Jankowski <mjankowski@thoughtbot.com> | 2017-04-16 10:38:02 -0400 |
---|---|---|
committer | Eugen <eugen@zeonfederated.com> | 2017-04-16 16:38:02 +0200 |
commit | 73b0af5c938b49ef0a4a21921b41a3b1bcd4e05e (patch) | |
tree | 36c83c1be4c69738913bc7212baa7630fc5df471 /app/views/stream_entries | |
parent | 7efde22c3ab0464a0896abcaa8be277fd14bdee9 (diff) |
Simplify the og:image and og:description code in stream_entries/show (#1934)
Diffstat (limited to 'app/views/stream_entries')
-rw-r--r-- | app/views/stream_entries/_og_description.html.haml | 4 | ||||
-rw-r--r-- | app/views/stream_entries/_og_image.html.haml | 6 | ||||
-rw-r--r-- | app/views/stream_entries/show.html.haml | 13 |
3 files changed, 12 insertions, 11 deletions
diff --git a/app/views/stream_entries/_og_description.html.haml b/app/views/stream_entries/_og_description.html.haml new file mode 100644 index 000000000..5762aca04 --- /dev/null +++ b/app/views/stream_entries/_og_description.html.haml @@ -0,0 +1,4 @@ +- if activity.is_a?(Status) && activity.spoiler_text? + %meta{ property: 'og:description', content: activity.spoiler_text }/ +- else + %meta{ property: 'og:description', content: activity.content }/ diff --git a/app/views/stream_entries/_og_image.html.haml b/app/views/stream_entries/_og_image.html.haml new file mode 100644 index 000000000..f725209d8 --- /dev/null +++ b/app/views/stream_entries/_og_image.html.haml @@ -0,0 +1,6 @@ +- if activity.is_a?(Status) && activity.non_sensitive_with_media? + %meta{ property: 'og:image', content: full_asset_url(activity.media_attachments.first.file.url(:small)) }/ +- else + %meta{ property: 'og:image', content: full_asset_url(account.avatar.url(:original)) }/ + %meta{ property: 'og:image:width', content: '120' }/ + %meta{ property: 'og:image:height', content: '120' }/ diff --git a/app/views/stream_entries/show.html.haml b/app/views/stream_entries/show.html.haml index eb8387ccb..dea5e9d40 100644 --- a/app/views/stream_entries/show.html.haml +++ b/app/views/stream_entries/show.html.haml @@ -6,17 +6,8 @@ %meta{ property: 'og:type', content: 'article' }/ %meta{ property: 'og:title', content: "#{@account.username} on #{Rails.configuration.x.local_domain}" }/ - - if @stream_entry.activity.is_a?(Status) && !@stream_entry.activity.spoiler_text.blank? - %meta{ property: 'og:description', content: @stream_entry.activity.spoiler_text }/ - - else - %meta{ property: 'og:description', content: @stream_entry.activity.content }/ - - - if @stream_entry.activity.is_a?(Status) && !@stream_entry.activity.sensitive? && @stream_entry.activity.media_attachments.size > 0 - %meta{ property: 'og:image', content: full_asset_url(@stream_entry.activity.media_attachments.first.file.url(:small)) }/ - - else - %meta{ property: 'og:image', content: full_asset_url(@account.avatar.url(:original)) }/ - %meta{ property: 'og:image:width', content: '120' }/ - %meta{ property: 'og:image:height', content: '120' }/ + = render 'stream_entries/og_description', activity: @stream_entry.activity + = render 'stream_entries/og_image', activity: @stream_entry.activity, account: @account %meta{ property: 'twitter:card', content: 'summary' }/ |