Make easter egg opt-in

This commit is contained in:
Jan-Lukas Else 2021-07-23 12:59:24 +02:00
parent d5198e3db8
commit b7f578cf2f
3 changed files with 13 additions and 1 deletions

View File

@ -23,6 +23,7 @@ type config struct {
Webmention *configWebmention `mapstructure:"webmention"`
Notifications *configNotifications `mapstructure:"notifications"`
PrivateMode *configPrivateMode `mapstructure:"privateMode"`
EasterEgg *configEasterEgg `mapstructure:"easterEgg"`
}
type configServer struct {
@ -250,6 +251,10 @@ type configPrivateMode struct {
Enabled bool `mapstructure:"enabled"`
}
type configEasterEgg struct {
Enabled bool `mapstructure:"enabled"`
}
type configWebmention struct {
DisableSending bool `mapstructure:"disableSending"`
DisableReceiving bool `mapstructure:"disableReceiving"`

View File

@ -107,6 +107,7 @@ type renderData struct {
CommentsEnabled bool
WebmentionReceivingEnabled bool
TorUsed bool
EasterEgg bool
}
func (a *goBlog) render(w http.ResponseWriter, r *http.Request, template string, data *renderData) {
@ -171,6 +172,10 @@ func (a *goBlog) checkRenderData(r *http.Request, data *renderData) {
data.CommentsEnabled = data.Blog.Comments != nil && data.Blog.Comments.Enabled
// Check if able to receive webmentions
data.WebmentionReceivingEnabled = a.cfg.Webmention == nil || !a.cfg.Webmention.DisableReceiving
// Easter egg
if ee := a.cfg.EasterEgg; ee != nil && ee.Enabled {
data.EasterEgg = true
}
// Data
if data.Data == nil {
data.Data = map[string]interface{}{}

View File

@ -23,6 +23,8 @@
{{ include "header" . }}
{{ block "main" . }}{{ end }}
{{ include "footer" . }}
<script defer src="{{ asset "js/easteregg.js" }}"></script>
{{ if .EasterEgg }}
<script defer src="{{ asset "js/easteregg.js" }}"></script>
{{ end }}
</html>
{{ end }}