mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
gads on master
This commit is contained in:
parent
8552515e34
commit
61ace3566a
3 changed files with 106 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { SHOW_ADS } from 'config';
|
import { SHOW_ADS, SIMPLE_SITE } from 'config';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ClaimList from 'component/claimList';
|
import ClaimList from 'component/claimList';
|
||||||
import Ads from 'web/component/ads';
|
import Ads from 'web/component/ads';
|
||||||
|
@ -58,7 +58,7 @@ export default function RecommendedContent(props: Props) {
|
||||||
type="small"
|
type="small"
|
||||||
loading={isSearching}
|
loading={isSearching}
|
||||||
uris={recommendedContent}
|
uris={recommendedContent}
|
||||||
injectedItem={SHOW_ADS && !isAuthenticated && IS_WEB && <Ads type="video" small />}
|
injectedItem={SHOW_ADS && !isAuthenticated && IS_WEB && <Ads small type={SIMPLE_SITE ? 'google' : 'video'} />}
|
||||||
empty={__('No related content found')}
|
empty={__('No related content found')}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
> div {
|
> div,
|
||||||
|
ins {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative !important;
|
position: relative !important;
|
||||||
max-width: 30rem;
|
max-width: 30rem;
|
||||||
|
@ -45,6 +46,34 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Related list ads
|
||||||
|
.ads__related--google {
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
//padding: var(--spacing-s);
|
||||||
|
background-color: var(--color-card-background);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
> div,
|
||||||
|
ins {
|
||||||
|
width: 100%;
|
||||||
|
position: relative !important;
|
||||||
|
max-width: 30rem;
|
||||||
|
min-width: 15rem;
|
||||||
|
margin: var(--spacing-s);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: $breakpoint-small) {
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
> div {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.ads__claim-text {
|
.ads__claim-text {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
|
@ -9,7 +9,12 @@ import classnames from 'classnames';
|
||||||
|
|
||||||
const ADS_URL = '//assets.revcontent.com/master/delivery.js';
|
const ADS_URL = '//assets.revcontent.com/master/delivery.js';
|
||||||
const IS_MOBILE = typeof window.orientation !== 'undefined';
|
const IS_MOBILE = typeof window.orientation !== 'undefined';
|
||||||
|
const G_AD_ID = 'ca-pub-7102138296475003';
|
||||||
|
// const G_AD_ONE_LAYOUT = '-gv+p-3a-8r+sd';
|
||||||
|
// const G_AD_ONE_SLOT = '6052061397';
|
||||||
|
|
||||||
|
const G_AD_TWO_LAYOUT = '-hl-o+3s-6c+33'; // dark mode, related
|
||||||
|
const G_AD_TWO_SLOT = '1498002046';
|
||||||
type Props = {
|
type Props = {
|
||||||
location: { pathname: string },
|
location: { pathname: string },
|
||||||
type: string,
|
type: string,
|
||||||
|
@ -22,21 +27,21 @@ function Ads(props: Props) {
|
||||||
type = 'sidebar',
|
type = 'sidebar',
|
||||||
small,
|
small,
|
||||||
} = props;
|
} = props;
|
||||||
|
let googleInit;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (SHOW_ADS && type === 'video') {
|
if (SHOW_ADS && type === 'video') {
|
||||||
|
let script;
|
||||||
try {
|
try {
|
||||||
const d = document;
|
const d = document;
|
||||||
const s = 'script';
|
const s = 'script';
|
||||||
const n = 'playbuzz-stream';
|
const n = 'playbuzz-stream';
|
||||||
|
|
||||||
let js;
|
|
||||||
let fjs = d.getElementsByTagName(s)[0];
|
let fjs = d.getElementsByTagName(s)[0];
|
||||||
js = d.createElement(s);
|
script = d.createElement(s);
|
||||||
js.className = n;
|
script.className = n;
|
||||||
js.src = 'https://stream.playbuzz.com/player/62d1eb10-e362-4873-99ed-c64a4052b43b';
|
script.src = 'https://stream.playbuzz.com/player/62d1eb10-e362-4873-99ed-c64a4052b43b';
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
fjs.parentNode.insertBefore(js, fjs);
|
fjs.parentNode.insertBefore(script, fjs);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}, [type]);
|
}, [type]);
|
||||||
|
@ -61,6 +66,50 @@ function Ads(props: Props) {
|
||||||
}
|
}
|
||||||
}, [type]);
|
}, [type]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let script;
|
||||||
|
|
||||||
|
if (SHOW_ADS && type === 'google') {
|
||||||
|
const d = document;
|
||||||
|
if (!d.getElementById('googleadscriptid')) {
|
||||||
|
try {
|
||||||
|
const s = 'script';
|
||||||
|
let fjs = d.getElementsByTagName(s)[0];
|
||||||
|
script = d.createElement(s);
|
||||||
|
script.id = 'googleadscriptid';
|
||||||
|
script.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
|
||||||
|
script.setAttribute('async', 'async');
|
||||||
|
script.setAttribute('data-ad-client', 'ca-pub-7102138296475003');
|
||||||
|
// $FlowFixMe
|
||||||
|
fjs.parentNode.insertBefore(script, fjs);
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
googleInit = setTimeout(() => {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
(window.adsbygoogle = window.adsbygoogle || []).push({});
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
return () => {
|
||||||
|
if (googleInit) {
|
||||||
|
clearTimeout(googleInit);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [type]);
|
||||||
|
|
||||||
|
const googleAd = (
|
||||||
|
<div className="ads__related--google">
|
||||||
|
<ins
|
||||||
|
className="adsbygoogle"
|
||||||
|
style={{ display: 'block' }}
|
||||||
|
data-ad-format="fluid"
|
||||||
|
data-ad-layout-key={G_AD_TWO_LAYOUT}
|
||||||
|
data-ad-client={G_AD_ID}
|
||||||
|
data-ad-slot={G_AD_TWO_SLOT}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
const adsSignInDriver = (
|
const adsSignInDriver = (
|
||||||
<I18nMessage
|
<I18nMessage
|
||||||
tokens={{
|
tokens={{
|
||||||
|
@ -78,11 +127,7 @@ function Ads(props: Props) {
|
||||||
</I18nMessage>
|
</I18nMessage>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!SHOW_ADS) {
|
const videoAd = (
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type === 'video' ? (
|
|
||||||
<div className="ads__claim-item">
|
<div className="ads__claim-item">
|
||||||
<div id="62d1eb10-e362-4873-99ed-c64a4052b43b" />
|
<div id="62d1eb10-e362-4873-99ed-c64a4052b43b" />
|
||||||
<div
|
<div
|
||||||
|
@ -94,7 +139,9 @@ function Ads(props: Props) {
|
||||||
<p>{adsSignInDriver}</p>
|
<p>{adsSignInDriver}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
);
|
||||||
|
|
||||||
|
const sidebarAd = (
|
||||||
<div className="ads-wrapper">
|
<div className="ads-wrapper">
|
||||||
<p>Ads</p>
|
<p>Ads</p>
|
||||||
<p>{adsSignInDriver}</p>
|
<p>{adsSignInDriver}</p>
|
||||||
|
@ -107,6 +154,21 @@ function Ads(props: Props) {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!SHOW_ADS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (type === 'video') {
|
||||||
|
return videoAd;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === 'google') {
|
||||||
|
return googleAd;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === 'sidebar') {
|
||||||
|
return sidebarAd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(Ads);
|
export default withRouter(Ads);
|
||||||
|
|
Loading…
Add table
Reference in a new issue