From 09fa952ce32ad32f2039ef5728809a6814969530 Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Tue, 17 Nov 2020 10:58:11 +0100 Subject: [PATCH] Update ads --- res/template/file_viewer.html | 61 +++++++++++---------------------- webcontroller/file_viewer.go | 17 ++++----- webcontroller/web_controller.go | 4 ++- 3 files changed, 30 insertions(+), 52 deletions(-) diff --git a/res/template/file_viewer.html b/res/template/file_viewer.html index 1ddc99e..5b85406 100644 --- a/res/template/file_viewer.html +++ b/res/template/file_viewer.html @@ -81,22 +81,18 @@ {{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }}
- - {{if ne (isBrave .UserAgent) true}} - Use the Brave web browser for a faster and safer web!
- - Brave lion - Get Brave - +
+ +
- or learn why pixeldrain supports Brave - {{else}} - Thank you for using Brave! Please consider supporting pixeldrain with a tip - - {{end}} - -
- {{end}} + Put your own advertisement here +
+ {{ end }} @@ -128,19 +124,13 @@
{{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }} - {{if eq .Other.AdType 0}} - - - {{else if eq .Other.AdType 1}} + {{if eq .Other.AdType 1}} + {{else if eq .Other.AdType 2}} +
Pixeldrain needs money to survive
@@ -155,18 +145,20 @@
{{else if eq .Other.AdType 3}} + {{else if eq .Other.AdType 4}} + - {{ else if eq .Other.AdType 6}} -
{{ else if eq .Other.AdType 7}} + {{ else if eq .Other.AdType 8}} + @@ -274,21 +266,8 @@ {{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }} {{ if eq .Other.AdType 5 }} - - {{ else if eq .Other.AdType 6}} - - - + + {{ end }} {{ end }} diff --git a/webcontroller/file_viewer.go b/webcontroller/file_viewer.go index ac157c7..f240776 100644 --- a/webcontroller/file_viewer.go +++ b/webcontroller/file_viewer.go @@ -31,29 +31,26 @@ func browserCompat(ua string) bool { func adType() int { const ( - aAds = 0 + aAds = 0 // Always on amarulaElectronics = 1 patreon = 2 soulStudio = 3 amarulaSolutions = 4 adMaven = 5 - mediaNet = 6 revenueHits = 7 brave = 8 ) - // Intn returns a number up to n, but never n itself. So it get a random 0 + // 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(12); i { - case 0, 1, 2, 3, 4: + switch i := rand.Intn(8); i { + case 0, 1, 2, 3: return amarulaSolutions - case 5, 6, 7, 8: + case 4, 5: return adMaven - case 9, 10: - return brave - case 11: - return aAds + case 6, 7: + return patreon default: panic(fmt.Errorf( "random number generator returned unrecognised number: %d", i), diff --git a/webcontroller/web_controller.go b/webcontroller/web_controller.go index 31b6272..5060d43 100644 --- a/webcontroller/web_controller.go +++ b/webcontroller/web_controller.go @@ -73,7 +73,9 @@ func New( var fs = http.FileServer(http.Dir(resourceDir + "/static")) r.GET(prefix+"/res/*filepath", func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { // Cache resources for 4 weeks - w.Header().Set("Cache-Control", "public, max-age=2419200") + if !debugMode { + w.Header().Set("Cache-Control", "public, max-age=2419200") + } r.URL.Path = p.ByName("filepath") fs.ServeHTTP(w, r) })