2021-08-25 10:00:16 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
type BaseData struct {
|
2022-01-18 23:50:47 +00:00
|
|
|
Domains []string `json:"domains"`
|
|
|
|
SiteOwnerName string `json:"siteOwnerName"`
|
|
|
|
SiteOwnerURL string `json:"siteOwnerURL"`
|
|
|
|
SiteName string `json:"siteName"`
|
|
|
|
UsernameInfo string `json:"usernameInfo"`
|
2021-08-25 10:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func renderHTML(w http.ResponseWriter, html string, extraData interface{}) {
|
2022-01-18 23:50:47 +00:00
|
|
|
info := "Desired Username"
|
|
|
|
if s.GlobalUsers {
|
|
|
|
info = "Desired Username (unique across all domains)"
|
|
|
|
}
|
2021-08-25 10:00:16 +00:00
|
|
|
base, _ := json.Marshal(BaseData{
|
2022-01-18 23:50:47 +00:00
|
|
|
Domains: getDomains(s.Domain),
|
2021-08-25 10:00:16 +00:00
|
|
|
SiteOwnerName: s.SiteOwnerName,
|
|
|
|
SiteOwnerURL: s.SiteOwnerURL,
|
|
|
|
SiteName: s.SiteName,
|
2022-01-18 23:50:47 +00:00
|
|
|
UsernameInfo: info,
|
2021-08-25 10:00:16 +00:00
|
|
|
})
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
}
|