forked from nbd-wtf/satdress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
html.go
43 lines (39 loc) · 1001 Bytes
/
html.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"encoding/json"
"fmt"
"net/http"
"strings"
)
type BaseData struct {
Domains []string `json:"domains"`
SiteOwnerName string `json:"siteOwnerName"`
SiteOwnerURL string `json:"siteOwnerURL"`
SiteName string `json:"siteName"`
UsernameInfo string `json:"usernameInfo"`
}
func renderHTML(w http.ResponseWriter, html string, extraData interface{}) {
info := "Desired Username"
if s.GlobalUsers {
info = "Desired Username (unique across all domains)"
}
base, _ := json.Marshal(BaseData{
Domains: getDomains(s.Domain),
SiteOwnerName: s.SiteOwnerName,
SiteOwnerURL: s.SiteOwnerURL,
SiteName: s.SiteName,
UsernameInfo: info,
})
extra, _ := json.Marshal(extraData)
w.Header().Set("content-type", "text/html")
fmt.Fprint(w,
strings.ReplaceAll(
strings.ReplaceAll(
html,
"{} // REPLACED WITH SERVER DATA",
fmt.Sprintf("{...%s, ...%s}", string(base), string(extra)),
),
"Satdress", s.SiteName,
),
)
}