Skip to content

Commit bf91537

Browse files
Gargronhiyuki2578
authored andcommitted
Change OpenGraph description on sign-up page to reflect invite (mastodon#11744)
1 parent 6fa0d32 commit bf91537

4 files changed

Lines changed: 19 additions & 3 deletions

File tree

app/helpers/instance_helper.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,16 @@ def site_title
88
def site_hostname
99
@site_hostname ||= Addressable::URI.parse("//#{Rails.configuration.x.local_domain}").display_uri.host
1010
end
11+
12+
def description_for_sign_up
13+
prefix = begin
14+
if @invite.present?
15+
I18n.t('auth.description.prefix_invited_by_user', name: @invite.user.account.username)
16+
else
17+
I18n.t('auth.description.prefix_sign_up')
18+
end
19+
end
20+
21+
safe_join([prefix, I18n.t('auth.description.suffix')], ' ')
22+
end
1123
end

app/views/auth/registrations/new.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
= t('auth.register')
33

44
- content_for :header_tags do
5-
= render partial: 'shared/og'
5+
= render partial: 'shared/og', locals: { description: description_for_sign_up }
66

77
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
88
= render 'shared/error_messages', object: resource

app/views/shared/_og.html.haml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
- thumbnail = @instance_presenter.thumbnail
2-
- description = strip_tags(@instance_presenter.site_short_description.presence || @instance_presenter.site_description.presence || t('about.about_mastodon_html'))
1+
- thumbnail = @instance_presenter.thumbnail
2+
- description ||= strip_tags(@instance_presenter.site_short_description.presence || @instance_presenter.site_description.presence || t('about.about_mastodon_html'))
33

44
%meta{ name: 'description', content: description }/
55

config/locales/en.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,10 @@ en:
570570
checkbox_agreement_without_rules_html: I agree to the <a href="%{terms_path}" target="_blank">terms of service</a>
571571
delete_account: Delete account
572572
delete_account_html: If you wish to delete your account, you can <a href="%{path}">proceed here</a>. You will be asked for confirmation.
573+
description:
574+
prefix_invited_by_user: "@%{name} invites you to join this server of Mastodon!"
575+
prefix_sign_up: Sign up on Mastodon today!
576+
suffix: With an account, you will be able to follow people, post updates and exchange messages with users from any Mastodon server and more!
573577
didnt_get_confirmation: Didn't receive confirmation instructions?
574578
forgot_password: Forgot your password?
575579
invalid_reset_password_token: Password reset token is invalid or expired. Please request a new one.

0 commit comments

Comments
 (0)