From dc01eca73c8536d956e46f771a189ace390571bd Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 13 Oct 2020 19:36:28 +0200 Subject: [PATCH] Add ?nowidget GET parameter --- web/handler.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/web/handler.go b/web/handler.go index 2ba4bd9..d2780f7 100644 --- a/web/handler.go +++ b/web/handler.go @@ -85,6 +85,7 @@ func viewerGetHandler(w http.ResponseWriter, r *http.Request) { } host = strings.Replace(host, ".", "-", -1) if streamID, ok := cfg.MapDomainToStream[host]; ok { + // Move home page to /about if path == "about" { path = "" } else { @@ -97,12 +98,15 @@ func viewerGetHandler(w http.ResponseWriter, r *http.Request) { Cfg *Options Path string WidgetURL string - }{Path: path, Cfg: cfg} + }{Path: path, Cfg: cfg, WidgetURL: ""} - // Compute the WidgetURL with the stream path - b := &bytes.Buffer{} - _ = template.Must(template.New("").Parse(cfg.WidgetURL)).Execute(b, data) - data.WidgetURL = b.String() + // Load widget is user does not disable it with ?nowidget + if _, ok := r.URL.Query()["nowidget"]; !ok { + // Compute the WidgetURL with the stream path + b := &bytes.Buffer{} + _ = template.Must(template.New("").Parse(cfg.WidgetURL)).Execute(b, data) + data.WidgetURL = b.String() + } if err := templates.ExecuteTemplate(w, "base", data); err != nil { log.Println(err.Error())