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"`
|
Webmention *configWebmention `mapstructure:"webmention"`
|
||||||
Notifications *configNotifications `mapstructure:"notifications"`
|
Notifications *configNotifications `mapstructure:"notifications"`
|
||||||
PrivateMode *configPrivateMode `mapstructure:"privateMode"`
|
PrivateMode *configPrivateMode `mapstructure:"privateMode"`
|
||||||
|
EasterEgg *configEasterEgg `mapstructure:"easterEgg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type configServer struct {
|
type configServer struct {
|
||||||
|
@ -250,6 +251,10 @@ type configPrivateMode struct {
|
||||||
Enabled bool `mapstructure:"enabled"`
|
Enabled bool `mapstructure:"enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type configEasterEgg struct {
|
||||||
|
Enabled bool `mapstructure:"enabled"`
|
||||||
|
}
|
||||||
|
|
||||||
type configWebmention struct {
|
type configWebmention struct {
|
||||||
DisableSending bool `mapstructure:"disableSending"`
|
DisableSending bool `mapstructure:"disableSending"`
|
||||||
DisableReceiving bool `mapstructure:"disableReceiving"`
|
DisableReceiving bool `mapstructure:"disableReceiving"`
|
||||||
|
|
|
@ -107,6 +107,7 @@ type renderData struct {
|
||||||
CommentsEnabled bool
|
CommentsEnabled bool
|
||||||
WebmentionReceivingEnabled bool
|
WebmentionReceivingEnabled bool
|
||||||
TorUsed bool
|
TorUsed bool
|
||||||
|
EasterEgg bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *goBlog) render(w http.ResponseWriter, r *http.Request, template string, data *renderData) {
|
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
|
data.CommentsEnabled = data.Blog.Comments != nil && data.Blog.Comments.Enabled
|
||||||
// Check if able to receive webmentions
|
// Check if able to receive webmentions
|
||||||
data.WebmentionReceivingEnabled = a.cfg.Webmention == nil || !a.cfg.Webmention.DisableReceiving
|
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
|
// Data
|
||||||
if data.Data == nil {
|
if data.Data == nil {
|
||||||
data.Data = map[string]interface{}{}
|
data.Data = map[string]interface{}{}
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
{{ include "header" . }}
|
{{ include "header" . }}
|
||||||
{{ block "main" . }}{{ end }}
|
{{ block "main" . }}{{ end }}
|
||||||
{{ include "footer" . }}
|
{{ include "footer" . }}
|
||||||
|
{{ if .EasterEgg }}
|
||||||
<script defer src="{{ asset "js/easteregg.js" }}"></script>
|
<script defer src="{{ asset "js/easteregg.js" }}"></script>
|
||||||
|
{{ end }}
|
||||||
</html>
|
</html>
|
||||||
{{ end }}
|
{{ end }}
|
Loading…
Reference in New Issue