1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 13:52:19 +00:00

Add ?nowidget GET parameter

This commit is contained in:
Alexandre Iooss 2020-10-13 19:36:28 +02:00
parent 0f98f6f62c
commit dc01eca73c
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02

View File

@ -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())