Add direct linking to user home

This commit is contained in:
2021-08-10 19:17:54 +02:00
parent d76b26b6d0
commit a7bf875dcc
3 changed files with 100 additions and 34 deletions

View File

@@ -78,23 +78,19 @@ 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(8); i {
case 0: // 12.5%
switch i := rand.Intn(4); i {
case 0: // 25%
vd.AdBannerType = brave
case 1, 2, 3, 4, 5, 6, 7: // 87.5%
case 2, 3, 4: // 75%
vd.AdBannerType = aAds
default:
panic(fmt.Errorf("random number generator returned unrecognised number: %d", i))
}
// If the file is larger than 10 MB we enable floating popups
if avgSize > 10e6 {
// If the file is larger than 5 MB we enable floating popups
if avgSize > 5e6 {
vd.AdFloaterType = propellerFloat
}
if avgSize > 250e6 {
vd.AdPopupType = clickAduPopup
}
}
// ServeFileViewer controller for GET /u/:id