mirror of https://github.com/jlelse/GoBlog
Make easter egg opt-in
This commit is contained in:
parent
d5198e3db8
commit
b7f578cf2f
|
@ -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"`
|
||||
|
|
|
@ -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{}{}
|
||||
|
|
|
@ -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 }}
|
Loading…
Reference in New Issue