Update account, status meta tags

• Update:
- account, status meta tags
This commit is contained in:
mgabdev
2020-05-26 20:12:19 -04:00
parent 7483c1de2c
commit 8d6d85f829
39 changed files with 49 additions and 69 deletions

View File

@@ -15,8 +15,9 @@ class ReactController < ApplicationController
def set_data_for_meta
return if find_route_matches
if request.path.starts_with?('/tags') && params[:tag].present?
@tag = Tag.find_normalized(params[:tag])
if request.path.count("/") == 1 && !request.path.include?("@")
acctFromPath = request.path.sub("/", "")
@account = Account.find_local!(acctFromPath)
end
end
@@ -31,7 +32,7 @@ class ReactController < ApplicationController
end
def find_route_matches
request.path.match(/\A\/(home|groups|lists|notifications|explore|follow_requests|blocks|domain_blocks|mutes)/)
request.path.match(/\A\/(home|group|groups|list|lists|notifications|explore|search|tags|compose|follow_requests|admin|account|settings|filters|timeline|blocks|domain_blocks|mutes)/)
end
def set_initial_state_json

View File

@@ -65,24 +65,7 @@ module StreamEntriesHelper
end
def account_description(account)
prepend_str = [
[
number_to_human(account.statuses_count, strip_insignificant_zeros: true),
I18n.t('accounts.posts', count: account.statuses_count),
].join(' '),
[
number_to_human(account.following_count, strip_insignificant_zeros: true),
I18n.t('accounts.following', count: account.following_count),
].join(' '),
[
number_to_human(account.followers_count, strip_insignificant_zeros: true),
I18n.t('accounts.followers', count: account.followers_count),
].join(' '),
].join(', ')
[prepend_str, account.note].join(' · ')
return "The latest Gabs from #{display_name(account)} (@#{account.username}). #{account.note}"
end
def media_summary(status)
@@ -113,7 +96,7 @@ module StreamEntriesHelper
status.preloadable_poll.options.map { |o| "[ ] #{o}" }.join("\n")
end
def status_description(status)
def status_description(status, account)
components = [[media_summary(status), status_text_summary(status)].reject(&:blank?).join(' · ')]
if status.spoiler_text.blank?
@@ -121,7 +104,7 @@ module StreamEntriesHelper
components << poll_summary(status)
end
components.reject(&:blank?).join("\n\n")
return "#{display_name(account)} (@#{account.username}) on Gab. #{components.reject(&:blank?).join("\n\n")}"
end
def stream_link_target

View File

@@ -1,9 +1,7 @@
- content_for :page_title do
= "#{display_name(account)} (@#{account.local_username_and_domain}) | #{site_hostname}"
= "#{display_name(account)} (@#{account.username}) #{site_hostname}"
- content_for :header_tags do
%meta{ name: 'description', content: account_description(account) }/
- if account.user&.setting_noindex
%meta{ name: 'robots', content: 'noindex' }/
@@ -12,10 +10,10 @@
%link{ rel: 'alternate', type: 'application/rss+xml', href: account_url(account, format: 'rss') }/
%link{ rel: 'alternate', type: 'application/activity+json', href: ActivityPub::TagManager.instance.uri_for(account) }/
= opengraph 'og:type', 'profile'
= render 'accounts/og', account: account, url: short_account_url(account, only_path: false)
- if older_url
%link{ rel: 'next', href: older_url }/
- if newer_url
%link{ rel: 'prev', href: newer_url }/
= opengraph 'og:type', 'profile'
= render 'accounts/og', account: account, url: short_account_url(account, only_path: false)

View File

@@ -4,7 +4,7 @@
= opengraph 'og:url', url
= opengraph 'og:site_name', site_title
= opengraph 'og:title', yield(:page_title).strip
= opengraph 'og:title', "#{display_name(account)} (@#{account.username}) • #{site_hostname}"
= opengraph 'og:description', description
= opengraph 'og:image', full_asset_url(account.avatar.url(:original))
= opengraph 'og:image:width', '120'

View File

@@ -32,9 +32,7 @@
%meta{ name: 'apple-mobile-web-app-capable', content: 'yes' }/
%meta{ name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' }/
- if @tag
= render 'tags/meta', tag: @tag, initial_state_json: @initial_state_json
- elsif @stream_entry && @account
- if @stream_entry && @account
= render 'stream_entries/meta', stream_entry: @stream_entry, account: @account
- elsif @account && @account.local?
= render 'accounts/meta', account: @account, older_url: nil, newer_url: nil

View File

@@ -1,5 +1,5 @@
- content_for :page_title do
= t('statuses.title', name: display_name(account), quote: truncate(stream_entry.activity.spoiler_text.presence || stream_entry.activity.text, length: 50, omission: '…', escape: false)) + " | #{site_hostname}"
= t('statuses.title', name: display_name(account), quote: truncate(stream_entry.activity.spoiler_text.presence || stream_entry.activity.text, length: 50, omission: '…', escape: false))
- content_for :header_tags do
- if account.user&.setting_noindex
@@ -11,8 +11,8 @@
= opengraph 'og:site_name', site_title
= opengraph 'og:type', 'article'
= opengraph 'og:title', "#{display_name(account)} (@#{account.local_username_and_domain})"
= opengraph 'og:title', t('statuses.title', name: display_name(account), quote: truncate(stream_entry.activity.spoiler_text.presence || stream_entry.activity.text, length: 50, omission: '…', escape: false))
= opengraph 'og:url', short_account_status_url(account, stream_entry.activity)
= render 'stream_entries/og_description', activity: stream_entry.activity
= render 'stream_entries/og_description', activity: stream_entry.activity, account: account
= render 'stream_entries/og_image', activity: stream_entry.activity, account: account

View File

@@ -1,4 +1,4 @@
- description = status_description(activity)
- description = t('statuses.title', name: display_name(account), quote: truncate(activity.spoiler_text.presence || activity.text, length: 50, omission: '…', escape: false))
%meta{ name: 'description', content: description }/
= opengraph 'og:description', description