Update ad show logic
This commit is contained in:
@@ -71,7 +71,7 @@
|
||||
</button>
|
||||
<br/>
|
||||
|
||||
{{if .Other.ShowAds}}
|
||||
{{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }}
|
||||
<hr/>
|
||||
<!-- <div id="brave_ref" style="text-align: center; padding: 2px;"> -->
|
||||
{{if ne (isBrave .UserAgent) true}}
|
||||
@@ -119,7 +119,7 @@
|
||||
</div>
|
||||
|
||||
<div id="sponsors" class="sponsors">
|
||||
{{if .Other.ShowAds}}
|
||||
{{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }}
|
||||
{{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 -->
|
||||
<iframe class="sponsors_banner"
|
||||
@@ -159,8 +159,12 @@
|
||||
{{ 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>
|
||||
{{end}}
|
||||
{{ else }}
|
||||
<div style="text-align: center; line-height: 1.5em; font-size: 14px;">
|
||||
{{ else if not .Other.UserAdsEnabled }}
|
||||
<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>!
|
||||
</div>
|
||||
{{end}}
|
||||
@@ -256,7 +260,7 @@
|
||||
|
||||
{{template "analytics"}}
|
||||
|
||||
{{ if .Other.ShowAds }}
|
||||
{{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }}
|
||||
{{ if eq .Other.AdType 5 }}
|
||||
<script data-cfasync="false" defer src="//d227cncaprzd7y.cloudfront.net/?acncd=905608"></script>
|
||||
{{ else if eq .Other.AdType 6}}
|
||||
|
@@ -71,7 +71,8 @@ type viewerData struct {
|
||||
CaptchaKey string
|
||||
ViewToken string
|
||||
AdType int
|
||||
ShowAds bool
|
||||
FileAdsEnabled bool
|
||||
UserAdsEnabled bool
|
||||
APIResponse interface{}
|
||||
}
|
||||
|
||||
@@ -106,39 +107,30 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
||||
return
|
||||
}
|
||||
|
||||
showAds := true
|
||||
if finfo[0].ShowAds == false ||
|
||||
(templateData.Authenticated && templateData.User.Subscription.DisableAdDisplay) {
|
||||
showAds = false
|
||||
}
|
||||
|
||||
templateData.OGData = metadataFromFile(finfo[0].FileInfo)
|
||||
if len(ids) > 1 {
|
||||
templateData.Title = fmt.Sprintf("%d files on pixeldrain", len(finfo))
|
||||
templateData.Other = viewerData{
|
||||
Type: "list",
|
||||
|
||||
var vd = viewerData{
|
||||
CaptchaKey: wc.captchaKey(),
|
||||
ViewToken: wc.viewTokenOrBust(),
|
||||
AdType: adType(),
|
||||
ShowAds: showAds,
|
||||
APIResponse: apitype.ListInfo{
|
||||
FileAdsEnabled: finfo[0].ShowAds,
|
||||
UserAdsEnabled: !(templateData.Authenticated && templateData.User.Subscription.DisableAdDisplay),
|
||||
}
|
||||
if len(ids) > 1 {
|
||||
templateData.Title = fmt.Sprintf("%d files on pixeldrain", len(finfo))
|
||||
vd.Type = "list"
|
||||
vd.APIResponse = apitype.ListInfo{
|
||||
Success: true,
|
||||
Title: "Multiple files",
|
||||
DateCreated: time.Now(),
|
||||
Files: finfo,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
templateData.Title = fmt.Sprintf("%s ~ pixeldrain", finfo[0].Name)
|
||||
templateData.Other = viewerData{
|
||||
Type: "file",
|
||||
CaptchaKey: wc.captchaKey(),
|
||||
ViewToken: wc.viewTokenOrBust(),
|
||||
AdType: adType(),
|
||||
ShowAds: showAds,
|
||||
APIResponse: finfo[0].FileInfo,
|
||||
}
|
||||
vd.Type = "file"
|
||||
vd.APIResponse = finfo[0].FileInfo
|
||||
}
|
||||
templateData.Other = vd
|
||||
|
||||
var templateName = "file_viewer"
|
||||
if browserCompat(r.UserAgent()) {
|
||||
@@ -160,7 +152,8 @@ func (wc *WebController) serveFileViewerDemo(w http.ResponseWriter, r *http.Requ
|
||||
Type: "file",
|
||||
CaptchaKey: wc.captchaSiteKey,
|
||||
AdType: 0, // Always show a-ads on the demo page
|
||||
ShowAds: true,
|
||||
FileAdsEnabled: true,
|
||||
UserAdsEnabled: true,
|
||||
APIResponse: map[string]interface{}{
|
||||
"id": "demo",
|
||||
"name": "Demo file",
|
||||
@@ -203,12 +196,6 @@ func (wc *WebController) serveListViewer(w http.ResponseWriter, r *http.Request,
|
||||
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.OGData = metadataFromList(list)
|
||||
templateData.Other = viewerData{
|
||||
@@ -216,7 +203,8 @@ func (wc *WebController) serveListViewer(w http.ResponseWriter, r *http.Request,
|
||||
CaptchaKey: wc.captchaSiteKey,
|
||||
ViewToken: wc.viewTokenOrBust(),
|
||||
AdType: adType(),
|
||||
ShowAds: showAds,
|
||||
FileAdsEnabled: list.Files[0].ShowAds,
|
||||
UserAdsEnabled: !(templateData.Authenticated && templateData.User.Subscription.DisableAdDisplay),
|
||||
APIResponse: list,
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user