mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-22 15:02:19 +00:00
ID is better than Id according to Golang
This commit is contained in:
parent
8eab4dfe22
commit
7ceecad355
@ -41,7 +41,8 @@ web:
|
|||||||
name: Demo
|
name: Demo
|
||||||
hostname: localhost
|
hostname: localhost
|
||||||
favicon: https://www.crans.org/images/favicon.ico
|
favicon: https://www.crans.org/images/favicon.ico
|
||||||
widgetURL: https://example.com/
|
# You can optionally use {{.Path}} to customize your widget URL
|
||||||
|
widgetURL: https://example.com/stream_{{.Path}}
|
||||||
viewersCounterRefreshPeriod: 20000
|
viewersCounterRefreshPeriod: 20000
|
||||||
|
|
||||||
# Configure WebRTC server
|
# Configure WebRTC server
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@ -45,9 +47,15 @@ func viewerPostHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
func viewerGetHandler(w http.ResponseWriter, r *http.Request) {
|
func viewerGetHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// Render template
|
// Render template
|
||||||
data := struct {
|
data := struct {
|
||||||
Path string
|
Cfg *Options
|
||||||
Cfg *Options
|
Path string
|
||||||
|
WidgetURL string
|
||||||
}{Path: r.URL.Path[1:], Cfg: cfg}
|
}{Path: r.URL.Path[1:], Cfg: cfg}
|
||||||
|
b := &bytes.Buffer{}
|
||||||
|
// Update the WidgetURL with the stream path
|
||||||
|
_ = template.Must(template.New("").Parse(cfg.WidgetURL)).Execute(b, data)
|
||||||
|
data.WidgetURL = b.String()
|
||||||
|
|
||||||
if err := templates.ExecuteTemplate(w, "base", data); err != nil {
|
if err := templates.ExecuteTemplate(w, "base", data); err != nil {
|
||||||
log.Println(err.Error())
|
log.Println(err.Error())
|
||||||
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
<!-- Chat -->
|
<!-- Chat -->
|
||||||
<div class="col-chat" id="sideWidget">
|
<div class="col-chat" id="sideWidget">
|
||||||
<iframe src="https://irc.crans.org/web/?join=stream_{{.Path}}&nick=viewer&password=&realname=Viewer"
|
<iframe src="{{.WidgetURL}}"
|
||||||
title="Chat" sandbox="allow-scripts allow-forms allow-same-origin"></iframe>
|
title="Chat" sandbox="allow-scripts allow-forms allow-same-origin"></iframe>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user