Link brave directly to referral link

This commit is contained in:
2021-06-29 12:08:31 +02:00
parent 4d140ad5a2
commit 887f055d67
4 changed files with 7 additions and 6 deletions

View File

@@ -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))

View File

@@ -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 {

View File

@@ -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