From a3f41917c7842a2d1b0c5986df0a7fabb37e53ee Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 27 Nov 2022 07:49:18 -0800 Subject: [PATCH] fix: change page titles (#2211) Co-authored-by: Gabriel de Perthuis --- src/intl/de.js | 4 ++-- src/intl/en-US.js | 4 ++-- src/intl/fr.js | 4 ++-- src/routes/accounts/[accountId]/followers.html | 10 ++++++++-- src/routes/accounts/[accountId]/follows.html | 10 ++++++++-- src/routes/accounts/[accountId]/index.html | 10 ++++++++-- src/routes/accounts/[accountId]/media.html | 10 ++++++++-- .../accounts/[accountId]/with_replies.html | 10 ++++++++-- tests/spec/102-notifications.js | 16 ++++++++-------- 9 files changed, 54 insertions(+), 24 deletions(-) diff --git a/src/intl/de.js b/src/intl/de.js index 32a30893..5dbd4f0c 100644 --- a/src/intl/de.js +++ b/src/intl/de.js @@ -170,12 +170,12 @@ export default { true {({count})} other {} } + {name} + · {showInstanceName, select, true {{instanceName}} other {Pinafore} } - · - {name} `, pinLabel: `{label} {pinnable, select, true { diff --git a/src/intl/en-US.js b/src/intl/en-US.js index 510f0f78..3f7c1b95 100644 --- a/src/intl/en-US.js +++ b/src/intl/en-US.js @@ -174,12 +174,12 @@ export default { true {({count})} other {} } + {name} + · {showInstanceName, select, true {{instanceName}} other {Pinafore} } - · - {name} `, pinLabel: `{label} {pinnable, select, true { diff --git a/src/intl/fr.js b/src/intl/fr.js index ed8a833d..32270228 100644 --- a/src/intl/fr.js +++ b/src/intl/fr.js @@ -171,12 +171,12 @@ export default { true {({count})} other {} } + {name} + · {showInstanceName, select, true {{instanceName}} other {Pinafore} } - · - {name} `, pinLabel: `{label} {pinnable, select, true { diff --git a/src/routes/accounts/[accountId]/followers.html b/src/routes/accounts/[accountId]/followers.html index 5d444876..b4a89768 100644 --- a/src/routes/accounts/[accountId]/followers.html +++ b/src/routes/accounts/[accountId]/followers.html @@ -1,4 +1,5 @@ - +<!-- TODO: this should probably be formatted as intl rather than concatenated --> +<Title name="{profileName}{intl.followers}" /> <LazyPage {pageComponent} {params} /> @@ -15,6 +16,11 @@ }, data: () => ({ pageComponent - }) + }), + computed: { + profileName: ({ $currentAccountProfile }) => { + return ($currentAccountProfile && ('@' + $currentAccountProfile.acct + ' · ')) || '' + } + } } </script> diff --git a/src/routes/accounts/[accountId]/follows.html b/src/routes/accounts/[accountId]/follows.html index cee4bf9e..328fda9a 100644 --- a/src/routes/accounts/[accountId]/follows.html +++ b/src/routes/accounts/[accountId]/follows.html @@ -1,4 +1,5 @@ -<Title name="{intl.follows}" /> +<!-- TODO: this should probably be formatted as intl rather than concatenated --> +<Title name="{profileName}{intl.follows}" /> <LazyPage {pageComponent} {params} /> @@ -15,6 +16,11 @@ }, data: () => ({ pageComponent - }) + }), + computed: { + profileName: ({ $currentAccountProfile }) => { + return ($currentAccountProfile && ('@' + $currentAccountProfile.acct + ' · ')) || '' + } + } } </script> diff --git a/src/routes/accounts/[accountId]/index.html b/src/routes/accounts/[accountId]/index.html index b4167479..1d07ab8a 100644 --- a/src/routes/accounts/[accountId]/index.html +++ b/src/routes/accounts/[accountId]/index.html @@ -1,4 +1,5 @@ -<Title name="{intl.profile}" /> +<!-- TODO: this should probably be formatted as intl rather than concatenated --> +<Title name="{profileName}{intl.profile}" /> <LazyPage {pageComponent} {params} /> @@ -15,6 +16,11 @@ }, data: () => ({ pageComponent - }) + }), + computed: { + profileName: ({ $currentAccountProfile }) => { + return ($currentAccountProfile && ('@' + $currentAccountProfile.acct + ' · ')) || '' + } + } } </script> diff --git a/src/routes/accounts/[accountId]/media.html b/src/routes/accounts/[accountId]/media.html index 5abf20d7..85cd789d 100644 --- a/src/routes/accounts/[accountId]/media.html +++ b/src/routes/accounts/[accountId]/media.html @@ -1,4 +1,5 @@ -<Title name="{intl.profileWithMedia}" /> +<!-- TODO: this should probably be formatted as intl rather than concatenated --> +<Title name="{profileName}{intl.profileWithMedia}" /> <LazyPage {pageComponent} {params} /> @@ -15,6 +16,11 @@ }, data: () => ({ pageComponent - }) + }), + computed: { + profileName: ({ $currentAccountProfile }) => { + return ($currentAccountProfile && ('@' + $currentAccountProfile.acct + ' · ')) || '' + } + } } </script> diff --git a/src/routes/accounts/[accountId]/with_replies.html b/src/routes/accounts/[accountId]/with_replies.html index 1a8de603..50fa2c1a 100644 --- a/src/routes/accounts/[accountId]/with_replies.html +++ b/src/routes/accounts/[accountId]/with_replies.html @@ -1,4 +1,5 @@ -<Title name="{intl.profileWithReplies}" /> +<!-- TODO: this should probably be formatted as intl rather than concatenated --> +<Title name="{profileName}{intl.profileWithReplies}" /> <LazyPage {pageComponent} {params} /> @@ -15,6 +16,11 @@ }, data: () => ({ pageComponent - }) + }), + computed: { + profileName: ({ $currentAccountProfile }) => { + return ($currentAccountProfile && ('@' + $currentAccountProfile.acct + ' · ')) || '' + } + } } </script> diff --git a/tests/spec/102-notifications.js b/tests/spec/102-notifications.js index bd5ba0cf..146bd29c 100644 --- a/tests/spec/102-notifications.js +++ b/tests/spec/102-notifications.js @@ -12,7 +12,7 @@ test('shows unread notification', async t => { await loginAsFoobar(t) await t .expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications') - .expect(getTitleText()).eql('localhost:3000 · Home') + .expect(getTitleText()).eql('Home · localhost:3000') .expect(getNthStatusContent(1).innerText).contains('somebody please favorite this to validate me', { timeout: 20000 }) @@ -21,17 +21,17 @@ test('shows unread notification', async t => { .expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (1 notification)', { timeout: 20000 }) - .expect(getTitleText()).eql('(1) localhost:3000 · Home') + .expect(getTitleText()).eql('(1) Home · localhost:3000') .click(notificationsNavButton) .expect(getUrl()).contains('/notifications') .expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (current page)') - .expect(getTitleText()).eql('localhost:3000 · Notifications') + .expect(getTitleText()).eql('Notifications · localhost:3000') .expect(getNthStatus(1).innerText).contains('somebody please favorite this to validate me') .expect(getNthStatus(1).innerText).match(/admin\s+favorited your toot/) await t .click(homeNavButton) .expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications') - .expect(getTitleText()).eql('localhost:3000 · Home') + .expect(getTitleText()).eql('Home · localhost:3000') }) test('shows unread notifications, more than one', async t => { @@ -39,7 +39,7 @@ test('shows unread notifications, more than one', async t => { await loginAsFoobar(t) await t .expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications') - .expect(getTitleText()).eql('localhost:3000 · Home') + .expect(getTitleText()).eql('Home · localhost:3000') .expect(getNthStatusContent(1).innerText).contains('I need lots of favorites on this one', { timeout: 20000 }) @@ -49,14 +49,14 @@ test('shows unread notifications, more than one', async t => { .expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (2 notifications)', { timeout: 20000 }) - .expect(getTitleText()).eql('(2) localhost:3000 · Home') + .expect(getTitleText()).eql('(2) Home · localhost:3000') .click(notificationsNavButton) .expect(getUrl()).contains('/notifications') .expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (current page)') - .expect(getTitleText()).eql('localhost:3000 · Notifications') + .expect(getTitleText()).eql('Notifications · localhost:3000') .expect(getNthStatus(1).innerText).contains('I need lots of favorites on this one') await t .click(homeNavButton) .expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications') - .expect(getTitleText()).eql('localhost:3000 · Home') + .expect(getTitleText()).eql('Home · localhost:3000') })