mirror of
https://github.com/knadh/listmonk.git
synced 2025-09-12 17:35:19 +08:00
Remove GET /api/settings
dependency on the Lists -> Forms UI.
This commit is contained in:
parent
b44ea0c336
commit
fb527008d7
2 changed files with 20 additions and 14 deletions
15
cmd/admin.go
15
cmd/admin.go
|
@ -8,11 +8,17 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
null "gopkg.in/volatiletech/null.v6"
|
||||||
)
|
)
|
||||||
|
|
||||||
type serverConfig struct {
|
type serverConfig struct {
|
||||||
RootURL string `json:"root_url"`
|
RootURL string `json:"root_url"`
|
||||||
FromEmail string `json:"from_email"`
|
FromEmail string `json:"from_email"`
|
||||||
|
PublicSubscription struct {
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
|
CaptchaEnabled bool `json:"captcha_enabled"`
|
||||||
|
CaptchaKey null.String `json:"captcha_key"`
|
||||||
|
} `json:"public_subscription"`
|
||||||
Messengers []string `json:"messengers"`
|
Messengers []string `json:"messengers"`
|
||||||
Langs []i18nLang `json:"langs"`
|
Langs []i18nLang `json:"langs"`
|
||||||
Lang string `json:"lang"`
|
Lang string `json:"lang"`
|
||||||
|
@ -32,6 +38,11 @@ func (a *App) GetServerConfig(c echo.Context) error {
|
||||||
Permissions: a.cfg.PermissionsRaw,
|
Permissions: a.cfg.PermissionsRaw,
|
||||||
HasLegacyUser: a.cfg.HasLegacyUser,
|
HasLegacyUser: a.cfg.HasLegacyUser,
|
||||||
}
|
}
|
||||||
|
out.PublicSubscription.Enabled = a.cfg.EnablePublicSubPage
|
||||||
|
if a.cfg.Security.EnableCaptcha {
|
||||||
|
out.PublicSubscription.CaptchaEnabled = true
|
||||||
|
out.PublicSubscription.CaptchaKey = null.StringFrom(a.cfg.Security.CaptchaKey)
|
||||||
|
}
|
||||||
|
|
||||||
// Language list.
|
// Language list.
|
||||||
langList, err := getI18nLangList(a.fs)
|
langList, err := getI18nLangList(a.fs)
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
<p v-else-if="publicLists.length === 0">
|
<p v-else-if="publicLists.length === 0">
|
||||||
{{ $t('forms.noPublicLists') }}
|
{{ $t('forms.noPublicLists') }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="columns" v-else-if="publicLists.length > 0">
|
<div class="columns" v-else-if="publicLists.length > 0">
|
||||||
<div class="column is-4">
|
<div class="column is-4">
|
||||||
<h4>{{ $t('forms.publicLists') }}</h4>
|
<h4>{{ $t('forms.publicLists') }}</h4>
|
||||||
|
@ -24,13 +23,13 @@
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<template v-if="settings['app.enable_public_subscription_page']">
|
<template v-if="serverConfig.public_subscription.enabled">
|
||||||
<hr />
|
<hr />
|
||||||
<h4>{{ $t('forms.publicSubPage') }}</h4>
|
<h4>{{ $t('forms.publicSubPage') }}</h4>
|
||||||
<p>
|
<p>
|
||||||
<a :href="`${settings['app.root_url']}/subscription/form`" target="_blank" rel="noopener noreferer"
|
<a :href="`${serverConfig.root_url}/subscription/form`" target="_blank" rel="noopener noreferer"
|
||||||
data-cy="url">
|
data-cy="url">
|
||||||
{{ settings['app.root_url'] }}/subscription/form
|
{{ serverConfig.root_url }}/subscription/form
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
|
@ -68,7 +67,7 @@ export default Vue.extend({
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
renderHTML() {
|
renderHTML() {
|
||||||
let h = `<form method="post" action="${this.settings['app.root_url']}/subscription/form" class="listmonk-form">\n`
|
let h = `<form method="post" action="${this.serverConfig.root_url}/subscription/form" class="listmonk-form">\n`
|
||||||
+ ' <div>\n'
|
+ ' <div>\n'
|
||||||
+ ` <h3>${this.$t('public.sub')}</h3>\n`
|
+ ` <h3>${this.$t('public.sub')}</h3>\n`
|
||||||
+ ' <input type="hidden" name="nonce" />\n\n'
|
+ ' <input type="hidden" name="nonce" />\n\n'
|
||||||
|
@ -91,9 +90,9 @@ export default Vue.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
// Captcha?
|
// Captcha?
|
||||||
if (this.settings['security.enable_captcha']) {
|
if (this.serverConfig.public_subscription.captcha_enabled) {
|
||||||
h += '\n'
|
h += '\n'
|
||||||
+ ` <div class="h-captcha" data-sitekey="${this.settings['security.captcha_key']}"></div>\n`
|
+ ` <div class="h-captcha" data-sitekey="${this.serverConfig.public_subscription.captcha_key}"></div>\n`
|
||||||
+ ` <${'script'} src="https://js.hcaptcha.com/1/api.js" async defer></${'script'}>\n`;
|
+ ` <${'script'} src="https://js.hcaptcha.com/1/api.js" async defer></${'script'}>\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +106,7 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['loading', 'lists', 'settings']),
|
...mapState(['loading', 'lists', 'serverConfig']),
|
||||||
|
|
||||||
publicLists() {
|
publicLists() {
|
||||||
if (!this.lists.results) {
|
if (!this.lists.results) {
|
||||||
|
@ -117,10 +116,6 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
|
||||||
this.$api.getSettings();
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
checked() {
|
checked() {
|
||||||
this.renderHTML();
|
this.renderHTML();
|
||||||
|
|
Loading…
Add table
Reference in a new issue