From 027a93facc73b78e3c3747ab796f4a14b1b4936f Mon Sep 17 00:00:00 2001
From: tobi <31960611+tsmethurst@users.noreply.github.com>
Date: Sun, 21 Jul 2024 14:22:08 +0200
Subject: [feature/frontend] Respect `prefers-reduced-motion` for avatars,
headers, and emojis (#3118)
* [feature/frontend] Respect `prefers-reduced-motion` for avatars, headers, and emojis
* go fmt
* fix tests
* use static version of instance thumbnail when appropriate
* use prefers-reduced-motion
* simplify account conversion a bit
* fix c&p error
---
internal/processing/account/get.go | 2 +-
internal/processing/account/rss_test.go | 116 +++++++++++++++++++++++++++++++-
2 files changed, 114 insertions(+), 4 deletions(-)
(limited to 'internal/processing/account')
diff --git a/internal/processing/account/get.go b/internal/processing/account/get.go
index 32d45054d..eac0f0c3f 100644
--- a/internal/processing/account/get.go
+++ b/internal/processing/account/get.go
@@ -98,7 +98,7 @@ func (p *Processor) Get(ctx context.Context, requestingAccount *gtsmodel.Account
}
// GetWeb returns the web model of a local account by username.
-func (p *Processor) GetWeb(ctx context.Context, username string) (*apimodel.Account, gtserror.WithCode) {
+func (p *Processor) GetWeb(ctx context.Context, username string) (*apimodel.WebAccount, gtserror.WithCode) {
targetAccount, err := p.state.DB.GetAccountByUsernameDomain(ctx, username, "")
if err != nil {
if errors.Is(err, db.ErrNoEntries) {
diff --git a/internal/processing/account/rss_test.go b/internal/processing/account/rss_test.go
index 0b1ae561d..e4706d3b7 100644
--- a/internal/processing/account/rss_test.go
+++ b/internal/processing/account/rss_test.go
@@ -35,7 +35,36 @@ func (suite *GetRSSTestSuite) TestGetAccountRSSAdmin() {
feed, err := getFeed()
suite.NoError(err)
- suite.Equal("\n \n Posts from @admin@localhost:8080\n http://localhost:8080/@admin\n Posts from @admin@localhost:8080\n Wed, 20 Oct 2021 10:41:37 +0000\n Wed, 20 Oct 2021 10:41:37 +0000\n - \n open to see some puppies\n http://localhost:8080/@admin/statuses/01F8MHAAY43M6RJ473VQFCVH37\n @admin@localhost:8080 made a new post: "🐕🐕🐕🐕🐕"\n \n @admin@localhost:8080\n http://localhost:8080/@admin/statuses/01F8MHAAY43M6RJ473VQFCVH37\n Wed, 20 Oct 2021 12:36:45 +0000\n http://localhost:8080/@admin/feed.rss\n
\n - \n hello world! #welcome ! first post on the instance :rainbow: !\n http://localhost:8080/@admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R\n @admin@localhost:8080 posted 1 attachment: "hello world! #welcome ! first post on the instance :rainbow: !"\n !]]>\n @admin@localhost:8080\n \n http://localhost:8080/@admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R\n Wed, 20 Oct 2021 11:36:45 +0000\n http://localhost:8080/@admin/feed.rss\n
\n \n", feed)
+ suite.Equal(`
+
+ Posts from @admin@localhost:8080
+ http://localhost:8080/@admin
+ Posts from @admin@localhost:8080
+ Wed, 20 Oct 2021 10:41:37 +0000
+ Wed, 20 Oct 2021 10:41:37 +0000
+ -
+ open to see some puppies
+ http://localhost:8080/@admin/statuses/01F8MHAAY43M6RJ473VQFCVH37
+ @admin@localhost:8080 made a new post: "🐕🐕🐕🐕🐕"
+
+ @admin@localhost:8080
+ http://localhost:8080/@admin/statuses/01F8MHAAY43M6RJ473VQFCVH37
+ Wed, 20 Oct 2021 12:36:45 +0000
+ http://localhost:8080/@admin/feed.rss
+
+ -
+ hello world! #welcome ! first post on the instance :rainbow: !
+ http://localhost:8080/@admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R
+ @admin@localhost:8080 posted 1 attachment: "hello world! #welcome ! first post on the instance :rainbow: !"
+ !]]>
+ @admin@localhost:8080
+
+ http://localhost:8080/@admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R
+ Wed, 20 Oct 2021 11:36:45 +0000
+ http://localhost:8080/@admin/feed.rss
+
+
+`, feed)
}
func (suite *GetRSSTestSuite) TestGetAccountRSSZork() {
@@ -45,7 +74,75 @@ func (suite *GetRSSTestSuite) TestGetAccountRSSZork() {
feed, err := getFeed()
suite.NoError(err)
- suite.Equal("\n \n Posts from @the_mighty_zork@localhost:8080\n http://localhost:8080/@the_mighty_zork\n Posts from @the_mighty_zork@localhost:8080\n Wed, 10 Jan 2024 09:24:00 +0000\n Wed, 10 Jan 2024 09:24:00 +0000\n \n http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp\n Avatar for @the_mighty_zork@localhost:8080\n http://localhost:8080/@the_mighty_zork\n \n - \n HTML in post\n http://localhost:8080/@the_mighty_zork/statuses/01HH9KYNQPA416TNJ53NSATP40\n @the_mighty_zork@localhost:8080 made a new post: "Here's a bunch of HTML, read it and weep, weep then!
```html
<section class="about-user">
<div class="col-header">
<h2>About</h2>
</div>
<div class="fields">
<h3 class="sr-only">Fields</h3>
<dl>
...\n Here's a bunch of HTML, read it and weep, weep then!
<section class="about-user">\n <div class="col-header">\n <h2>About</h2>\n </div> \n <div class="fields">\n <h3 class="sr-only">Fields</h3>\n <dl>\n <div class="field">\n <dt>should you follow me?</dt>\n <dd>maybe!</dd>\n </div>\n <div class="field">\n <dt>age</dt>\n <dd>120</dd>\n </div>\n </dl>\n </div>\n <div class="bio">\n <h3 class="sr-only">Bio</h3>\n <p>i post about things that concern me</p>\n </div>\n <div class="sr-only" role="group">\n <h3 class="sr-only">Stats</h3>\n <span>Joined in Jun, 2022.</span>\n <span>8 posts.</span>\n <span>Followed by 1.</span>\n <span>Following 1.</span>\n </div>\n <div class="accountstats" aria-hidden="true">\n <b>Joined</b><time datetime="2022-06-04T13:12:00.000Z">Jun, 2022</time>\n <b>Posts</b><span>8</span>\n <b>Followed by</b><span>1</span>\n <b>Following</b><span>1</span>\n </div>\n</section>\n
There, hope you liked that!
]]>\n @the_mighty_zork@localhost:8080\n http://localhost:8080/@the_mighty_zork/statuses/01HH9KYNQPA416TNJ53NSATP40\n Sun, 10 Dec 2023 09:24:00 +0000\n http://localhost:8080/@the_mighty_zork/feed.rss\n \n - \n introduction post\n http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY\n @the_mighty_zork@localhost:8080 made a new post: "hello everyone!"\n \n @the_mighty_zork@localhost:8080\n http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY\n Wed, 20 Oct 2021 10:40:37 +0000\n http://localhost:8080/@the_mighty_zork/feed.rss\n
\n \n", feed)
+ suite.Equal(`
+
+ Posts from @the_mighty_zork@localhost:8080
+ http://localhost:8080/@the_mighty_zork
+ Posts from @the_mighty_zork@localhost:8080
+ Wed, 10 Jan 2024 09:24:00 +0000
+ Wed, 10 Jan 2024 09:24:00 +0000
+
+ http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp
+ Avatar for @the_mighty_zork@localhost:8080
+ http://localhost:8080/@the_mighty_zork
+
+ -
+ HTML in post
+ http://localhost:8080/@the_mighty_zork/statuses/01HH9KYNQPA416TNJ53NSATP40
+ @the_mighty_zork@localhost:8080 made a new post: "Here's a bunch of HTML, read it and weep, weep then!
`+"```"+`html
<section class="about-user">
<div class="col-header">
<h2>About</h2>
</div>
<div class="fields">
<h3 class="sr-only">Fields</h3>
<dl>
...
+ Here's a bunch of HTML, read it and weep, weep then!
<section class="about-user">
+ <div class="col-header">
+ <h2>About</h2>
+ </div>
+ <div class="fields">
+ <h3 class="sr-only">Fields</h3>
+ <dl>
+ <div class="field">
+ <dt>should you follow me?</dt>
+ <dd>maybe!</dd>
+ </div>
+ <div class="field">
+ <dt>age</dt>
+ <dd>120</dd>
+ </div>
+ </dl>
+ </div>
+ <div class="bio">
+ <h3 class="sr-only">Bio</h3>
+ <p>i post about things that concern me</p>
+ </div>
+ <div class="sr-only" role="group">
+ <h3 class="sr-only">Stats</h3>
+ <span>Joined in Jun, 2022.</span>
+ <span>8 posts.</span>
+ <span>Followed by 1.</span>
+ <span>Following 1.</span>
+ </div>
+ <div class="accountstats" aria-hidden="true">
+ <b>Joined</b><time datetime="2022-06-04T13:12:00.000Z">Jun, 2022</time>
+ <b>Posts</b><span>8</span>
+ <b>Followed by</b><span>1</span>
+ <b>Following</b><span>1</span>
+ </div>
+</section>
+
There, hope you liked that!
]]>
+ @the_mighty_zork@localhost:8080
+ http://localhost:8080/@the_mighty_zork/statuses/01HH9KYNQPA416TNJ53NSATP40
+ Sun, 10 Dec 2023 09:24:00 +0000
+ http://localhost:8080/@the_mighty_zork/feed.rss
+
+ -
+ introduction post
+ http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY
+ @the_mighty_zork@localhost:8080 made a new post: "hello everyone!"
+
+ @the_mighty_zork@localhost:8080
+ http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY
+ Wed, 20 Oct 2021 10:40:37 +0000
+ http://localhost:8080/@the_mighty_zork/feed.rss
+
+
+`, feed)
}
func (suite *GetRSSTestSuite) TestGetAccountRSSZorkNoPosts() {
@@ -70,7 +167,20 @@ func (suite *GetRSSTestSuite) TestGetAccountRSSZorkNoPosts() {
feed, err := getFeed()
suite.NoError(err)
- suite.Equal("\n \n Posts from @the_mighty_zork@localhost:8080\n http://localhost:8080/@the_mighty_zork\n Posts from @the_mighty_zork@localhost:8080\n Fri, 20 May 2022 11:09:18 +0000\n Fri, 20 May 2022 11:09:18 +0000\n \n http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp\n Avatar for @the_mighty_zork@localhost:8080\n http://localhost:8080/@the_mighty_zork\n \n \n", feed)
+ suite.Equal(`
+
+ Posts from @the_mighty_zork@localhost:8080
+ http://localhost:8080/@the_mighty_zork
+ Posts from @the_mighty_zork@localhost:8080
+ Fri, 20 May 2022 11:09:18 +0000
+ Fri, 20 May 2022 11:09:18 +0000
+
+ http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp
+ Avatar for @the_mighty_zork@localhost:8080
+ http://localhost:8080/@the_mighty_zork
+
+
+`, feed)
}
func TestGetRSSTestSuite(t *testing.T) {
--
cgit v1.2.3