Update ad show logic
This commit is contained in:
@@ -71,7 +71,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
{{if .Other.ShowAds}}
|
{{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }}
|
||||||
<hr/>
|
<hr/>
|
||||||
<!-- <div id="brave_ref" style="text-align: center; padding: 2px;"> -->
|
<!-- <div id="brave_ref" style="text-align: center; padding: 2px;"> -->
|
||||||
{{if ne (isBrave .UserAgent) true}}
|
{{if ne (isBrave .UserAgent) true}}
|
||||||
@@ -119,7 +119,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="sponsors" class="sponsors">
|
<div id="sponsors" class="sponsors">
|
||||||
{{if .Other.ShowAds}}
|
{{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }}
|
||||||
{{if eq .Other.AdType 0}}
|
{{if eq .Other.AdType 0}}
|
||||||
<!-- scrolling="no" is not allowed by the W3C, but overflow: hidden doesn't work in chrome, so I have no choice -->
|
<!-- scrolling="no" is not allowed by the W3C, but overflow: hidden doesn't work in chrome, so I have no choice -->
|
||||||
<iframe class="sponsors_banner"
|
<iframe class="sponsors_banner"
|
||||||
@@ -159,8 +159,12 @@
|
|||||||
{{ else if eq .Other.AdType 7}}
|
{{ else if eq .Other.AdType 7}}
|
||||||
<iframe class="sponsors_banner" src="/ad/revenuehits" style="width:728px; height:90px; border:none; padding:0; overflow:hidden;" scrolling="no"></iframe>
|
<iframe class="sponsors_banner" src="/ad/revenuehits" style="width:728px; height:90px; border:none; padding:0; overflow:hidden;" scrolling="no"></iframe>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{ else }}
|
{{ else if not .Other.UserAdsEnabled }}
|
||||||
<div style="text-align: center; line-height: 1.5em; font-size: 14px;">
|
<div style="text-align: center; line-height: 1.3em; font-size: 13px;">
|
||||||
|
Thank you for supporting pixeldrain!
|
||||||
|
</div>
|
||||||
|
{{ else if not .Other.FileAdsEnabled }}
|
||||||
|
<div style="text-align: center; line-height: 1.3em; font-size: 13px;">
|
||||||
The uploader of this file disabled advertisements. You can do the same for <a href="/subscribe">only €2 per month</a>!
|
The uploader of this file disabled advertisements. You can do the same for <a href="/subscribe">only €2 per month</a>!
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
@@ -256,7 +260,7 @@
|
|||||||
|
|
||||||
{{template "analytics"}}
|
{{template "analytics"}}
|
||||||
|
|
||||||
{{ if .Other.ShowAds }}
|
{{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }}
|
||||||
{{ if eq .Other.AdType 5 }}
|
{{ if eq .Other.AdType 5 }}
|
||||||
<script data-cfasync="false" defer src="//d227cncaprzd7y.cloudfront.net/?acncd=905608"></script>
|
<script data-cfasync="false" defer src="//d227cncaprzd7y.cloudfront.net/?acncd=905608"></script>
|
||||||
{{ else if eq .Other.AdType 6}}
|
{{ else if eq .Other.AdType 6}}
|
||||||
|
@@ -67,12 +67,13 @@ func adType() (i int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type viewerData struct {
|
type viewerData struct {
|
||||||
Type string // file or list
|
Type string // file or list
|
||||||
CaptchaKey string
|
CaptchaKey string
|
||||||
ViewToken string
|
ViewToken string
|
||||||
AdType int
|
AdType int
|
||||||
ShowAds bool
|
FileAdsEnabled bool
|
||||||
APIResponse interface{}
|
UserAdsEnabled bool
|
||||||
|
APIResponse interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeFileViewer controller for GET /u/:id
|
// ServeFileViewer controller for GET /u/:id
|
||||||
@@ -106,39 +107,30 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
showAds := true
|
|
||||||
if finfo[0].ShowAds == false ||
|
|
||||||
(templateData.Authenticated && templateData.User.Subscription.DisableAdDisplay) {
|
|
||||||
showAds = false
|
|
||||||
}
|
|
||||||
|
|
||||||
templateData.OGData = metadataFromFile(finfo[0].FileInfo)
|
templateData.OGData = metadataFromFile(finfo[0].FileInfo)
|
||||||
|
|
||||||
|
var vd = viewerData{
|
||||||
|
CaptchaKey: wc.captchaKey(),
|
||||||
|
ViewToken: wc.viewTokenOrBust(),
|
||||||
|
AdType: adType(),
|
||||||
|
FileAdsEnabled: finfo[0].ShowAds,
|
||||||
|
UserAdsEnabled: !(templateData.Authenticated && templateData.User.Subscription.DisableAdDisplay),
|
||||||
|
}
|
||||||
if len(ids) > 1 {
|
if len(ids) > 1 {
|
||||||
templateData.Title = fmt.Sprintf("%d files on pixeldrain", len(finfo))
|
templateData.Title = fmt.Sprintf("%d files on pixeldrain", len(finfo))
|
||||||
templateData.Other = viewerData{
|
vd.Type = "list"
|
||||||
Type: "list",
|
vd.APIResponse = apitype.ListInfo{
|
||||||
CaptchaKey: wc.captchaKey(),
|
Success: true,
|
||||||
ViewToken: wc.viewTokenOrBust(),
|
Title: "Multiple files",
|
||||||
AdType: adType(),
|
DateCreated: time.Now(),
|
||||||
ShowAds: showAds,
|
Files: finfo,
|
||||||
APIResponse: apitype.ListInfo{
|
|
||||||
Success: true,
|
|
||||||
Title: "Multiple files",
|
|
||||||
DateCreated: time.Now(),
|
|
||||||
Files: finfo,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
templateData.Title = fmt.Sprintf("%s ~ pixeldrain", finfo[0].Name)
|
templateData.Title = fmt.Sprintf("%s ~ pixeldrain", finfo[0].Name)
|
||||||
templateData.Other = viewerData{
|
vd.Type = "file"
|
||||||
Type: "file",
|
vd.APIResponse = finfo[0].FileInfo
|
||||||
CaptchaKey: wc.captchaKey(),
|
|
||||||
ViewToken: wc.viewTokenOrBust(),
|
|
||||||
AdType: adType(),
|
|
||||||
ShowAds: showAds,
|
|
||||||
APIResponse: finfo[0].FileInfo,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
templateData.Other = vd
|
||||||
|
|
||||||
var templateName = "file_viewer"
|
var templateName = "file_viewer"
|
||||||
if browserCompat(r.UserAgent()) {
|
if browserCompat(r.UserAgent()) {
|
||||||
@@ -157,10 +149,11 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
|||||||
func (wc *WebController) serveFileViewerDemo(w http.ResponseWriter, r *http.Request) {
|
func (wc *WebController) serveFileViewerDemo(w http.ResponseWriter, r *http.Request) {
|
||||||
templateData := wc.newTemplateData(w, r)
|
templateData := wc.newTemplateData(w, r)
|
||||||
templateData.Other = viewerData{
|
templateData.Other = viewerData{
|
||||||
Type: "file",
|
Type: "file",
|
||||||
CaptchaKey: wc.captchaSiteKey,
|
CaptchaKey: wc.captchaSiteKey,
|
||||||
AdType: 0, // Always show a-ads on the demo page
|
AdType: 0, // Always show a-ads on the demo page
|
||||||
ShowAds: true,
|
FileAdsEnabled: true,
|
||||||
|
UserAdsEnabled: true,
|
||||||
APIResponse: map[string]interface{}{
|
APIResponse: map[string]interface{}{
|
||||||
"id": "demo",
|
"id": "demo",
|
||||||
"name": "Demo file",
|
"name": "Demo file",
|
||||||
@@ -203,21 +196,16 @@ func (wc *WebController) serveListViewer(w http.ResponseWriter, r *http.Request,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
showAds := true
|
|
||||||
if (templateData.Authenticated && templateData.User.Subscription.DisableAdDisplay) ||
|
|
||||||
list.Files[0].ShowAds == false {
|
|
||||||
showAds = false
|
|
||||||
}
|
|
||||||
|
|
||||||
templateData.Title = fmt.Sprintf("%s ~ pixeldrain", list.Title)
|
templateData.Title = fmt.Sprintf("%s ~ pixeldrain", list.Title)
|
||||||
templateData.OGData = metadataFromList(list)
|
templateData.OGData = metadataFromList(list)
|
||||||
templateData.Other = viewerData{
|
templateData.Other = viewerData{
|
||||||
Type: "list",
|
Type: "list",
|
||||||
CaptchaKey: wc.captchaSiteKey,
|
CaptchaKey: wc.captchaSiteKey,
|
||||||
ViewToken: wc.viewTokenOrBust(),
|
ViewToken: wc.viewTokenOrBust(),
|
||||||
AdType: adType(),
|
AdType: adType(),
|
||||||
ShowAds: showAds,
|
FileAdsEnabled: list.Files[0].ShowAds,
|
||||||
APIResponse: list,
|
UserAdsEnabled: !(templateData.Authenticated && templateData.User.Subscription.DisableAdDisplay),
|
||||||
|
APIResponse: list,
|
||||||
}
|
}
|
||||||
|
|
||||||
var templateName = "file_viewer"
|
var templateName = "file_viewer"
|
||||||
|
Reference in New Issue
Block a user