From 8829ee187afd24d0b54f12c73a3b9df1f8612f68 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 20 Feb 2025 15:09:28 +0100 Subject: [feature] Add page-specific class per template (#3814) * [feature] Add page-specific class per template * cheeky bit cheaper --- internal/api/util/template.go | 10 +++ internal/web/confirmemail.go | 4 +- internal/web/login-info.go | 2 +- web/template/confirm-email.tmpl | 33 ++++++++ web/template/confirm_email.tmpl | 33 -------- web/template/confirmed-email.tmpl | 30 ++++++++ web/template/confirmed_email.tmpl | 30 -------- web/template/login-info.tmpl | 157 ++++++++++++++++++++++++++++++++++++++ web/template/login_info.tmpl | 157 -------------------------------------- web/template/page.tmpl | 4 +- 10 files changed, 234 insertions(+), 226 deletions(-) create mode 100644 web/template/confirm-email.tmpl delete mode 100644 web/template/confirm_email.tmpl create mode 100644 web/template/confirmed-email.tmpl delete mode 100644 web/template/confirmed_email.tmpl create mode 100644 web/template/login-info.tmpl delete mode 100644 web/template/login_info.tmpl diff --git a/internal/api/util/template.go b/internal/api/util/template.go index 990874028..ec04a4d97 100644 --- a/internal/api/util/template.go +++ b/internal/api/util/template.go @@ -236,6 +236,16 @@ func templatePage( obj map[string]any, ) { const pageTmpl = "page.tmpl" + + // Render given template inside the page. obj["pageContent"] = template + + // Inject specific page class by trimming + // ".tmpl" suffix. In the page template + // (see page.tmpl) this will be appended + // with "-page", so "index.tmpl" for example + // ends up with class "page index-page". + obj["pageClass"] = template[:len(template)-5] + c.HTML(code, pageTmpl, obj) } diff --git a/internal/web/confirmemail.go b/internal/web/confirmemail.go index e512761f4..323de6bb2 100644 --- a/internal/web/confirmemail.go +++ b/internal/web/confirmemail.go @@ -77,7 +77,7 @@ func (m *Module) confirmEmailGETHandler(c *gin.Context) { // Serve page where user can click button // to POST confirmation to same endpoint. page := apiutil.WebPage{ - Template: "confirm_email.tmpl", + Template: "confirm-email.tmpl", Instance: instance, Extra: map[string]any{ "email": email, @@ -127,7 +127,7 @@ func (m *Module) confirmEmailPOSTHandler(c *gin.Context) { // Serve page informing user that their // email address is now confirmed. page := apiutil.WebPage{ - Template: "confirmed_email.tmpl", + Template: "confirmed-email.tmpl", Instance: instance, Extra: map[string]any{ "email": user.Email, diff --git a/internal/web/login-info.go b/internal/web/login-info.go index bd52f72ef..9aca768b6 100644 --- a/internal/web/login-info.go +++ b/internal/web/login-info.go @@ -50,7 +50,7 @@ func (m *Module) loginGETHandler(c *gin.Context) { } page := apiutil.WebPage{ - Template: "login_info.tmpl", + Template: "login-info.tmpl", Instance: instance, OGMeta: apiutil.OGBase(instance), Stylesheets: []string{cssAbout, cssLoginInfo}, diff --git a/web/template/confirm-email.tmpl b/web/template/confirm-email.tmpl new file mode 100644 index 000000000..d1932acd9 --- /dev/null +++ b/web/template/confirm-email.tmpl @@ -0,0 +1,33 @@ +{{- /* +// 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 . }} +
+
+

Confirm email address

+
+

+ Hi {{- .username -}}! + Please click the button to confirm your email address {{- .email -}}. +

+ +
+
+
+{{- end }} \ No newline at end of file diff --git a/web/template/confirm_email.tmpl b/web/template/confirm_email.tmpl deleted file mode 100644 index d1932acd9..000000000 --- a/web/template/confirm_email.tmpl +++ /dev/null @@ -1,33 +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 . -*/ -}} - -{{- with . }} -
-
-

Confirm email address

-
-

- Hi {{- .username -}}! - Please click the button to confirm your email address {{- .email -}}. -

- -
-
-
-{{- end }} \ No newline at end of file diff --git a/web/template/confirmed-email.tmpl b/web/template/confirmed-email.tmpl new file mode 100644 index 000000000..2dc605e4b --- /dev/null +++ b/web/template/confirmed-email.tmpl @@ -0,0 +1,30 @@ +{{- /* +// 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 . }} +
+
+

Email address confirmed

+

Email address {{- .email -}} is now confirmed!

+ {{- if not .approved }} +

Once an admin has approved your sign-up, you will be able to log in and use your account.

+ {{- end }} +
+
+{{- end }} \ No newline at end of file diff --git a/web/template/confirmed_email.tmpl b/web/template/confirmed_email.tmpl deleted file mode 100644 index 2dc605e4b..000000000 --- a/web/template/confirmed_email.tmpl +++ /dev/null @@ -1,30 +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 . -*/ -}} - -{{- with . }} -
-
-

Email address confirmed

-

Email address {{- .email -}} is now confirmed!

- {{- if not .approved }} -

Once an admin has approved your sign-up, you will be able to log in and use your account.

- {{- end }} -
-
-{{- end }} \ No newline at end of file diff --git a/web/template/login-info.tmpl b/web/template/login-info.tmpl new file mode 100644 index 000000000..238e3e9d2 --- /dev/null +++ b/web/template/login-info.tmpl @@ -0,0 +1,157 @@ +{{- /* +// 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 . }} +
+
+

+ Looking to configure your profile and other settings? +

+ + Settings + +
+
+

Client applications

+
+

+ Want to log in and start posting? + Unlike other ActivityPub softwares, GoToSocial does not provide its own + webclient. Instead it implements the Mastodon client API, so you can use + a variety of third-party clients to log in to your account here: +

+
    +
  • +
    +

    Pinafore is a web client designed for speed and simplicity.

    + + Use Pinafore + +
    + +
  • +
  • +
    +

    Tusky is a lightweight mobile client for Android.

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

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

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

    + Masto-FE (🦥 flavour) is an (experimental!) client based on + the Mastodon Glitch web frontend, with some small changes specific to GoToSocial. +

    + + Try Masto-FE (🦥 flavour) + +
    + +
  • +
  • +
    +

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

    + + Browse Mastodon apps + +
    + +
  • +
+
+
+
+{{- end }} \ No newline at end of file diff --git a/web/template/login_info.tmpl b/web/template/login_info.tmpl deleted file mode 100644 index 238e3e9d2..000000000 --- a/web/template/login_info.tmpl +++ /dev/null @@ -1,157 +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 . -*/ -}} - -{{- with . }} -
-
-

- Looking to configure your profile and other settings? -

- - Settings - -
-
-

Client applications

-
-

- Want to log in and start posting? - Unlike other ActivityPub softwares, GoToSocial does not provide its own - webclient. Instead it implements the Mastodon client API, so you can use - a variety of third-party clients to log in to your account here: -

-
    -
  • -
    -

    Pinafore is a web client designed for speed and simplicity.

    - - Use Pinafore - -
    - -
  • -
  • -
    -

    Tusky is a lightweight mobile client for Android.

    - - Get Tusky - -
    - -
  • -
  • -
    -

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

    - - Get Feditext - -
    - -
  • -
  • -
    -

    - Masto-FE (🦥 flavour) is an (experimental!) client based on - the Mastodon Glitch web frontend, with some small changes specific to GoToSocial. -

    - - Try Masto-FE (🦥 flavour) - -
    - -
  • -
  • -
    -

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

    - - Browse Mastodon apps - -
    - -
  • -
-
-
-
-{{- end }} \ No newline at end of file diff --git a/web/template/page.tmpl b/web/template/page.tmpl index fad0fc3b9..7dccc7469 100644 --- a/web/template/page.tmpl +++ b/web/template/page.tmpl @@ -71,9 +71,8 @@ image/webp {{- end }} {{- template "instanceTitle" . -}} - + {{- include "login_button.tmpl" . | indent 3 }} -
@@ -83,6 +82,5 @@ image/webp -
\ No newline at end of file -- cgit v1.2.3