diff --git a/res/template/advertisements.html b/res/template/advertisements.html index 782c331..18947ae 100644 --- a/res/template/advertisements.html +++ b/res/template/advertisements.html @@ -51,7 +51,7 @@ {{ else if eq .Other.AdBannerType 7 }} - + {{ else if eq .Other.AdBannerType 8 }} diff --git a/webcontroller/file_viewer.go b/webcontroller/file_viewer.go index 5434b61..b7be6c3 100644 --- a/webcontroller/file_viewer.go +++ b/webcontroller/file_viewer.go @@ -78,10 +78,10 @@ func (vd *viewerData) adType(files []pixelapi.ListFile) { // Intn returns a number up to n, but never n itself. So to get a random 0 // or 1 we need to give it n=2. We can use this function to make other // splits like 1/3 1/4, etc - switch i := rand.Intn(4); i { - case 0: // 25% + switch i := rand.Intn(8); i { + case 0: // 12.5% vd.AdBannerType = brave - case 1, 2, 3: // 75% + case 1, 2, 3, 4, 5, 6, 7: // 87.5% vd.AdBannerType = aAds default: panic(fmt.Errorf("random number generator returned unrecognised number: %d", i)) diff --git a/webcontroller/templates.go b/webcontroller/templates.go index 707bd46..e6426dd 100644 --- a/webcontroller/templates.go +++ b/webcontroller/templates.go @@ -174,11 +174,12 @@ func (tm *TemplateManager) ParseTemplates(silent bool) { } else if strings.HasSuffix(path, ".gif") { file = []byte("data:image/gif;base64," + base64.StdEncoding.EncodeToString(file)) } + // Wrap the resources in a template definition if _, err = tpl.Parse( `{{define "` + f.Name() + `"}}` + string(file) + `{{end}}`, ); err != nil { - return err + return fmt.Errorf("failed to parse '%s': %w", path, err) } if !silent { diff --git a/webcontroller/web_controller.go b/webcontroller/web_controller.go index 756657c..3f64a25 100644 --- a/webcontroller/web_controller.go +++ b/webcontroller/web_controller.go @@ -74,7 +74,7 @@ func New( wc.templates.ParseTemplates(false) if wc.hostname, err = os.Hostname(); err != nil { - panic(fmt.Errorf("Could not get hostname: %s", err)) + panic(fmt.Errorf("could not get hostname: %s", err)) } // Serve static files