Embed static resources (#1466)

* Replace pkger with go:embed for bundling the admin. Closes #844

* Remove references to pkged.go

* Point tests to use an updated version of Go

* Add comment to new exported function

* Cleanup

* Add a dummy pkged.go to alert people to stop using it.

* Add simple browser test to make sure the admin is available and renders

* Don't panic

* Embed bot/scraper metadata template.

Add browser test to validate the rendering of this template.

* Use embedded offline.ts segment

* Remove placeholder thumbnail as its unnecessary

* Remove copying the static directory into the release

* Cleanup
This commit is contained in:
Gabe Kangas
2021-10-11 15:04:16 -07:00
committed by GitHub
parent f0bd7d2528
commit ca9d5de192
10 changed files with 105 additions and 19 deletions

View File

@@ -8,7 +8,6 @@ import (
"path"
"path/filepath"
"strings"
"text/template"
log "github.com/sirupsen/logrus"
@@ -17,6 +16,7 @@ import (
"github.com/owncast/owncast/core/data"
"github.com/owncast/owncast/models"
"github.com/owncast/owncast/router/middleware"
"github.com/owncast/owncast/static"
"github.com/owncast/owncast/utils"
)
@@ -74,7 +74,12 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
// Return a basic HTML page with server-rendered metadata from the config file
// to give to Opengraph clients and web scrapers (bots, web crawlers, etc).
func handleScraperMetadataPage(w http.ResponseWriter, r *http.Request) {
tmpl := template.Must(template.ParseFiles(path.Join("static", "metadata.html")))
tmpl, err := static.GetBotMetadataTemplate()
if err != nil {
log.Errorln(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
scheme := "http"