From 0ff52b71f2c0e970b1f0d43793c019bbed93e112 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Wed, 27 Dec 2023 11:23:52 +0100 Subject: [chore] Refactor HTML templates and CSS (#2480) * [chore] Refactor HTML templates and CSS * eslint * ignore "Local" * rss tests * fiddle with OG just a tiny bit * dick around with polls a bit more so SR stops saying "clickable" * remove break * oh lord * don't lazy load avatar * fix ogmeta tests * clean up some cruft * catch remaining calls to c.HTML * fix error rendering + stack overflow in tag * allow templating attributes * fix indent * set aria-hidden on status complementary content, since it's already present in the label anyway * tidy up templating calls a little * try to make styling a bit more consistent + readable * fix up some remaining CSS issues * fix up reports --- web/template/404.tmpl | 40 +++--- web/template/about.tmpl | 220 +++++++++++++++++-------------- web/template/authorize.tmpl | 44 +++---- web/template/confirmed.tmpl | 13 +- web/template/domain-blocklist.tmpl | 62 ++++----- web/template/error.tmpl | 22 ++-- web/template/finalize.tmpl | 59 ++++----- web/template/footer.tmpl | 46 ------- web/template/frontend.tmpl | 7 +- web/template/header.tmpl | 122 ------------------ web/template/index.tmpl | 74 +++-------- web/template/index_apps.tmpl | 115 +++++++++++++++++ web/template/oob.tmpl | 14 +- web/template/page.tmpl | 85 ++++++++++++ web/template/page_footer.tmpl | 67 ++++++++++ web/template/page_header.tmpl | 72 +++++++++++ web/template/page_ogmeta.tmpl | 57 +++++++++ web/template/page_stylesheets.tmpl | 41 ++++++ web/template/profile.tmpl | 242 +++++++++++++++++------------------ web/template/profile_fields.tmpl | 32 +++++ web/template/sign-in.tmpl | 10 +- web/template/status.tmpl | 154 ++++++++++------------ web/template/status_attachments.tmpl | 184 ++++++++++++++++---------- web/template/status_attributes.tmpl | 55 ++++++++ web/template/status_header.tmpl | 56 ++++++++ web/template/status_info.tmpl | 74 +++++++++++ web/template/status_poll.tmpl | 105 ++++++++------- web/template/tag.tmpl | 16 ++- web/template/thread.tmpl | 59 ++++++--- 29 files changed, 1339 insertions(+), 808 deletions(-) delete mode 100644 web/template/footer.tmpl delete mode 100644 web/template/header.tmpl create mode 100644 web/template/index_apps.tmpl create mode 100644 web/template/page.tmpl create mode 100644 web/template/page_footer.tmpl create mode 100644 web/template/page_header.tmpl create mode 100644 web/template/page_ogmeta.tmpl create mode 100644 web/template/page_stylesheets.tmpl create mode 100644 web/template/profile_fields.tmpl create mode 100644 web/template/status_attributes.tmpl create mode 100644 web/template/status_header.tmpl create mode 100644 web/template/status_info.tmpl (limited to 'web/template') diff --git a/web/template/404.tmpl b/web/template/404.tmpl index 2269d667b..cbad36091 100644 --- a/web/template/404.tmpl +++ b/web/template/404.tmpl @@ -17,23 +17,27 @@ // along with this program. If not, see . */ -}} -{{ template "header.tmpl" .}} +{{- with . }}
-
-

404: Page Not Found

-

- GoToSocial only serves Public statuses via the web. - If you reached this page by clicking on a status link, - it's possible that the status is not Public, has been - deleted by the author, you don't have permission to see - it, or it just doesn't exist at all. -

-

- If you believe this 404 was an error, you can contact - the instance admin. Provide them with the following request - Request ID: {{.requestID}}. -

-
+
+

404: Not Found

+

+ GoToSocial only serves Public statuses via the web. +

+

+ If you reached this page by clicking on a status link, + it's likely that the status is not Public. You can try + entering the status URL in your client's search bar, + to view the status from your account. If that doesn't + work, it's possible that the status has been deleted by + the author, you don't have permission to view it, or it + doesn't exist at all. +

+

+ If you believe this 404 was an error, you can contact + the instance admin. Provide them with the following + request ID: {{- .requestID -}}. +

+
- -{{ template "footer.tmpl" .}} \ No newline at end of file +{{- end }} \ No newline at end of file diff --git a/web/template/about.tmpl b/web/template/about.tmpl index 6579f492f..a23dfa953 100644 --- a/web/template/about.tmpl +++ b/web/template/about.tmpl @@ -17,105 +17,133 @@ // along with this program. If not, see . */ -}} -{{ template "header.tmpl" .}} -
-
-

About

-
- {{.instance.Description |noescape}} -
+{{- define "description" -}} +{{- if .instance.Description }} +{{ .instance.Description | noescape }} +{{- else }} +

No description has yet been set for this instance.

+{{- end }} +{{- end -}} -

-

Languages

-

- {{ if .languages }} - This instance prefers the following languages: -

    - {{range .languages}} -
  1. {{.}}
  2. - {{end}} -
- {{ else }} - This instance does not have any preferred languages. - {{ end }} -

-
+{{- define "registrationLimits" -}} +{{- if .instance.Registrations -}} + Registration is enabled; new signups can be submitted to this instance.
+ {{- if .instance.ApprovalRequired -}} + Admin approval is required for new registrations. + {{- else -}} + Admin approval is not required for registrations; new signups will be automatically approved (pending email confirmation). + {{- end -}} +{{- else -}} + Registration is disabled; new signups are currently closed for this instance. +{{- end -}} +{{- end -}} -
-

Admin Contact

- {{if .instance.ContactAccount}} -
- {{end}} - {{if .instance.Email}} - Email: {{.instance.Email}} - {{end}} -
+{{- define "customCSSLimits" -}} +{{- if .instance.Configuration.Accounts.AllowCustomCSS -}} +Users are allowed to set Custom CSS for their profiles. +{{- else -}} +Custom CSS is not enabled for user profiles. +{{- end -}} +{{- end -}} -
-

Rules

-
    - {{range .instance.Rules}} -
  1. {{.Text}}
  2. - {{end}} -
-
+{{- define "statusLimits" -}} +Statuses can contain up to  +{{- .instance.Configuration.Statuses.MaxCharacters }} characters, and  +{{- .instance.Configuration.Statuses.MaxMediaAttachments }} media attachments. +{{- end -}} -
-

Features

-
    -
  • - Registration is - {{if .instance.Registrations}} - enabled{{if .instance.ApprovalRequired}}, but requires admin approval{{end}}. - {{else}} - disabled. - {{end}} -
  • - {{if .instance.Configuration.Accounts.AllowCustomCSS}} -
  • - Users are allowed to set Custom CSS for their profiles. -
  • - {{end}} -
  • - Toots can contain up to {{.instance.Configuration.Statuses.MaxCharacters}} characters and - {{.instance.Configuration.Statuses.MaxMediaAttachments}} media attachments. -
  • -
  • - Polls can have up to {{.instance.Configuration.Polls.MaxOptions}} options, with - {{.instance.Configuration.Polls.MaxCharactersPerOption}} characters each. -
  • -
-
+{{- define "pollLimits" -}} +Polls can have up to  +{{- .instance.Configuration.Polls.MaxOptions }} options, with  +{{- .instance.Configuration.Polls.MaxCharactersPerOption }} characters per option. +{{- end -}} -
-

Moderated servers

-

- ActivityPub instances exchange (federate) data with other instances, including accounts and toots. - This can be prevented for specific domains by suspending them. None of their content is stored, - and interaction with their users is blocked both ways.
- {{if .blocklistExposed}} - View the list of suspended domains - {{else}} - This instance does not publically share this list. - {{end}} -

-
- -
-

Instance Statistics

-
    -
  • Users: {{.instance.Stats.user_count}}
  • -
  • Posts: {{.instance.Stats.status_count}}
  • -
  • Federates with: {{.instance.Stats.domain_count}} instances
  • -
-
-
+{{- with . }} +
+
+

About {{ .instance.Title -}}

+ {{- with . }} + {{- include "description" . | indent 2 }} + {{- end }} +
+
+

Admin Contact

+ {{- if .instance.ContactAccount }} + + {{- else }} +

This instance has not yet set a contact account.

+ {{- end }} + {{- if .instance.Email }} +

Email: {{- .instance.Email -}}

+ {{- else }} +

This instance has not yet set a contact email address.

+ {{- end }} +
+
+

Languages

+ {{- if .languages }} +

This instance prefers the following languages:

+
    + {{- range .languages }} +
  1. {{- . -}}
  2. + {{- end }} +
+ {{- else }} +

This instance does not have any preferred languages.

+ {{- end }} +
+
+

Instance Rules

+

This instance has the following rules:

+ {{- if .instance.Rules }} +
    + {{- range .instance.Rules }} +
  1. {{- .Text -}}
  2. + {{- end }} +
+ {{- else }} +

This instance has not yet set any rules.

+ {{- end }} +
+
+

Instance Features

+
    +
  • {{- template "registrationLimits" . -}}
  • +
  • {{- template "customCSSLimits" . -}}
  • +
  • {{- template "statusLimits" . -}}
  • +
  • {{- template "pollLimits" . -}}
  • +
+
+
+

Moderated servers

+

+ ActivityPub instances federate with other instances by exchanging data with them over the network. + Exchanged data includes things like accounts, statuses, likes, boosts, and media attachments. + This exchange of data can prevented for instances on specific domains via a domain block created + by an instance admin. When an instance is domain blocked by another instance: +

+
    +
  • Any existing data from the blocked instance is deleted from the storage of the instance doing the blocking.
  • +
  • Interaction between the two instances is cut off in both directions; neither instance can interact with the other.
  • +
  • No new data from the blocked instance will be created on the instance that blocks it.
  • +
+

+ {{- if .blocklistExposed }} + View the list of domains blocked by this instance + {{- else }} + This instance does not publically share their list of blocked domains. + {{- end }} +

+
-{{ template "footer.tmpl" .}} \ No newline at end of file +{{- end }} \ No newline at end of file diff --git a/web/template/authorize.tmpl b/web/template/authorize.tmpl index ada078968..9be094137 100644 --- a/web/template/authorize.tmpl +++ b/web/template/authorize.tmpl @@ -17,26 +17,24 @@ // along with this program. If not, see . */ -}} -{{ template "header.tmpl" .}} -
-
-

Hi {{.user}}!

-

- Application {{.appname}} - {{if len .appwebsite | eq 0 | not}} - ({{.appwebsite}}) - {{end}} - would like to perform actions on your behalf, with scope {{.scope}}. -

-

The application will redirect to {{.redirect}} to continue.

-

- -

-
-
-{{ template "footer.tmpl" .}} \ No newline at end of file +{{- with . }} +
+
+

Hi {{ .user -}}!

+

+ Application + {{- if .appwebsite }} + {{- .appname -}} + {{- else }} + {{- .appname -}} + {{- end }} + would like to perform actions on your behalf, with scope + {{- .scope -}}. +

+

+ To continue, the application will redirect to: {{- .redirect -}} +

+ +
+
+{{- end }} \ No newline at end of file diff --git a/web/template/confirmed.tmpl b/web/template/confirmed.tmpl index 3cf5b7ac9..c1633a8fb 100644 --- a/web/template/confirmed.tmpl +++ b/web/template/confirmed.tmpl @@ -17,12 +17,11 @@ // along with this program. If not, see . */ -}} -{{ template "header.tmpl" .}} +{{- with . }}
-
-

Email Address Confirmed

-

Thanks {{.username}}! Your email address {{.email}} has been confirmed.

-

+
+

Email Address Confirmed

+

Thanks {{ .username -}}! Your email address {{- .email -}} has been confirmed.

+

- -{{ template "footer.tmpl" .}} \ No newline at end of file +{{- end }} \ No newline at end of file diff --git a/web/template/domain-blocklist.tmpl b/web/template/domain-blocklist.tmpl index def1b990e..9a21796f9 100644 --- a/web/template/domain-blocklist.tmpl +++ b/web/template/domain-blocklist.tmpl @@ -17,36 +17,36 @@ // along with this program. If not, see . */ -}} -{{ template "header.tmpl" .}} +{{- with . }}
-
-

Suspended Instances

-

- The following list of domains have been suspended by the administrator(s) of this server. -

-

- All current and future accounts on these instances are blocked, and no more data is federated to the remote - servers. - This extends to subdomains, so an entry for 'example.com' includes 'social.example.com' as well. -

-
-
-
Domain
-
Public comment
-
- {{range .blocklist}} -
- -
-

- {{.PublicComment}} -

-
-
- {{end}} -
-
+
+

Suspended Instances

+

+ The following list of domains have been suspended + by the administrator(s) of this server. +

+

+ All current and future accounts on these instances are + blocked, and no more data is federated to the remote servers. + This extends to subdomains, so an entry for 'example.com' + includes 'social.example.com' as well. +

+
+
+
Domain
+
Public comment
+
+ {{- range .blocklist }} +
+ +
+

{{- .PublicComment -}}

+
+
+ {{- end }} +
+
-{{ template "footer.tmpl" .}} \ No newline at end of file +{{- end }} \ No newline at end of file diff --git a/web/template/error.tmpl b/web/template/error.tmpl index dc0713e43..816062e27 100644 --- a/web/template/error.tmpl +++ b/web/template/error.tmpl @@ -17,16 +17,16 @@ // along with this program. If not, see . */ -}} -{{ template "header.tmpl" .}} +{{- with . }}
-
-

An error occured:

-
{{.error}}
- {{if .requestID}} -
- Request ID: {{.requestID}} -
- {{end}} -
+
+

An error occured:

+
{{- .error -}}
+ {{- if .requestID }} +
+ Request ID: {{- .requestID -}} +
+ {{- end }} +
-{{ template "footer.tmpl" .}} \ No newline at end of file +{{- end }} \ No newline at end of file diff --git a/web/template/finalize.tmpl b/web/template/finalize.tmpl index e0d880db7..56ab677e5 100644 --- a/web/template/finalize.tmpl +++ b/web/template/finalize.tmpl @@ -17,34 +17,31 @@ // along with this program. If not, see . */ -}} -{{ template "header.tmpl" .}} -
-
-

Hi {{.name}}!

-

- You are about to sign-up to {{ .instance.Title }} ({{ .instance.URI }}) -
- To ensure the best experience for you, we need you to provide some additional details. -

- {{if .error}} -
-
{{.error}}
-
- {{end}} -
-

Important

-

Due to the way the ActivityPub standard works, you cannot change your username after it has been set.

-
-
- - -
- - -
-
-{{ template "footer.tmpl" .}} +{{- with . }} +
+
+

Hi {{ .name -}}!

+

+ You are about to sign-up to {{ .instance.Title -}}. + To ensure the best experience for you, we need you to provide some additional details. +

+
+

Important

+

Due to the way the ActivityPub standard works, you cannot change your username after it has been set.

+
+
+ + +
+ + +
+
+{{- end }} \ No newline at end of file diff --git a/web/template/footer.tmpl b/web/template/footer.tmpl deleted file mode 100644 index 028a27ffb..000000000 --- a/web/template/footer.tmpl +++ /dev/null @@ -1,46 +0,0 @@ -{{- /* -// 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 . -*/ -}} - - - - - - {{ if .javascript }} - {{ range .javascript }} - - {{ end }} - {{ end }} - - \ No newline at end of file diff --git a/web/template/frontend.tmpl b/web/template/frontend.tmpl index 977a7fab4..8e5267f4a 100644 --- a/web/template/frontend.tmpl +++ b/web/template/frontend.tmpl @@ -17,9 +17,8 @@ // along with this program. If not, see . */ -}} -{{ template "header.tmpl" .}} +{{- with . }}
-
-
+
-{{ template "footer.tmpl" .}} \ No newline at end of file +{{- end }} \ No newline at end of file diff --git a/web/template/header.tmpl b/web/template/header.tmpl deleted file mode 100644 index 2759ab804..000000000 --- a/web/template/header.tmpl +++ /dev/null @@ -1,122 +0,0 @@ -{{- /* -// 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 . -*/ -}} - - -{{- /* - NESTED TEMPLATE DECLARATIONS - If some if/else macro is used multiple times, declare it once here instead. - When invoking these nested templates, remember to pass in the values passed - to the executing template, ie., use '{{ template "example" . }}' not - '{{ template "example" }}', otherwise you'll end up with empty variables. -*/ -}} -{{ define "thumbnailType" }}{{ if .instance.ThumbnailType }}{{ .instance.ThumbnailType }}{{ else }}image/png{{ end }}{{ end }} -{{ define "instanceTitle" }}{{ if .ogMeta }}{{ .ogMeta.Title }}{{ else }}{{ .instance.Title }} - GoToSocial{{ end }}{{ end }} - -{{- /* - BOILERPLATE GOES HERE -*/ -}} - - - - - - - - - {{- /* - ROBOTS META TAGS - If this template was provided with a specific robots meta policy, use that. - Otherwise, fall back to a default restrictive policy. - See: https://developers.google.com/search/docs/crawling-indexing/robots-meta-tag - */ -}} - - - {{- /* - OPEN GRAPH META TAGS - To enable fancy previews of links to GtS posts/profiles shared via instant - messaging, or other social media, parse out provided Open Graph meta tags. - */ -}} - {{ if .ogMeta -}} - {{ if .ogMeta.Locale }}{{ end }} - - - - - - {{ if .ogMeta.ArticlePublisher }} - - - - - {{ end }} - {{ if .ogMeta.ProfileUsername }}{{ end }} - - {{ if .ogMeta.ImageAlt }}{{ end }} - {{ if .ogMeta.ImageWidth }} - - - {{ end }} - {{- end }} - - {{- /* - ICON - For icon, provide a link to the instance thumbnail. If the instance admin has - set a custom thumbnail, use the type they uploaded, else assume image/png. - See: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel#icon - */ -}} - - - - - {{- /* - RSS FEED - To enable automatic rss feed discovery for feed readers, provide the 'alternate' - link only if rss is enabled. - See: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel#alternate - */ -}} - {{ if .rssFeed -}} - - {{- end }} - - {{- /* - STYLESHEET STUFF - To try to speed up rendering a little bit, offer a preload for each stylesheet. - See: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload. - */ -}} - - - {{ range .stylesheets }}{{ end }} - - - {{ range .stylesheets }}{{ end }} - {{ template "instanceTitle" . }} - - - -
-
- - {{ if .instance.ThumbnailDescription }}{{ .instance.ThumbnailDescription }}{{ else }}Instance Logo{{ end }} -

- {{ .instance.Title }} -

-
-
-
\ No newline at end of file diff --git a/web/template/index.tmpl b/web/template/index.tmpl index 665ce7a7e..f27cf8570 100644 --- a/web/template/index.tmpl +++ b/web/template/index.tmpl @@ -17,61 +17,21 @@ // along with this program. If not, see . */ -}} -{{ template "header.tmpl" .}} -
- home to {{.instance.Stats.user_count}} users - who posted {{.instance.Stats.status_count}} statuses, - federating with {{.instance.Stats.domain_count}} other instances. -
-
-
-
- {{.instance.ShortDescription |noescape}} -
-
-
-

- GoToSocial does not provide its own webclient, but implements the Mastodon client API. - You can use this server through a variety of other clients: -

-
-
- -
-

Semaphore

-

Semaphore is a web client designed for speed and simplicity.

- Use Semaphore -
-
-
- -
-

Tusky

-

Tusky is a lightweight mobile client for Android.

- Get Tusky -
-
-
- -
-

Feditext

-

Feditext (beta) is a beautiful client for iOS, iPadOS and macOS.

- Get Feditext -
-
-
- -
-

More clients

-

Or try one of the clients listed on the official Mastodon page.

- Get Mastodon apps -
-
-
-
+{{- define "shortDescription" -}} +{{- if .instance.ShortDescription }} +{{ .instance.ShortDescription | noescape }} +{{- else }} +

No short description has yet been set for this instance.

+{{- end }} +{{- end -}} + +{{- with . }} +

+
+

About this instance

+ {{- include "shortDescription" . | indent 2 }} + See more details +
+ {{- include "index_apps.tmpl" . | indent 1 }}
-{{ template "footer.tmpl" .}} +{{- end }} \ No newline at end of file diff --git a/web/template/index_apps.tmpl b/web/template/index_apps.tmpl new file mode 100644 index 000000000..05a4a9517 --- /dev/null +++ b/web/template/index_apps.tmpl @@ -0,0 +1,115 @@ +{{- /* +// 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 . }} +
+

Client applications

+

+ GoToSocial does not provide its own webclient, but implements the Mastodon client API. + You can use this server through a variety of other clients: +

+
    +
  • +
    +

    Semaphore is a web client designed for speed and simplicity.

    + + Use Semaphore + +
    + +
  • +
  • +
    +

    Tusky is a lightweight mobile client for Android.

    + + Get Tusky + +
    + +
  • +
  • +
    +

    Feditext (beta) is a beautiful client for iOS, iPadOS and macOS.

    + + Get Feditext + +
    + +
  • +
  • +
    +

    Or try one of the Mastodon clients listed on the official Mastodon page.

    + + Get Mastodon apps + +
    + +
  • +
+
+{{- end }} \ No newline at end of file diff --git a/web/template/oob.tmpl b/web/template/oob.tmpl index 0f183c350..ff36582e7 100644 --- a/web/template/oob.tmpl +++ b/web/template/oob.tmpl @@ -17,12 +17,12 @@ // along with this program. If not, see . */ -}} -{{ template "header.tmpl" .}} +{{- with . }}
-
-

Hi {{ .user }}!

-

Here's your out-of-band token with scope "{{.scope}}", use it wisely:

- {{ .oobToken }} -
+
+

Hi {{ .user -}}!

+

Here's your out-of-band token with scope "{{- .scope -}}", use it wisely:

+ {{- .oobToken -}} +
-{{ template "footer.tmpl" .}} \ No newline at end of file +{{- end }} \ No newline at end of file diff --git a/web/template/page.tmpl b/web/template/page.tmpl new file mode 100644 index 000000000..347caf33e --- /dev/null +++ b/web/template/page.tmpl @@ -0,0 +1,85 @@ +{{- /* +// 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 . +*/ -}} + +{{- /* + NESTED TEMPLATE DECLARATIONS + If some if/else macro is used multiple times, declare it once here instead. + When invoking these nested templates, remember to pass in the values passed + to the executing template, ie., use '{{ template "example" . }}' not + '{{ template "example" }}', otherwise you'll end up with empty variables. +*/ -}} + +{{- define "thumbnailType" -}} +{{- if .instance.ThumbnailType -}} +{{- .instance.ThumbnailType -}} +{{- else -}} +image/png +{{- end -}} +{{- end -}} + +{{- define "instanceTitle" -}} +{{- if .ogMeta -}} +{{- demojify .ogMeta.Title | noescape -}} +{{- else -}} +{{- .instance.Title }} - GoToSocial +{{- end -}} +{{- end -}} + + + + + + + + + {{- if .ogMeta }} + {{- include "page_ogmeta.tmpl" . | indent 2 }} + {{- else }} + {{- end }} + {{- if .rssFeed }} + + {{- else }} + {{- end }} + {{- if .account }} + + {{- else if .status }} + + {{- else }} + {{- end }} + + + + {{- include "page_stylesheets.tmpl" . | indent 2 }} + {{- range .javascript }} + + {{- end }} + {{- template "instanceTitle" . -}} + + + +
+ {{- include .pageContent . | indent 3 | outdentPre }} +
+
+ {{- include "page_footer.tmpl" . | indent 3 }} +
+ + \ No newline at end of file diff --git a/web/template/page_footer.tmpl b/web/template/page_footer.tmpl new file mode 100644 index 000000000..a00f4dfde --- /dev/null +++ b/web/template/page_footer.tmpl @@ -0,0 +1,67 @@ +{{- /* +// 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 . }} + +{{- end }} \ No newline at end of file diff --git a/web/template/page_header.tmpl b/web/template/page_header.tmpl new file mode 100644 index 000000000..dc727d144 --- /dev/null +++ b/web/template/page_header.tmpl @@ -0,0 +1,72 @@ +{{- /* +// 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 "thumbnailDescription" -}} +{{- if .instance.ThumbnailDescription -}} +{{- .instance.ThumbnailDescription -}} +{{- else -}} +Instance Logo +{{- end -}} +{{- end -}} + +{{- define "strapUsers" -}} +{{- with .instance.Stats.user_count -}} + {{- if eq . 1 -}} + {{- . -}} user + {{- else -}} + {{- . -}} users + {{- end -}} +{{- end -}} +{{- end -}} + +{{- define "strapPosts" -}} +{{- with .instance.Stats.status_count -}} + {{- if eq . 1 -}} + {{- . -}} post + {{- else -}} + {{- . -}} posts + {{- end -}} +{{- end -}} +{{- end -}} + +{{- define "strapInstances" -}} +{{- with .instance.Stats.domain_count -}} + {{- if eq . 1 -}} + {{- . -}} other instance + {{- else -}} + {{- . -}} other instances + {{- end -}} +{{- end -}} +{{- end -}} + +{{- with . }} + + {{- template +

{{- .instance.Title -}}

+
+{{- if .showStrap }} + +{{- end }} +{{- end }} \ No newline at end of file diff --git a/web/template/page_ogmeta.tmpl b/web/template/page_ogmeta.tmpl new file mode 100644 index 000000000..82bb4bbfb --- /dev/null +++ b/web/template/page_ogmeta.tmpl @@ -0,0 +1,57 @@ +{{- /* +// 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 . +*/ -}} + +{{- /* + OPEN GRAPH META TAGS + To enable fancy previews of links to GtS posts/profiles shared via instant + messaging, or other social media, parse out provided Open Graph meta tags. +*/ -}} + +{{- with .ogMeta }} +{{- if .Locale }} + +{{- else }} +{{- end }} + + + + + +{{- if .ArticlePublisher }} + + + + +{{- else }} +{{- end }} +{{- if .ProfileUsername }} + +{{- else }} +{{- end }} + +{{- if .ImageAlt }} + +{{- else }} +{{- end }} +{{- if .ImageWidth }} + + +{{- else }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/web/template/page_stylesheets.tmpl b/web/template/page_stylesheets.tmpl new file mode 100644 index 000000000..9234607f8 --- /dev/null +++ b/web/template/page_stylesheets.tmpl @@ -0,0 +1,41 @@ +{{- /* +// 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 . +*/ -}} + +{{- /* + Order of stylesheet loading is important: _colors and base should always be loaded + before any other provided sheets, since the latter cascade from the former. + + To try to speed up rendering a little bit, offer a preload for each stylesheet. + See: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload. +*/ -}} + +{{- with . }} + + + +{{- range .stylesheets }} + +{{- end }} + + + +{{- range .stylesheets }} + +{{- end }} +{{- end }} \ No newline at end of file diff --git a/web/template/profile.tmpl b/web/template/profile.tmpl index 4207b39e8..0b079db10 100644 --- a/web/template/profile.tmpl +++ b/web/template/profile.tmpl @@ -17,129 +17,123 @@ // along with this program. If not, see . */ -}} -{{ template "header.tmpl" .}} - +{{- with . }}
-
-
- {{ if .account.Header }} - - {{ end }} -
- -
- Profile for - {{if .account.DisplayName}}{{.account.DisplayName}}{{else}}{{.account.Username}}{{end}}. - Username @{{.account.Username}}, {{.instance.AccountDomain}}. - {{ if and (.account.Role) (ne .account.Role.Name "user") }} - Role: {{ .account.Role.Name }} - {{ end }} -
-
- -
- -
-
-

About

-
- -
- {{ range .account.Fields }} -
- {{emojify $.account.Emojis (noescape .Name)}} - {{emojify $.account.Emojis (noescape .Value)}} -
- {{ end }} -
- -
- {{ if .account.Note }} - {{emojify .account.Emojis (noescape .account.Note)}} - {{else}} - This GoToSocial user hasn't written a bio yet! - {{end}} -
- -
- Joined on {{.account.CreatedAt | timestampVague}}. - {{.account.StatusesCount}} post{{if .account.StatusesCount | eq 1 | not}}s{{end}}. - Followed by {{.account.FollowersCount}}. - Following {{.account.FollowingCount}}. -
- - -
- -
- {{ if .pinned_statuses }} -
-

Pinned posts

- jump to recent -
-
- {{ range .pinned_statuses }} -
- {{ template "status.tmpl" .}} -
- {{ end }} -
- {{ end }} - -
-

Recent posts

- {{ if .rssFeed }} - - - - {{ end }} -
- -
- {{ if not .statuses }} -
Nothing here!
- {{ else }} - {{ range .statuses }} -
- {{ template "status.tmpl" .}} -
- {{ end }} - {{ end }} -
- - -
-
+

Profile for {{ .account.Username -}}

+
+
+ Header for {{ .account.Username -}} +
+
+ + Avatar for {{ .account.Username -}} + +
+
Display name
+
+ {{- if .account.DisplayName -}} + {{- emojify .account.Emojis (escape .account.DisplayName) -}} + {{- else -}} + {{- .account.Username -}} + {{- end -}} +
+
Username
+
@{{- .account.Username -}}@{{- .instance.AccountDomain -}}
+ {{- if and (.account.Role) (ne .account.Role.Name "user") }} +
Role
+
{{- .account.Role.Name -}}
+ {{- 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
+
{{- .account.FollowersCount -}}
+
Following
+
{{- .account.FollowingCount -}}
+
+
+
+ {{- if .pinned_statuses }} +
+
+

Pinned posts

+ jump to recent +
+
+ {{- range .pinned_statuses }} +
+ {{- include "status.tmpl" . | indent 6 }} +
+ {{- end }} +
+
+ {{- end }} +
+
+

Recent posts

+ {{- if .rssFeed }} + + + + {{- end }} +
+
+ {{- if not .statuses }} +
Nothing here!
+ {{- else }} + {{- range .statuses }} +
+ {{- include "status.tmpl" . | indent 6 }} +
+ {{- end }} + {{- end }} +
+ +
+
+
- -{{ template "footer.tmpl" .}} \ No newline at end of file +{{- end }} \ No newline at end of file diff --git a/web/template/profile_fields.tmpl b/web/template/profile_fields.tmpl new file mode 100644 index 000000000..e9005d4c9 --- /dev/null +++ b/web/template/profile_fields.tmpl @@ -0,0 +1,32 @@ +{{- /* +// 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 . }} +
+

Fields

+
+ {{- range .account.Fields }} +
+
{{- emojify $.account.Emojis (noescape .Name) -}}
+
{{- emojify $.account.Emojis (noescape .Value) -}}
+
+ {{- end }} +
+
+{{- end }} \ No newline at end of file diff --git a/web/template/sign-in.tmpl b/web/template/sign-in.tmpl index e2a985b9c..916d6942f 100644 --- a/web/template/sign-in.tmpl +++ b/web/template/sign-in.tmpl @@ -17,10 +17,10 @@ // along with this program. If not, see . */ -}} -{{ template "header.tmpl" .}} +{{- with . }}
-
-{{ template "footer.tmpl" .}} +{{- end }} \ No newline at end of file diff --git a/web/template/status.tmpl b/web/template/status.tmpl index eb6c6a6c6..de2167d88 100644 --- a/web/template/status.tmpl +++ b/web/template/status.tmpl @@ -17,88 +17,74 @@ // along with this program. If not, see . */ -}} -Open thread -
- - - - - - {{- if .Account.DisplayName -}} - {{- emojify .Account.Emojis (escape .Account.DisplayName) -}}. Username: @{{ .Account.Acct -}}. - {{- else -}} - @{{- .Account.Acct -}}. - {{- end -}} - - -
-
- {{- if .SpoilerText }} -
- - {{- emojify .Emojis (escape .SpoilerText) -}} - Toggle visibility - -
-
- {{ emojify .Emojis (noescape .Content) }} -
- {{- if .Poll }} - {{ template "status_poll.tmpl" . }} - {{- end }} -
-
- {{- else }} -
-
- {{ emojify .Emojis (noescape .Content) }} -
- {{- if .Poll }} - {{ template "status_poll.tmpl" . }} - {{- end }} -
- {{- end }} - {{- if .MediaAttachments }} - {{ template "status_attachments.tmpl" . }} - {{- end }} -
-