mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-18 16:47:42 +01:00
form: add pre-signup card
same as the post-signup card, but shown on the sidebar.
This commit is contained in:
@@ -169,6 +169,7 @@ func (app *appContext) GetCustomMessageTemplate(gc *gin.Context) {
|
|||||||
case "UserPage":
|
case "UserPage":
|
||||||
case "UserLogin":
|
case "UserLogin":
|
||||||
case "PostSignupCard":
|
case "PostSignupCard":
|
||||||
|
case "PreSignupCard":
|
||||||
// These don't have any example content
|
// These don't have any example content
|
||||||
msg = nil
|
msg = nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -352,9 +352,31 @@ var customContent = map[string]CustomContentInfo{
|
|||||||
"myAccountURL",
|
"myAccountURL",
|
||||||
),
|
),
|
||||||
Placeholders: defaultVals(map[string]any{
|
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{
|
var EmptyCustomContent = CustomContentInfo{
|
||||||
|
|||||||
@@ -125,6 +125,11 @@
|
|||||||
{{ if .fromUser }}
|
{{ if .fromUser }}
|
||||||
<aside class="col aside sm ~positive mb-4" id="invite-from-user" data-from="{{ .fromUser }}">{{ .strings.invitedBy }}</aside>
|
<aside class="col aside sm ~positive mb-4" id="invite-from-user" data-from="{{ .fromUser }}">{{ .strings.invitedBy }}</aside>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ if .preSignupCard }}
|
||||||
|
<div class="card @low dark:~d_neutral break-words content">
|
||||||
|
{{ .preSignupCardContent }}
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
<div class="card ~neutral @low mb-4">
|
<div class="card ~neutral @low mb-4">
|
||||||
<span class="label supra">{{ .strings.passwordRequirementsHeader }}</span>
|
<span class="label supra">{{ .strings.passwordRequirementsHeader }}</span>
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
@@ -155,6 +155,8 @@
|
|||||||
"userPagePage": "User Page: Page",
|
"userPagePage": "User Page: Page",
|
||||||
"postSignupCard": "Post-signup help card",
|
"postSignupCard": "Post-signup help card",
|
||||||
"postSignupCardDescription": "Card shown to user after signing up. Overrides \"Success Message\". Overriden by \"Auto redirect on success\" setting.",
|
"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",
|
"buildTime": "Build Time",
|
||||||
"builtBy": "Built By",
|
"builtBy": "Built By",
|
||||||
"buildTags": "Build Tags",
|
"buildTags": "Build Tags",
|
||||||
|
|||||||
19
views.go
19
views.go
@@ -831,6 +831,25 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
|||||||
[]byte(templated), nil, markdownRenderer),
|
[]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 {
|
// if discordEnabled {
|
||||||
// pin := ""
|
// pin := ""
|
||||||
|
|||||||
Reference in New Issue
Block a user