mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-01 04:54:09 +00:00
1496bb6079
There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
128 lines
5 KiB
Go HTML Template
128 lines
5 KiB
Go HTML Template
<div id="profile-avatar-card" class="ui card">
|
|
<div id="profile-avatar" class="content tw-flex">
|
|
{{if eq .SignedUserID .ContextUser.ID}}
|
|
<a class="image" href="{{AppSubUrl}}/user/settings" data-tooltip-content="{{ctx.Locale.Tr "user.change_avatar"}}">
|
|
{{/* the size doesn't take affect (and no need to take affect), image size(width) should be controlled by the parent container since this is not a flex layout*/}}
|
|
{{ctx.AvatarUtils.Avatar .ContextUser 256}}
|
|
</a>
|
|
{{else}}
|
|
<span class="image">
|
|
{{ctx.AvatarUtils.Avatar .ContextUser 256}}
|
|
</span>
|
|
{{end}}
|
|
</div>
|
|
<div class="content tw-break-anywhere profile-avatar-name">
|
|
{{if .ContextUser.FullName}}<span class="header text center">{{.ContextUser.FullName}}</span>{{end}}
|
|
<span class="username text center">{{.ContextUser.Name}}{{if .ContextUser.Pronouns}} · {{.ContextUser.Pronouns}}{{end}} {{if .IsAdmin}}
|
|
<a class="muted" href="{{AppSubUrl}}/admin/users/{{.ContextUser.ID}}" data-tooltip-content="{{ctx.Locale.Tr "admin.users.details"}}">
|
|
{{svg "octicon-gear" 18}}
|
|
</a>
|
|
{{end}}</span>
|
|
<div class="tw-mt-2">
|
|
<a class="muted" href="{{.ContextUser.HomeLink}}?tab=followers">{{svg "octicon-people" 18 "tw-mr-1"}}{{ctx.Locale.TrN .NumFollowers "user.followers_one" "user.followers_few" .NumFollowers}}</a> · <a class="muted" href="{{.ContextUser.HomeLink}}?tab=following">{{ctx.Locale.TrN .NumFollowing "user.following_one" "user.following_few" .NumFollowing}}</a>
|
|
{{if and .EnableFeed (or .IsAdmin (eq .SignedUserID .ContextUser.ID) (not .ContextUser.KeepActivityPrivate))}}
|
|
<a href="{{.ContextUser.HomeLink}}.rss"><i class="ui text grey tw-ml-2" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}">{{svg "octicon-rss" 18}}</i></a>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
<div class="extra content tw-break-anywhere">
|
|
<ul>
|
|
{{if .ContextUser.Location}}
|
|
<li>
|
|
{{svg "octicon-location"}}
|
|
<span class="tw-flex-1">{{.ContextUser.Location}}</span>
|
|
{{if .ContextUserLocationMapURL}}
|
|
<a href="{{.ContextUserLocationMapURL}}" rel="nofollow noreferrer" data-tooltip-content="{{ctx.Locale.Tr "user.show_on_map"}}">
|
|
{{svg "octicon-link-external"}}
|
|
</a>
|
|
{{end}}
|
|
</li>
|
|
{{end}}
|
|
{{if .ShowUserEmail}}
|
|
<li>
|
|
{{svg "octicon-mail"}}
|
|
<a class="tw-flex-1" href="mailto:{{.ContextUser.Email}}" rel="nofollow">{{.ContextUser.Email}}</a>
|
|
{{if (eq .SignedUserID .ContextUser.ID)}}
|
|
<a href="{{AppSubUrl}}/user/settings#privacy-user-settings">
|
|
<i data-tooltip-content="{{ctx.Locale.Tr "user.email_visibility.limited"}}">
|
|
{{svg "octicon-unlock"}}
|
|
</i>
|
|
</a>
|
|
{{end}}
|
|
</li>
|
|
{{end}}
|
|
{{if .ContextUser.Website}}
|
|
<li>
|
|
{{svg "octicon-link"}}
|
|
<a target="_blank" rel="noopener noreferrer me" href="{{.ContextUser.Website}}">{{.ContextUser.Website}}</a>
|
|
</li>
|
|
{{end}}
|
|
{{if $.RenderedDescription}}
|
|
<li>
|
|
<div class="render-content markup">{{$.RenderedDescription}}</div>
|
|
</li>
|
|
{{end}}
|
|
{{range .OpenIDs}}
|
|
{{if .Show}}
|
|
<li>
|
|
{{svg "fontawesome-openid"}}
|
|
<a target="_blank" rel="noopener noreferrer" href="{{.URI}}">{{.URI}}</a>
|
|
</li>
|
|
{{end}}
|
|
{{end}}
|
|
<li>{{svg "octicon-calendar"}} <span>{{ctx.Locale.Tr "user.joined_on" (DateTime "short" .ContextUser.CreatedUnix)}}</span></li>
|
|
{{if and .Orgs .HasOrgsVisible}}
|
|
<li>
|
|
<ul class="user-orgs">
|
|
{{range .Orgs}}
|
|
{{if (or .Visibility.IsPublic (and ($.SignedUser) (or .Visibility.IsLimited (and (.HasMemberWithUserID ctx $.SignedUserID) .Visibility.IsPrivate) ($.IsAdmin))))}}
|
|
<li>
|
|
<a href="{{.HomeLink}}" data-tooltip-content="{{.Name}}">
|
|
{{ctx.AvatarUtils.Avatar .}}
|
|
</a>
|
|
</li>
|
|
{{end}}
|
|
{{end}}
|
|
</ul>
|
|
</li>
|
|
{{end}}
|
|
{{if .Badges}}
|
|
<li>
|
|
<ul class="user-badges">
|
|
{{range .Badges}}
|
|
<li>
|
|
<img width="64" height="64" src="{{.ImageURL}}" alt="{{.Description}}" data-tooltip-content="{{.Description}}">
|
|
</li>
|
|
{{end}}
|
|
</ul>
|
|
</li>
|
|
{{end}}
|
|
{{if and .IsSigned (ne .SignedUserID .ContextUser.ID)}}
|
|
<li class="follow" hx-target="#profile-avatar-card" hx-indicator="#profile-avatar-card" >
|
|
{{if $.IsFollowing}}
|
|
<button hx-post="{{.ContextUser.HomeLink}}?action=unfollow" class="ui basic red button">
|
|
{{svg "octicon-person"}} {{ctx.Locale.Tr "user.unfollow"}}
|
|
</button>
|
|
{{else}}
|
|
<button hx-post="{{.ContextUser.HomeLink}}?action=follow" class="ui basic primary button">
|
|
{{svg "octicon-person"}} {{ctx.Locale.Tr "user.follow"}}
|
|
</button>
|
|
{{end}}
|
|
</li>
|
|
<li class="block">
|
|
{{if $.IsBlocked}}
|
|
<button class="ui basic red button link-action" data-url="{{.ContextUser.HomeLink}}?action=unblock&redirect_to={{$.Link}}">
|
|
{{svg "octicon-person"}} {{ctx.Locale.Tr "user.unblock"}}
|
|
</button>
|
|
{{else}}
|
|
<button type="submit" class="ui basic orange button delete-button"
|
|
data-modal-id="block-user" data-url="{{.ContextUser.HomeLink}}?action=block">
|
|
{{svg "octicon-blocked"}} {{ctx.Locale.Tr "user.block"}}
|
|
</button>
|
|
{{end}}
|
|
</li>
|
|
{{end}}
|
|
</ul>
|
|
</div>
|
|
</div>
|