Skip to content

Commit 06d1c2e

Browse files
committed
Change layout of public profile directory to be the same as in web UI
1 parent 7235f53 commit 06d1c2e

6 files changed

Lines changed: 83 additions & 5 deletions

File tree

app/controllers/directories_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def set_tag
2828
end
2929

3030
def set_accounts
31-
@accounts = Account.local.discoverable.by_recent_status.page(params[:page]).per(15).tap do |query|
31+
@accounts = Account.local.discoverable.by_recent_status.page(params[:page]).per(20).tap do |query|
3232
query.merge!(Account.tagged_with(@tag.id)) if @tag
3333
query.merge!(Account.not_excluded_by_account(current_account)) if current_account
3434
end

app/helpers/statuses_helper.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ def account_action_button(account)
3434
end
3535
end
3636

37+
def minimal_account_action_button(account)
38+
if user_signed_in?
39+
return if account.id == current_user.account_id
40+
41+
if current_account.following?(account) || current_account.requested?(account)
42+
link_to account_unfollow_path(account), class: 'icon-button active', data: { method: :post }, title: t('accounts.unfollow') do
43+
fa_icon('user-times fw')
44+
end
45+
elsif !(account.memorial? || account.moved?)
46+
link_to account_follow_path(account), class: "icon-button#{account.blocking?(current_account) ? ' disabled' : ''}", data: { method: :post }, title: t('accounts.follow') do
47+
fa_icon('user-plus fw')
48+
end
49+
end
50+
elsif !(account.memorial? || account.moved?)
51+
link_to account_remote_follow_path(account), class: 'icon-button modal-button', target: '_new', title: t('accounts.follow') do
52+
fa_icon('user-plus fw')
53+
end
54+
end
55+
end
56+
3757
def svg_logo
3858
content_tag(:svg, tag(:use, 'xlink:href' => '#mastodon-svg-logo'), 'viewBox' => '0 0 216.4144 232.00976')
3959
end

app/javascript/mastodon/features/directory/components/account_card.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class AccountCard extends ImmutablePureComponent {
119119
return (
120120
<div className='directory__card'>
121121
<div className='directory__card__img'>
122-
<img src={autoPlayGif ? account.get('header') : account.get('header_static')} alt='' className='parallax' />
122+
<img src={autoPlayGif ? account.get('header') : account.get('header_static')} alt='' />
123123
</div>
124124

125125
<div className='directory__card__bar'>
@@ -134,7 +134,7 @@ class AccountCard extends ImmutablePureComponent {
134134
</div>
135135

136136
<div className='directory__card__extra'>
137-
{account.get('note').length > 0 && account.get('note') !== '<p></p>' && <div className='account__header__content' dangerouslySetInnerHTML={{ __html: account.get('note_emojified') }} />}
137+
<div className='account__header__content' dangerouslySetInnerHTML={{ __html: account.get('note_emojified') }} />
138138
</div>
139139

140140
<div className='directory__card__extra'>

app/javascript/styles/mastodon/components.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5367,6 +5367,7 @@ a.status-card.compact:hover {
53675367
height: 125px;
53685368
position: relative;
53695369
background: darken($ui-base-color, 12%);
5370+
overflow: hidden;
53705371

53715372
img {
53725373
display: block;
@@ -5388,6 +5389,7 @@ a.status-card.compact:hover {
53885389
display: flex;
53895390
align-items: center;
53905391
text-decoration: none;
5392+
overflow: hidden;
53915393
}
53925394

53935395
&__relationship {
@@ -5453,6 +5455,7 @@ a.status-card.compact:hover {
54535455
padding: 15px 10px;
54545456
border-bottom: 1px solid lighten($ui-base-color, 8%);
54555457
width: 100%;
5458+
min-height: 18px + 30px;
54565459
white-space: nowrap;
54575460
overflow: hidden;
54585461
text-overflow: ellipsis;
@@ -5464,6 +5467,10 @@ a.status-card.compact:hover {
54645467
display: inline;
54655468
}
54665469
}
5470+
5471+
br {
5472+
display: none;
5473+
}
54675474
}
54685475
}
54695476
}

app/javascript/styles/mastodon/containers.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,24 @@
763763
}
764764
}
765765

766+
.directory__list {
767+
display: grid;
768+
grid-gap: 10px;
769+
grid-template-columns: minmax(0, 50%) minmax(0, 50%);
770+
771+
@media screen and (max-width: $no-gap-breakpoint) {
772+
display: block;
773+
}
774+
775+
.icon-button {
776+
font-size: 18px;
777+
}
778+
}
779+
780+
.directory__card {
781+
margin-bottom: 0;
782+
}
783+
766784
.card-grid {
767785
display: flex;
768786
flex-wrap: wrap;

app/views/directories/index.html.haml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,40 @@
1717
- if @accounts.empty?
1818
= nothing_here
1919
- else
20-
.card-grid
21-
= render partial: 'application/card', collection: @accounts, as: :account
20+
.directory__list
21+
- @accounts.each do |account|
22+
.directory__card
23+
.directory__card__img
24+
= image_tag account.header.url, alt: ''
25+
.directory__card__bar
26+
= link_to TagManager.instance.url_for(account), class: 'directory__card__bar__name' do
27+
.avatar
28+
= image_tag account.avatar.url, alt: '', width: 48, height: 48, class: 'u-photo'
29+
30+
.display-name
31+
%span{ id: "default_account_display_name", style: "display: none" }= account.username
32+
%bdi
33+
%strong.emojify.p-name= display_name(account, custom_emojify: true)
34+
%span= acct(account)
35+
.directory__card__bar__relationship.account__relationship
36+
= minimal_account_action_button(account)
37+
38+
.directory__card__extra
39+
.account__header__content.emojify= Formatter.instance.simplified_format(account, custom_emojify: true)
40+
41+
.directory__card__extra
42+
.accounts-table__count
43+
= number_to_human account.statuses_count, strip_insignificant_zeros: true
44+
%small= t('accounts.posts', count: account.statuses_count).downcase
45+
.accounts-table__count
46+
= number_to_human account.followers_count, strip_insignificant_zeros: true
47+
%small= t('accounts.followers', count: account.followers_count).downcase
48+
.accounts-table__count
49+
- if account.last_status_at.present?
50+
%time.time-ago{ datetime: account.last_status_at.iso8601, title: l(account.last_status_at) }= l account.last_status_at
51+
- else
52+
= t('invites.expires_in_prompt')
53+
54+
%small= t('accounts.last_active')
2255

2356
= paginate @accounts

0 commit comments

Comments
 (0)