Move ads to separate template
This commit is contained in:
114
res/template/advertisements.html
Normal file
114
res/template/advertisements.html
Normal file
@@ -0,0 +1,114 @@
|
||||
{{ define "banner_ads"}}
|
||||
|
||||
{{ if eq .Other.AdBannerType 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"
|
||||
data-aa="73974"
|
||||
src="//ad.a-ads.com/73974?size=728x90&background_color={{.Style.Layer1Color.RGB}}&text_color={{.Style.TextColor.RGB}}&title_color={{.Style.HighlightColor.RGB}}&title_hover_color={{.Style.HighlightColor.RGB}}&link_color={{.Style.HighlightColor.RGB}}&link_hover_color={{.Style.HighlightColor.RGB}}"
|
||||
style="width:728px; height:90px; border:none; padding:0; overflow:hidden;"
|
||||
scrolling="no">
|
||||
</iframe>
|
||||
{{ else if eq .Other.AdBannerType 1 }}
|
||||
<!-- Amarula electronics -->
|
||||
<a class="sponsors_banner" style="display: inline-block; width: 576px; height: 96px;" href="/click/DtZ3hHT9?target=https%3A%2F%2Fwww.amarula-electronics.com">
|
||||
<img src="/res/img/misc/banner_as.png" style="width: 100%; height: 100%" />
|
||||
</a>
|
||||
{{else if eq .Other.AdBannerType 2}}
|
||||
<!-- Patreon -->
|
||||
<div style="text-align: center; line-height: 22px; font-size: 18px;">
|
||||
<div style="margin: 4px 8px; display: inline-block; vertical-align: middle;">
|
||||
Pixeldrain needs money to survive<br/>
|
||||
<a href="/click/7wy9gg2J?target=%2Fsubscribe" class="button button_highlight">
|
||||
Support me on Patreon and get some neat perks
|
||||
</a>
|
||||
</div>
|
||||
<div style="margin: 4px 8px; display: inline-block; vertical-align: middle; text-align: left;">
|
||||
No ads when viewing files<br/>
|
||||
No ads on your uploaded files<br/>
|
||||
Longer file retention<br/>
|
||||
</div>
|
||||
<div>
|
||||
{{else if eq .Other.AdBannerType 3}}
|
||||
<!-- Soul Studio -->
|
||||
<a class="sponsors_banner" style="display: inline-block; width: 842px; height: 125px;" href="/click/RJRbh7Tn?target=https%3A%2F%2Fsoulstudio.nl%2Fonline-y">
|
||||
<img src="/res/img/misc/banner_soul_studio.png" style="width: 100%; height: 100%" />
|
||||
</a>
|
||||
{{else if eq .Other.AdBannerType 4}}
|
||||
<!-- Amarula Jobs -->
|
||||
<a class="sponsors_banner" style="display: inline-block; width: 576px; height: 96px;" href="/click/DtZ3hHT9?target=https%3A%2F%2Fwww.amarulasolutions.com/jobs">
|
||||
<img src="/res/img/misc/banner_amarula_jobs.png" style="width: 100%; height: 100%" />
|
||||
</a>
|
||||
{{ else if eq .Other.AdBannerType 6 }}
|
||||
<div class="sponsors_banner" style="display: inline-block; width: 728px; height: 90px;">
|
||||
<script type="text/javascript">
|
||||
atOptions = {
|
||||
'key' : 'a62692cf48c3969d426a09c868ae13f7',
|
||||
'format' : 'iframe',
|
||||
'height' : 90,
|
||||
'width' : 728,
|
||||
'params' : {}
|
||||
};
|
||||
document.write('<scr' + 'ipt type="text/javascript" defer src="http' + (location.protocol === 'https:' ? 's' : '') + '://www.highperformancedisplaycontent.com/a62692cf48c3969d426a09c868ae13f7/invoke.js"></scr' + 'ipt>');
|
||||
</script>
|
||||
</div>
|
||||
{{ else if eq .Other.AdBannerType 7 }}
|
||||
<a class="sponsors_banner" style="display: inline-block; width: 728px; height: 90px;" href="/brave">
|
||||
<img src="/res/img/misc/brave-728x90.png" style="width: 100%; height: 100%" />
|
||||
</a>
|
||||
{{ else if eq .Other.AdBannerType 8 }}
|
||||
<div style="text-align: center; line-height: 1.4em; font-size: 22px;">
|
||||
<img src="/res/img/pixeldrain_128.png" style="height: 2.4em; vertical-align: middle; margin: 4px;"/>
|
||||
<div style="margin: 4px; display: inline-block; vertical-align: middle;">
|
||||
Are your files expiring too quickly?<br/>
|
||||
<a href="/click/7wy9gg2J?target=%2F%23pro" class="button button_highlight">Pixeldrain Pro: Only €2 per month</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ else if eq .Other.AdBannerType 9 }}
|
||||
<div style="text-align: center; line-height: 1.4em; font-size: 22px;">
|
||||
<img src="/res/img/pixeldrain_128.png" style="height: 2.4em; vertical-align: middle; margin: 4px;"/>
|
||||
<div style="margin: 4px; display: inline-block; vertical-align: middle;">
|
||||
Are your files too large to share?<br/>
|
||||
<a href="/click/7wy9gg2J?target=%2F%23pro" class="button button_highlight">Pixeldrain Pro: Only €2 per month</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ else if eq .Other.AdBannerType 10 }}
|
||||
<div style="text-align: center; line-height: 1.4em; font-size: 22px;">
|
||||
<img src="/res/img/pixeldrain_128.png" style="height: 2.4em; vertical-align: middle; margin: 4px;"/>
|
||||
<div style="margin: 4px; display: inline-block; vertical-align: middle;">
|
||||
Are you tired of advertisements?<br/>
|
||||
<a href="/click/7wy9gg2J?target=%2F%23pro" class="button button_highlight">Pixeldrain Pro: Only €2 per month</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ else if eq .Other.AdBannerType 11 }}
|
||||
<div style="text-align: center; line-height: 1.4em; font-size: 22px;">
|
||||
<img src="/res/img/pixeldrain_128.png" style="height: 2.4em; vertical-align: middle; margin: 4px;"/>
|
||||
<div style="margin: 4px; display: inline-block; vertical-align: middle;">
|
||||
Concerned about your online privacy?<br/>
|
||||
<a href="/click/7wy9gg2J?target=%2F%23pro" class="button button_highlight">Pixeldrain Pro: Only €2 per month</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
{{ define "floating_ads"}}
|
||||
|
||||
{{ if eq .Other.AdFloaterType 3 }}
|
||||
<!-- AdMaven -->
|
||||
<script data-cfasync="false" async src="//d227cncaprzd7y.cloudfront.net/?acncd=905608"></script>
|
||||
{{ else if eq .Other.AdFloaterType 2 }}
|
||||
<!-- AdSterra -->
|
||||
<script type='text/javascript' async src='//concoursestrickenpuppy.com/4c/4d/90/4c4d90a2e79b0e049f811a663f3e3c07.js'></script>
|
||||
{{ else if eq .Other.AdFloaterType 1 }}
|
||||
<!-- PropellerAds -->
|
||||
<script>
|
||||
// Load fires when the page is completely finished loading, including assets
|
||||
window.addEventListener("load", () => {
|
||||
(function(d,z,s){
|
||||
s.src='//'+d+'/400/'+z
|
||||
try{(document.body||document.documentElement).appendChild(s)}catch(e){}
|
||||
})('in-page-push.com',3724132,document.createElement('script'))
|
||||
})
|
||||
</script>
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
@@ -141,81 +141,7 @@
|
||||
|
||||
<div id="sponsors" class="sponsors">
|
||||
{{ 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"
|
||||
data-aa="73974"
|
||||
src="//ad.a-ads.com/73974?size=728x90&background_color={{.Style.Layer1Color.RGB}}&text_color={{.Style.TextColor.RGB}}&title_color={{.Style.HighlightColor.RGB}}&title_hover_color={{.Style.HighlightColor.RGB}}&link_color={{.Style.HighlightColor.RGB}}&link_hover_color={{.Style.HighlightColor.RGB}}"
|
||||
style="width:728px; height:90px; border:none; padding:0; overflow:hidden;"
|
||||
scrolling="no">
|
||||
</iframe>
|
||||
{{ else if eq .Other.AdType 1 }}
|
||||
<!-- Amarula electronics -->
|
||||
<a class="sponsors_banner" style="display: inline-block; width: 576px; height: 96px;" href="/click/DtZ3hHT9?target=https%3A%2F%2Fwww.amarula-electronics.com">
|
||||
<img src="/res/img/misc/banner_as.png" style="width: 100%; height: 100%" />
|
||||
</a>
|
||||
{{else if eq .Other.AdType 2}}
|
||||
<!-- Patreon -->
|
||||
<div style="text-align: center; line-height: 22px; font-size: 18px;">
|
||||
<div style="margin: 4px 8px; display: inline-block; vertical-align: middle;">
|
||||
Pixeldrain needs money to survive<br/>
|
||||
<a href="/click/7wy9gg2J?target=%2Fsubscribe" class="button button_highlight">
|
||||
Support me on Patreon and get some neat perks
|
||||
</a>
|
||||
</div>
|
||||
<div style="margin: 4px 8px; display: inline-block; vertical-align: middle; text-align: left;">
|
||||
No ads when viewing files<br/>
|
||||
No ads on your uploaded files<br/>
|
||||
Longer file retention<br/>
|
||||
</div>
|
||||
<div>
|
||||
{{else if eq .Other.AdType 3}}
|
||||
<!-- Soul Studio -->
|
||||
<a class="sponsors_banner" style="display: inline-block; width: 842px; height: 125px;" href="/click/RJRbh7Tn?target=https%3A%2F%2Fsoulstudio.nl%2Fonline-y">
|
||||
<img src="/res/img/misc/banner_soul_studio.png" style="width: 100%; height: 100%" />
|
||||
</a>
|
||||
{{else if eq .Other.AdType 4}}
|
||||
<!-- Amarula Jobs -->
|
||||
<a class="sponsors_banner" style="display: inline-block; width: 576px; height: 96px;" href="/click/DtZ3hHT9?target=https%3A%2F%2Fwww.amarulasolutions.com/jobs">
|
||||
<img src="/res/img/misc/banner_amarula_jobs.png" style="width: 100%; height: 100%" />
|
||||
</a>
|
||||
{{ else if eq .Other.AdType 7 }}
|
||||
<a class="sponsors_banner" style="display: inline-block; width: 728px; height: 90px;" href="/brave">
|
||||
<img src="/res/img/misc/brave-728x90.png" style="width: 100%; height: 100%" />
|
||||
</a>
|
||||
{{ else if eq .Other.AdType 8 }}
|
||||
<div style="text-align: center; line-height: 1.4em; font-size: 22px;">
|
||||
<img src="/res/img/pixeldrain_128.png" style="height: 2.4em; vertical-align: middle; margin: 4px;"/>
|
||||
<div style="margin: 4px; display: inline-block; vertical-align: middle;">
|
||||
Are your files expiring too quickly?<br/>
|
||||
<a href="/click/7wy9gg2J?target=%2F%23pro" class="button button_highlight">Pixeldrain Pro: Only €2 per month</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ else if eq .Other.AdType 9 }}
|
||||
<div style="text-align: center; line-height: 1.4em; font-size: 22px;">
|
||||
<img src="/res/img/pixeldrain_128.png" style="height: 2.4em; vertical-align: middle; margin: 4px;"/>
|
||||
<div style="margin: 4px; display: inline-block; vertical-align: middle;">
|
||||
Are your files too large to share?<br/>
|
||||
<a href="/click/7wy9gg2J?target=%2F%23pro" class="button button_highlight">Pixeldrain Pro: Only €2 per month</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ else if eq .Other.AdType 10 }}
|
||||
<div style="text-align: center; line-height: 1.4em; font-size: 22px;">
|
||||
<img src="/res/img/pixeldrain_128.png" style="height: 2.4em; vertical-align: middle; margin: 4px;"/>
|
||||
<div style="margin: 4px; display: inline-block; vertical-align: middle;">
|
||||
Are you tired of advertisements?<br/>
|
||||
<a href="/click/7wy9gg2J?target=%2F%23pro" class="button button_highlight">Pixeldrain Pro: Only €2 per month</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ else if eq .Other.AdType 11 }}
|
||||
<div style="text-align: center; line-height: 1.4em; font-size: 22px;">
|
||||
<img src="/res/img/pixeldrain_128.png" style="height: 2.4em; vertical-align: middle; margin: 4px;"/>
|
||||
<div style="margin: 4px; display: inline-block; vertical-align: middle;">
|
||||
Concerned about your online privacy?<br/>
|
||||
<a href="/click/7wy9gg2J?target=%2F%23pro" class="button button_highlight">Pixeldrain Pro: Only €2 per month</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ template "banner_ads" . }}
|
||||
{{ else if not .Other.UserAdsEnabled }}
|
||||
<div style="text-align: center; line-height: 1.3em; font-size: 13px;">
|
||||
Thank you for supporting pixeldrain!
|
||||
@@ -224,7 +150,7 @@
|
||||
<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="/#pro">only €2 per month</a>!
|
||||
</div>
|
||||
{{end}}
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -416,22 +342,7 @@
|
||||
{{template "analytics"}}
|
||||
|
||||
{{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }}
|
||||
{{ if eq .Other.AdType 5 }}
|
||||
<!-- AdMaven -->
|
||||
<script data-cfasync="false" async src="//d227cncaprzd7y.cloudfront.net/?acncd=905608"></script>
|
||||
{{ else if ne .Other.AdType 4 }}
|
||||
<!-- PropellerAds -->
|
||||
<script>
|
||||
// Load fires when the page is completely finished loading,
|
||||
// including assets
|
||||
window.addEventListener("load", () => {
|
||||
(function(d,z,s){
|
||||
s.src='//'+d+'/400/'+z
|
||||
try{(document.body||document.documentElement).appendChild(s)}catch(e){}
|
||||
})('in-page-push.com',3724132,document.createElement('script'))
|
||||
})
|
||||
</script>
|
||||
{{ end }}
|
||||
{{ template "floating_ads" . }}
|
||||
{{ end }}
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -287,7 +287,7 @@ const node_click = (index) => {
|
||||
on:click|preventDefault={() => {node_click(index)}}
|
||||
>
|
||||
<div>
|
||||
<img src={file.icon} alt="file thumbnail" />
|
||||
<img src={file.icon} alt="thumbnail" />
|
||||
<span>{file.name}</span>
|
||||
</div>
|
||||
<div style="width: {tableColumns[1].width}">
|
||||
|
@@ -28,19 +28,27 @@ func browserCompat(ua string) bool {
|
||||
return strings.Contains(ua, "MSIE") || strings.Contains(ua, "Trident/7.0")
|
||||
}
|
||||
|
||||
func adType() int {
|
||||
func adType() (banner, floater int) {
|
||||
const (
|
||||
// Banners
|
||||
aAds = 0
|
||||
amarulaElectronics = 1
|
||||
patreon = 2
|
||||
soulStudio = 3
|
||||
amarulaSolutions = 4
|
||||
adMaven = 5
|
||||
adSterra = 6
|
||||
brave = 7
|
||||
pdpro1 = 8
|
||||
pdpro2 = 9
|
||||
pdpro3 = 10
|
||||
pdpro4 = 11
|
||||
|
||||
// Floaters
|
||||
none = 0
|
||||
propellerFloat = 1
|
||||
adSterraFloat = 2
|
||||
adMavenFloat = 3
|
||||
)
|
||||
|
||||
// Intn returns a number up to n, but never n itself. So to get a random 0
|
||||
@@ -48,21 +56,33 @@ func adType() int {
|
||||
// splits like 1/3 1/4, etc
|
||||
switch i := rand.Intn(10); i {
|
||||
case 0: // 10%
|
||||
return amarulaSolutions
|
||||
banner = amarulaSolutions
|
||||
case 1, 2, 3, 4, 5: // 50%
|
||||
return brave
|
||||
banner = brave
|
||||
case 6, 7, 8, 9: // 40%
|
||||
return aAds
|
||||
banner = aAds
|
||||
default:
|
||||
panic(fmt.Errorf("random number generator returned unrecognised number: %d", i))
|
||||
}
|
||||
|
||||
switch i := rand.Intn(4); i {
|
||||
case 0, 1, 2: // 75%
|
||||
floater = propellerFloat
|
||||
case 3: // 25%
|
||||
floater = adSterraFloat
|
||||
default:
|
||||
panic(fmt.Errorf("random number generator returned unrecognised number: %d", i))
|
||||
}
|
||||
|
||||
return banner, floater
|
||||
}
|
||||
|
||||
type viewerData struct {
|
||||
Type string // file or list
|
||||
CaptchaKey string
|
||||
ViewToken string
|
||||
AdType int
|
||||
AdBannerType int
|
||||
AdFloaterType int
|
||||
FileAdsEnabled bool
|
||||
UserAdsEnabled bool
|
||||
Embedded bool
|
||||
@@ -112,10 +132,10 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
||||
var vd = viewerData{
|
||||
CaptchaKey: wc.captchaKey(),
|
||||
ViewToken: wc.viewTokenOrBust(),
|
||||
AdType: adType(),
|
||||
FileAdsEnabled: files[0].ShowAds,
|
||||
UserAdsEnabled: !(templateData.Authenticated && templateData.User.Subscription.DisableAdDisplay),
|
||||
}
|
||||
vd.AdBannerType, vd.AdFloaterType = adType()
|
||||
|
||||
if len(ids) > 1 {
|
||||
templateData.Title = fmt.Sprintf("%d files on pixeldrain", len(files))
|
||||
@@ -164,7 +184,8 @@ func (wc *WebController) serveFileViewerDemo(w http.ResponseWriter, r *http.Requ
|
||||
templateData.Other = viewerData{
|
||||
Type: "file",
|
||||
CaptchaKey: wc.captchaSiteKey,
|
||||
AdType: 0, // Always show a-ads on the demo page
|
||||
AdBannerType: 0, // Always show a-ads on the demo page
|
||||
AdFloaterType: 0, // No floaters
|
||||
FileAdsEnabled: true,
|
||||
UserAdsEnabled: true,
|
||||
APIResponse: map[string]interface{}{
|
||||
@@ -215,11 +236,11 @@ func (wc *WebController) serveListViewer(w http.ResponseWriter, r *http.Request,
|
||||
Type: "list",
|
||||
CaptchaKey: wc.captchaSiteKey,
|
||||
ViewToken: wc.viewTokenOrBust(),
|
||||
AdType: adType(),
|
||||
FileAdsEnabled: list.Files[0].ShowAds,
|
||||
UserAdsEnabled: !(templateData.Authenticated && templateData.User.Subscription.DisableAdDisplay),
|
||||
APIResponse: list,
|
||||
}
|
||||
vd.AdBannerType, vd.AdFloaterType = adType()
|
||||
|
||||
if _, ok := r.URL.Query()["embed"]; ok {
|
||||
vd.Embedded = true
|
||||
@@ -317,8 +338,7 @@ func (wc *WebController) serveSkynetViewer(w http.ResponseWriter, r *http.Reques
|
||||
|
||||
templateData.Title = fmt.Sprintf("name ~ Skynet")
|
||||
templateData.Other = viewerData{
|
||||
Type: "skylink",
|
||||
AdType: adType(),
|
||||
Type: "skylink",
|
||||
APIResponse: pixelapi.FileInfo{
|
||||
Success: true,
|
||||
ID: p.ByName("id"),
|
||||
|
Reference in New Issue
Block a user