From 21cd1ddd01389945857637955dd867c1b640d628 Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Tue, 19 Oct 2021 12:07:04 +0200 Subject: [PATCH] Fix pixfuture skyscraper --- res/include/script/file_viewer/Skyscraper.js | 18 +++++++++- .../file_viewer/viewer_scripts/VideoViewer.js | 4 +-- res/include/style/viewer.css | 5 +++ res/template/file_viewer.html | 2 +- webcontroller/file_viewer.go | 33 +++++++++++-------- webcontroller/templates.go | 8 +++-- webcontroller/user_account.go | 8 +++-- 7 files changed, 55 insertions(+), 23 deletions(-) diff --git a/res/include/script/file_viewer/Skyscraper.js b/res/include/script/file_viewer/Skyscraper.js index 4a035b6..3406651 100644 --- a/res/include/script/file_viewer/Skyscraper.js +++ b/res/include/script/file_viewer/Skyscraper.js @@ -29,8 +29,24 @@ Skyscraper.prototype.open = function () { this.divAdSpace.innerHTML = `` + } else if (skyscraperType === "pixfuture") { + + let div = document.createElement("div") + div.id = "27513x160x600x4605x_ADSLOT1" + div.setAttribute("clickTrack", "%%CLICK_URL_ESC%%") + this.divAdSpace.appendChild(div) + + let script = document.createElement("script") + script.async = "async" + script.type = "text/javascript" + script.src = "https:\/\/served-by.pixfuture.com/www/delivery/headerbid.js" + script.setAttribute("slotId", "27513x160x600x4605x_ADSLOT1") + script.setAttribute("refreshTime", "5") + script.setAttribute("refreshInterval", "60") + document.head.appendChild(script) + } else { return } diff --git a/res/include/script/file_viewer/viewer_scripts/VideoViewer.js b/res/include/script/file_viewer/viewer_scripts/VideoViewer.js index 6c78ecf..3a3fa8a 100644 --- a/res/include/script/file_viewer/viewer_scripts/VideoViewer.js +++ b/res/include/script/file_viewer/viewer_scripts/VideoViewer.js @@ -27,8 +27,8 @@ VideoViewer.prototype.render = function (parent) { parent.appendChild(vidContainer) // Possible fix for ios 15 video bug? - this.videoSource.src = this.file.get_href - this.videoSource.type = this.file.mime_type + videoSource.src = this.file.get_href + videoSource.type = this.file.mime_type } else { let container = document.createElement("div") container.classList = "image-container" diff --git a/res/include/style/viewer.css b/res/include/style/viewer.css index 87bc095..15b980d 100644 --- a/res/include/style/viewer.css +++ b/res/include/style/viewer.css @@ -180,6 +180,11 @@ transition: right 0.5s; background-color: var(--layer_2_color); } +.file_viewer > .file_viewer_window > .skyscraper > .skyscraper_ad_space { + width: 100%; + height: 100%; +} + /* ===================== == FILE CONTAINERS == diff --git a/res/template/file_viewer.html b/res/template/file_viewer.html index 7aca5b0..5d6b253 100644 --- a/res/template/file_viewer.html +++ b/res/template/file_viewer.html @@ -150,7 +150,7 @@ -
+
diff --git a/webcontroller/file_viewer.go b/webcontroller/file_viewer.go index 91b2167..57641d5 100644 --- a/webcontroller/file_viewer.go +++ b/webcontroller/file_viewer.go @@ -87,25 +87,32 @@ func (vd *viewerData) adType(files []pixelapi.ListFile) { // propellerPopup = 2 ) - vd.AdSkyscraperType = aAdsSkyscraper - // 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(10); i { + switch i := rand.Intn(20); i { case 0: - vd.AdBannerType = brave + vd.AdBannerType = publisherrest1 // 5%, total 5% + case 1: + vd.AdBannerType = publisherrest2 // 5%, total 10% + case 2: + vd.AdBannerType = publisherrest3 // 5%, total 15% + case 3, 4, 5: + vd.AdBannerType = brave // 15%, total 30% + case 6, 7, 8, 9, 10, 11, 12: + vd.AdBannerType = adsPlus // 35%, total 65% + case 13, 14, 15, 16, 17, 18, 19: + vd.AdBannerType = pixFuture // 35%, total 100% + default: + panic(fmt.Errorf("random number generator returned unrecognised number: %d", i)) + } + + switch i := rand.Intn(4); i { + case 0: + vd.AdSkyscraperType = aAdsSkyscraper case 1, 2, 3: - vd.AdBannerType = adsPlus - case 4, 5, 6: - vd.AdBannerType = pixFuture - case 7: - vd.AdBannerType = publisherrest1 - case 8: - vd.AdBannerType = publisherrest2 - case 9: - vd.AdBannerType = publisherrest3 + vd.AdSkyscraperType = pixfutureSkyscraper default: panic(fmt.Errorf("random number generator returned unrecognised number: %d", i)) } diff --git a/webcontroller/templates.go b/webcontroller/templates.go index 766fe1e..197eabf 100644 --- a/webcontroller/templates.go +++ b/webcontroller/templates.go @@ -141,6 +141,8 @@ func (tm *TemplateManager) ParseTemplates(silent bool) { "formatData": tm.formatData, "formatSC": tm.formatSC, "noescape": tm.noEscape, + "noescapeJS": tm.noEscapeJS, + "slashes": tm.slashes, }) // Parse dynamic templates @@ -296,9 +298,9 @@ func (tm *TemplateManager) formatSC(amt float64) string { } return fmtSize(amt/1e-24, "H") } -func (tm *TemplateManager) noEscape(t string) template.HTML { - return template.HTML(t) -} +func (tm *TemplateManager) noEscape(t string) template.HTML { return template.HTML(t) } +func (tm *TemplateManager) noEscapeJS(t string) template.JS { return template.JS(t) } +func (tm *TemplateManager) slashes() template.HTML { return template.HTML("//") } func detectInt(i interface{}) int { switch v := i.(type) { diff --git a/webcontroller/user_account.go b/webcontroller/user_account.go index f623ba8..80dab29 100644 --- a/webcontroller/user_account.go +++ b/webcontroller/user_account.go @@ -216,9 +216,11 @@ func (wc *WebController) loginForm(td *TemplateData, r *http.Request) (f Form) { // Strict means the Cookie will only be sent when the user // reaches a page by a link from the same domain. Lax means any // page on the domain gets the cookie and None means embedded - // content also gets the cookie. We're not trying to track the - // user around the web so we use lax - SameSite: http.SameSiteLaxMode, + // content also gets the cookie. + // + // Users who see pixeldrain links in iframes also expect their + // accounts to be logged in so we need to use None + SameSite: http.SameSiteNoneMode, Secure: true, } f.Extra.RedirectTo = "/user"