diff --git a/cmd/version.go b/cmd/version.go
index 35394a0..c7f2146 100644
--- a/cmd/version.go
+++ b/cmd/version.go
@@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra"
)
-var Version = "0.24.0"
+var Version = "0.24.1"
func init() {
rootCmd.AddCommand(versionCmd)
diff --git a/cmd/web.go b/cmd/web.go
index 7b71f11..783b89e 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -25,10 +25,6 @@ const (
LogDate string = `2006-01-02T15:04:05.000-07:00`
Prefix string = `/src`
RedirectStatusCode int = http.StatusSeeOther
-
- // You may not like it, but this is what peak string generation looks like.
- RefreshScriptTemplate string = ``
- HtmlTemplate string = `
%v (%vx%v)%v`
)
type Filters struct {
@@ -204,33 +200,34 @@ func serveHtml(w http.ResponseWriter, r *http.Request, filePath string, dimensio
queryParams, err := generateQueryParams(filters, r.URL.Query().Get("sort"), refreshInterval)
- refreshScript := ""
+ var htmlBody strings.Builder
+ htmlBody.WriteString(``)
+ htmlBody.WriteString(``)
+ htmlBody.WriteString(fmt.Sprintf(`%v (%vx%v)`,
+ fileName,
+ dimensions.Width,
+ dimensions.Height))
+ htmlBody.WriteString(``)
+ htmlBody.WriteString(fmt.Sprintf(``,
+ queryParams,
+ generateFilePath(filePath),
+ dimensions.Width,
+ dimensions.Height,
+ fileName))
if refreshInterval != "0" {
r, err := strconv.Atoi(refreshInterval)
if err != nil {
return err
}
refreshTimer := strconv.Itoa(r * 1000)
- refreshScript = fmt.Sprintf(RefreshScriptTemplate,
+ htmlBody.WriteString(fmt.Sprintf(``,
queryParams,
- refreshTimer)
+ refreshTimer))
}
+ htmlBody.WriteString(``)
- htmlBody := fmt.Sprintf(HtmlTemplate,
- fileName,
- dimensions.Width,
- dimensions.Height,
- queryParams,
- generateFilePath(filePath),
- dimensions.Width,
- dimensions.Height,
- fileName,
- refreshScript,
- )
-
- formattedBody := gohtml.Format(htmlBody)
-
- _, err = io.WriteString(w, formattedBody)
+ _, err = io.WriteString(w, gohtml.Format(htmlBody.String()))
if err != nil {
return err
}