From b6e481d63eec15191f2717957682c13ee8a68308 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Wed, 26 Mar 2025 16:59:39 +0100 Subject: [feature] Allow user to choose "gallery" style layout for web view of profile (#3917) * [feature] Allow user to choose "gallery" style web layout * find a bug and squish it up and all day long you'll have good luck * just a sec * [performance] reindex public timeline + tinker with query a bit * fiddling * should be good now * last bit of finagling, i'm done now i prommy * panic normally --- web/template/profile-gallery.tmpl | 87 ++++++++++++++++ web/template/profile.tmpl | 197 ++--------------------------------- web/template/profile_about_user.tmpl | 56 ++++++++++ web/template/profile_header.tmpl | 185 ++++++++++++++++++++++++++++++++ web/template/status.tmpl | 20 +++- web/template/status_attachment.tmpl | 179 +++++++++++++++++++++++++++++++ web/template/status_attachments.tmpl | 195 ---------------------------------- web/template/status_info.tmpl | 29 +----- 8 files changed, 533 insertions(+), 415 deletions(-) create mode 100644 web/template/profile-gallery.tmpl create mode 100644 web/template/profile_about_user.tmpl create mode 100644 web/template/profile_header.tmpl create mode 100644 web/template/status_attachment.tmpl delete mode 100644 web/template/status_attachments.tmpl (limited to 'web/template') diff --git a/web/template/profile-gallery.tmpl b/web/template/profile-gallery.tmpl new file mode 100644 index 000000000..badb04615 --- /dev/null +++ b/web/template/profile-gallery.tmpl @@ -0,0 +1,87 @@ +{{- /* +// GoToSocial +// Copyright (C) GoToSocial Authors admin@gotosocial.org +// SPDX-License-Identifier: AGPL-3.0-or-later +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +*/ -}} + +{{- with . }} +
+ {{- with . }} + {{- include "profile_header.tmpl" . | indent 1 }} + {{- end }} + {{- with . }} + {{- include "profile_about_user.tmpl" . | indent 1 }} + {{- end }} +
+ {{- if .pinned_statuses }} +
+
+

Pinned media

+ jump to recent +
+ +
+ {{- end }} +
+
+

Recent media

+ {{- if .rssFeed }} + + + + {{- end }} +
+ {{- if not .galleryItems }} +
+ {{- if .show_back_to_top }} + Reached the end of visible media! + {{- else }} + Nothing to see here! {{ .account.Username }} has either not posted any public media yet, or has opted not to make posts visible via the World Wide Web. + {{- end }} +
+ {{- else }} + + {{- end }} + +
+
+
+{{- end }} \ No newline at end of file diff --git a/web/template/profile.tmpl b/web/template/profile.tmpl index 6b486eb74..d7d24cb64 100644 --- a/web/template/profile.tmpl +++ b/web/template/profile.tmpl @@ -17,200 +17,15 @@ // along with this program. If not, see . */ -}} -{{- define "profileMovedTo" -}} -{{- with .account.Moved }} -
- - ℹ️ This account has permanently moved to - - @{{ .Username }} - - -
-{{- end }} -{{- end -}} - -{{- define "defaultAvatarDimension" -}} -{{- /* 136 is the default width/height for 8.5rem avatars, double it to get a good look when expanded. */ -}} -272 -{{- end -}} - -{{- define "avatarWidth" -}} -{{- with .account }} - {{- if isNil .AvatarAttachment -}} - {{- template "defaultAvatarDimension" . -}} - {{- else -}} - {{- /* Use the avatar's proper dimensions. */ -}} - {{- .AvatarAttachment.Meta.Original.Width -}} - {{- end -}} -{{- end }} -{{- end -}} - -{{- define "avatarHeight" -}} -{{- with .account }} - {{- if isNil .AvatarAttachment -}} - {{- template "defaultAvatarDimension" . -}} - {{- else -}} - {{- /* Use the avatar's proper dimensions. */ -}} - {{- .AvatarAttachment.Meta.Original.Height -}} - {{- end -}} -{{- end }} -{{- end -}} - -{{- define "avatarAlt" -}} - Avatar for {{ .account.Username -}} - {{- if .account.AvatarDescription }} - {{- /* Add the avatar's image description. */ -}} - : {{ .account.AvatarDescription -}} - {{- end -}} -{{- end -}} - -{{- define "headerAlt" -}} - Header for {{ .account.Username -}} - {{- if .account.HeaderDescription }} - {{- /* Add the header's image description. */ -}} - : {{ .account.HeaderDescription -}} - {{- end -}} -{{- end -}} - -{{- define "avatar" -}} -{{- with . }} - -{{- end }} -{{- end -}} - {{- with . }}
-

Profile for {{ .account.Username -}}

-
- {{- if .account.Moved }} - {{- include "profileMovedTo" . | indent 2 }} - {{- end }} -
- - {{- if .account.HeaderAttachment }} - - {{- end }} - {{- template - -
-
- {{- with . }} - {{- include "avatar" . | indent 3 }} - {{- end }} -
-
Display name
-
- {{- if .account.DisplayName -}} - {{- emojify .account.Emojis (escape .account.DisplayName) -}} - {{- else -}} - {{- .account.Username -}} - {{- end -}} -
-
- {{- if .account.Bot }} -
Bot account
-
- true - -
- {{- end }} -
Username
-
@{{- .account.Username -}}@{{- .instance.AccountDomain -}}
-
- {{- if .account.Roles }} -
Role
- {{- range .account.Roles }} -
{{- .Name -}}
- {{- end }} - {{- end }} -
- -
-
+ {{- with . }} + {{- include "profile_header.tmpl" . | indent 1 }} + {{- end }}
-
-
-

About {{- .account.Username -}}

-
- {{- if .account.Fields }} - {{- include "profile_fields.tmpl" . | indent 3 }} - {{- end }} -

Bio

-
- {{- if .account.Note }} - {{ emojify .account.Emojis (noescape .account.Note) }} - {{- else }} -

This GoToSocial user hasn't written a bio yet!

- {{- end }} -
-

Stats

-
-
Joined
-
-
Posts
-
{{- .account.StatusesCount -}}
-
Followed by
-
{{- if .account.HideCollections -}}hidden{{- else -}}{{- .account.FollowersCount -}}{{- end -}}
-
Following
-
{{- if .account.HideCollections -}}hidden{{- else -}}{{- .account.FollowingCount -}}{{- end -}}
-
-
+ {{- with . }} + {{- include "profile_about_user.tmpl" . | indent 2 }} + {{- end }}
{{- if .pinned_statuses }}
diff --git a/web/template/profile_about_user.tmpl b/web/template/profile_about_user.tmpl new file mode 100644 index 000000000..7f3ce0e97 --- /dev/null +++ b/web/template/profile_about_user.tmpl @@ -0,0 +1,56 @@ +{{- /* +// GoToSocial +// Copyright (C) GoToSocial Authors admin@gotosocial.org +// SPDX-License-Identifier: AGPL-3.0-or-later +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +*/ -}} + +{{- with . }} +
+
+

About {{- .account.Username -}}

+
+ {{- if .account.Fields }} + {{- include "profile_fields.tmpl" . | indent 1 }} + {{- end }} +

Bio

+
+ {{- if .account.Note }} + {{ emojify .account.Emojis (noescape .account.Note) }} + {{- else }} +

This GoToSocial user hasn't written a bio yet!

+ {{- end }} +
+

Stats

+
+
+
Joined
+
+
+
+
Posts
+
{{- .account.StatusesCount -}}
+
+
+
Followed by
+
{{- if .account.HideCollections -}}hidden{{- else -}}{{- .account.FollowersCount -}}{{- end -}}
+
+
+
Following
+
{{- if .account.HideCollections -}}hidden{{- else -}}{{- .account.FollowingCount -}}{{- end -}}
+
+
+
+{{- end }} \ No newline at end of file diff --git a/web/template/profile_header.tmpl b/web/template/profile_header.tmpl new file mode 100644 index 000000000..4be900287 --- /dev/null +++ b/web/template/profile_header.tmpl @@ -0,0 +1,185 @@ +{{- /* +// GoToSocial +// Copyright (C) GoToSocial Authors admin@gotosocial.org +// SPDX-License-Identifier: AGPL-3.0-or-later +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +*/ -}} + +{{- define "profileMovedTo" -}} +{{- with .account.Moved }} +
+ + ℹ️ This account has permanently moved to + + @{{ .Username }} + + +
+{{- end }} +{{- end -}} + +{{- define "defaultAvatarDimension" -}} +{{- /* 136 is the default width/height for 8.5rem avatars, double it to get a good look when expanded. */ -}} +272 +{{- end -}} + +{{- define "avatarWidth" -}} +{{- with .account }} + {{- if isNil .AvatarAttachment -}} + {{- template "defaultAvatarDimension" . -}} + {{- else -}} + {{- /* Use the avatar's proper dimensions. */ -}} + {{- .AvatarAttachment.Meta.Original.Width -}} + {{- end -}} +{{- end }} +{{- end -}} + +{{- define "avatarHeight" -}} +{{- with .account }} + {{- if isNil .AvatarAttachment -}} + {{- template "defaultAvatarDimension" . -}} + {{- else -}} + {{- /* Use the avatar's proper dimensions. */ -}} + {{- .AvatarAttachment.Meta.Original.Height -}} + {{- end -}} +{{- end }} +{{- end -}} + +{{- define "avatarAlt" -}} + Avatar for {{ .account.Username -}} + {{- if .account.AvatarDescription }} + {{- /* Add the avatar's image description. */ -}} + : {{ .account.AvatarDescription -}} + {{- end -}} +{{- end -}} + +{{- define "headerAlt" -}} + Header for {{ .account.Username -}} + {{- if .account.HeaderDescription }} + {{- /* Add the header's image description. */ -}} + : {{ .account.HeaderDescription -}} + {{- end -}} +{{- end -}} + +{{- define "avatar" -}} +{{- with . }} + +{{- end }} +{{- end -}} + +{{- with . }} +

Profile for {{ .account.Username -}}

+
+ {{- if .account.Moved }} + {{- include "profileMovedTo" . | indent 2 }} + {{- end }} +
+ + {{- if .account.HeaderAttachment }} + + {{- end }} + {{- template + +
+
+ {{- with . }} + {{- include "avatar" . | indent 3 }} + {{- end }} +
+
Display name
+
+ {{- if .account.DisplayName -}} + {{- emojify .account.Emojis (escape .account.DisplayName) -}} + {{- else -}} + {{- .account.Username -}} + {{- end -}} +
+
+ {{- if .account.Bot }} +
Bot account
+
+ true + +
+ {{- end }} +
Username
+
@{{- .account.Username -}}@{{- .instance.AccountDomain -}}
+
+ {{- if .account.Roles }} +
Role
+ {{- range .account.Roles }} +
{{- .Name -}}
+ {{- end }} + {{- end }} +
+ +
+
+{{- end }} \ No newline at end of file diff --git a/web/template/status.tmpl b/web/template/status.tmpl index 85000fd72..872b784ed 100644 --- a/web/template/status.tmpl +++ b/web/template/status.tmpl @@ -30,6 +30,16 @@ it in an appropriate
! */ -}} +{{- /* Produces something like "1 attachment", "2 attachments", etc */ -}} +{{- define "attachmentsLength" -}} +{{- (len .) }}{{- if eq (len .) 1 }} attachment{{- else }} attachments{{- end -}} +{{- end -}} + +{{- /* Produces something like "media photoswipe-gallery odd single" */ -}} +{{- define "galleryClass" -}} +media photoswipe-gallery {{ (len .) | oddOrEven }} {{ if eq (len .) 1 }}single{{ else if eq (len .) 2 }}double{{ end }} +{{- end -}} + {{- with . }}
{{- include "status_header.tmpl" . | indent 1 }} @@ -63,7 +73,15 @@
{{- end }} {{- if .MediaAttachments }} - {{- include "status_attachments.tmpl" . | indent 1 }} +
+ {{- range $index, $media := .MediaAttachments }} + {{- includeIndex "status_attachment.tmpl" $media $index | indent 2 }} + {{- end }} +
{{- end }}