2021-10-12 00:56:00 +03:00
|
|
|
package static
|
|
|
|
|
2021-10-12 01:04:16 +03:00
|
|
|
import (
|
|
|
|
"embed"
|
|
|
|
"html/template"
|
2021-11-04 02:27:37 +03:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2021-10-12 01:04:16 +03:00
|
|
|
)
|
2021-10-12 00:56:00 +03:00
|
|
|
|
|
|
|
//go:embed admin/*
|
|
|
|
//go:embed admin/_next/static
|
|
|
|
//go:embed admin/_next/static/chunks/pages/*.js
|
|
|
|
//go:embed admin/_next/static/*/*.js
|
|
|
|
var adminFiles embed.FS
|
|
|
|
|
|
|
|
// GetAdmin will return an embedded filesystem reference to the admin web app.
|
|
|
|
func GetAdmin() embed.FS {
|
|
|
|
return adminFiles
|
|
|
|
}
|
2021-10-12 01:04:16 +03:00
|
|
|
|
|
|
|
//go:embed metadata.html.tmpl
|
|
|
|
var botMetadataTemplate embed.FS
|
|
|
|
|
|
|
|
// GetBotMetadataTemplate will return the bot/scraper metadata template.
|
|
|
|
func GetBotMetadataTemplate() (*template.Template, error) {
|
|
|
|
name := "metadata.html.tmpl"
|
|
|
|
t, err := template.ParseFS(botMetadataTemplate, name)
|
|
|
|
tmpl := template.Must(t, err)
|
|
|
|
return tmpl, err
|
|
|
|
}
|
|
|
|
|
|
|
|
//go:embed offline.ts
|
|
|
|
var offlineVideoSegment []byte
|
|
|
|
|
|
|
|
// GetOfflineSegment will return the offline video segment data.
|
|
|
|
func GetOfflineSegment() []byte {
|
2021-11-04 02:27:37 +03:00
|
|
|
return getFileSystemStaticFileOrDefault("offline.ts", offlineVideoSegment)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getFileSystemStaticFileOrDefault(path string, defaultData []byte) []byte {
|
|
|
|
fullPath := filepath.Join("static", path)
|
|
|
|
data, err := os.ReadFile(fullPath) //nolint: gosec
|
|
|
|
if err != nil {
|
|
|
|
return defaultData
|
|
|
|
}
|
|
|
|
|
|
|
|
return data
|
2021-10-12 01:04:16 +03:00
|
|
|
}
|