form: add pre-signup card

same as the post-signup card, but shown on the sidebar.
This commit is contained in:
Harvey Tindall
2025-12-02 14:56:15 +00:00
parent a4b94b4f45
commit 6e31a7e2dd
5 changed files with 50 additions and 1 deletions

View File

@@ -169,6 +169,7 @@ func (app *appContext) GetCustomMessageTemplate(gc *gin.Context) {
case "UserPage":
case "UserLogin":
case "PostSignupCard":
case "PreSignupCard":
// These don't have any example content
msg = nil
}

View File

@@ -352,9 +352,31 @@ var customContent = map[string]CustomContentInfo{
"myAccountURL",
),
Placeholders: defaultVals(map[string]any{
"myAccountURL": "https://sub2.test.url/my/account",
"myAccountURL": "https://example.url/my/account",
}),
},
"PreSignupCard": {
Name: "PreSignupCard",
ContentType: CustomCard,
DisplayName: func(dict *Lang, lang string) string {
if _, ok := dict.Admin[lang]; !ok {
lang = dict.chosenAdminLang
}
return dict.Admin[lang].Strings["preSignupCard"]
},
Description: func(dict *Lang, lang string) string {
if _, ok := dict.Admin[lang]; !ok {
lang = dict.chosenAdminLang
}
return dict.Admin[lang].Strings["preSignupCardDescription"]
},
Variables: []string{
"myAccountURL",
},
Placeholders: map[string]any{
"myAccountURL": "https://example.url/my/account",
},
},
}
var EmptyCustomContent = CustomContentInfo{

View File

@@ -125,6 +125,11 @@
{{ if .fromUser }}
<aside class="col aside sm ~positive mb-4" id="invite-from-user" data-from="{{ .fromUser }}">{{ .strings.invitedBy }}</aside>
{{ end }}
{{ if .preSignupCard }}
<div class="card @low dark:~d_neutral break-words content">
{{ .preSignupCardContent }}
</div>
{{ end }}
<div class="card ~neutral @low mb-4">
<span class="label supra">{{ .strings.passwordRequirementsHeader }}</span>
<ul>

View File

@@ -155,6 +155,8 @@
"userPagePage": "User Page: Page",
"postSignupCard": "Post-signup help card",
"postSignupCardDescription": "Card shown to user after signing up. Overrides \"Success Message\". Overriden by \"Auto redirect on success\" setting.",
"preSignupCard": "Pre-signup help card",
"preSignupCardDescription": "Optional card shown on the sign-up page.",
"buildTime": "Build Time",
"builtBy": "Built By",
"buildTags": "Build Tags",

View File

@@ -831,6 +831,25 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
[]byte(templated), nil, markdownRenderer),
)
}
if msg, ok := app.storage.GetCustomContentKey("PreSignupCard"); ok && msg.Enabled {
cci := customContent["PreSignupCard"]
data["preSignupCard"] = true
// We don't template here, since the username is only known after login.
templated, err := templateEmail(
msg.Content,
cci.Variables,
cci.Conditionals,
map[string]any{
"myAccountURL": userPageAddress,
},
)
if err != nil {
app.err.Printf(lm.FailedConstructCustomContent, "PreSignupCard", err)
}
data["preSignupCardContent"] = template.HTML(markdown.ToHTML(
[]byte(templated), nil, markdownRenderer),
)
}
// if discordEnabled {
// pin := ""