Commit 10581f6d authored by Jason Salyers's avatar Jason Salyers
Browse files

Merge branch '145-remove-gpt' into 'develop'

Resolve "Remove google ads codes"

Closes #145

See merge request !276
parents 752803be e9ad1460
......@@ -39,11 +39,6 @@
"conveyor_username": "CONVEYOR_USERNAME",
"special_posts_url": "SPECIAL_POSTS_URL",
"wallet_url": "WALLET_URL",
"google_ad_enabled": "GOOGLE_AD_ENABLED",
"google_ad_test": "GOOGLE_AD_TEST",
"google_ad_client": "GOOGLE_AD_CLIENT",
"gpt_enabled": "GPT_ENABLED",
"video_ads_enabled": "VIDEO_ADS_ENABLED",
"steem_market_endpoint": "STEEM_MARKET_ENDPOINT",
"steem_market_token": "STEEM_MARKET_TOKEN",
"cookie_consent_enabled": "SDC_ENABLE_COOKIE_CONSENT",
......
......@@ -5,7 +5,7 @@
"directives": {
"childSrc": "'self' 3speak.tv emb.d.tube player.twitch.tv www.youtube.com staticxx.facebook.com w.soundcloud.com player.vimeo.com",
"connectSrc": "https://images.hive.blog 'self' hive.blog https://api.hive.blog api.blocktrades.us https://anyx.io https://hivesigner.com https://hivebuzz.me https://peakd.com https://api.deathwing.me https://www.reddit.com https://gist.github.com https://rpc.ausbit.dev https://api.ha.deathwing.me *.ibytedtos.com",
"defaultSrc": "tpc.googlesyndication.com 'self' img.3speakcontent.online emb.d.tube www.youtube.com staticxx.facebook.com player.vimeo.com *.streamrail.com",
"defaultSrc": "'self' img.3speakcontent.online emb.d.tube www.youtube.com staticxx.facebook.com player.vimeo.com *.streamrail.com",
"fontSrc": "data: fonts.gstatic.com cdn.embedly.com",
"frameAncestors": "'none'",
"frameSrc": "'self' https:",
......@@ -47,179 +47,6 @@
"conveyor_username": false,
"special_posts_url": false,
"wallet_url": "https://wallet.hive.blog",
"gpt_banned_tags": ["nsfw", "tante"],
"google_ad_enabled": null,
"google_ad_test": null,
"google_ad_client": null,
"google_ad_slots": {
"market_1": {
"slot_id": "0"
},
"in_feed_1": {
"slot_id": "0",
"layout_key": "-fb+5w+4e-db+86",
"every": 15
}
},
"video_ads_enabled": null,
"gpt_enabled": null,
"gpt_basic_slots": {
"bottom-of-post": {
"path": "/21784675435/steemit_bottom-of-post",
"dimensions": [[728, 90], [970, 90]]
},
"bottom-of-post-mobile": {
"path": "/21784675435/steemit_bottom-of-post/steemit_bottom-of-post_mobile",
"dimensions": [[220, 90]]
},
"left-navigation": {
"path": "/21784675435/steemit_left-navigation",
"dimensions": [[120, 600], [160, 600]]
},
"left-navigation-loggedin-mobile": {
"path": "/21784675435/steemit_left-navigation/steemit_left-navigation_loggedin_mobile",
"dimensions": [[120, 240]]
},
"left-navigation-loggedin": {
"path": "/21784675435/steemit_left-navigation/steemit_left-navigation_loggedin",
"dimensions": [[120, 600], [160, 600]]
},
"left-navigation-mobile": {
"path": "/21784675435/steemit_left-navigation/steemit_left-navigation_mobile",
"dimensions": [[120, 240]]
},
"right-navigation": {
"path": "/21784675435/steemit_right-navigation",
"dimensions": [[120, 600], [160, 600]]
},
"right-navigation-loggedin-mobile": {
"path": "/21784675435/steemit_right-navigation/steemit_right-navigation_loggedin_mobile",
"dimensions": [[120, 240]]
},
"right-navigation-loggedin": {
"path": "/21784675435/steemit_right-navigation/steemit_right-navigation_loggedin",
"dimensions": [[120, 600], [160, 600]]
},
"right-navigation-mobile": {
"path": "/21784675435/steemit_right-navigation/steemit_right-navigation_mobile",
"dimensions": [[120, 240]]
},
"top-navigation": {
"path": "/21784675435/steemit_top-navi",
"dimensions": [[728, 90], [970, 90]]
},
"top-navigation-loggedin-mobile": {
"path": "/21784675435/steemit_top-navi/steemit_top-navi_loggedin_mobile",
"dimensions": [[220, 90]]
},
"top-navigation-loggedin": {
"path": "/21784675435/steemit_top-navi/steemit_top-navi_loggedin",
"dimensions": [[728, 90], [970, 90]]
},
"top-navigation-mobile": {
"path": "/21784675435/steemit_top-navi/steemit_top-navi_mobile",
"dimensions": [[220, 90]]
}
},
"gpt_category_slots": {},
"gpt_bidding_slots":{
"bottom-of-post": {
"path": "/21784675435/steemit_bottom-of-post/steemit_bottom-of-post_prebid",
"dimensions": [[728, 90]]
},
"post-page-above-comments": {
"path": "/21784675435/steemit_post-page-above-comments",
"dimensions": [[728, 90], [970, 90]]
},
"post-page-above-comments-loggedin-mobile": {
"path": "/21784675435/steemit_post-page-above-comments/steemit_post-page-above-comments_loggedin_mobile",
"dimensions": [[220, 90]]
},
"post-page-above-comments-loggedin": {
"path": "/21784675435/steemit_post-page-above-comments/steemit_post-page-above-comments_loggedin",
"dimensions": [[728, 90], [970, 90]]
},
"post-page-above-comments-mobile": {
"path": "/21784675435/steemit_post-page-above-comments/steemit_post-page-above-comments_mobile",
"dimensions": [[220, 90]]
},
"top-navigation": {
"path": "/21784675435/steemit_top-navi",
"dimensions": [[728, 90], [970, 90]]
},
"top-navigation-loggedin-mobile": {
"path": "/21784675435/steemit_top-navi/steemit_top-navi_loggedin_mobile",
"dimensions": [[220, 90]]
},
"top-navigation-loggedin": {
"path": "/21784675435/steemit_top-navi/steemit_top-navi_loggedin",
"dimensions": [[728, 90], [970, 90]]
},
"top-navigation-mobile": {
"path": "/21784675435/steemit_top-navi/steemit_top-navi_mobile",
"dimensions": [[220, 90]]
},
"left-navigation": {
"path": "/21784675435/steemit_left-navigation/steemit_left-navigation_prebid",
"dimensions": [[120, 600], [160, 600]]
}
},
"gpt_bidding": {
"prebid_timeout": 2000,
"failsafe_timeout": 3000,
"ad_units": [
{
"code": "/21784675435/steemit_top-navi",
"mediaTypes": { "banner": { "sizes": [[728, 90], [220, 90], [970, 90]] } },
"bids": [{
"bidder": "coinzilla",
"params": { "placementId": "6425c7b9886e0045972" }
}]
},
{
"code": "/21784675435/steemit_post-page-above-comments",
"mediaTypes": { "banner": { "sizes": [[728, 90], [220, 90], [970, 90]] } },
"bids": [{
"bidder": "coinzilla",
"params": { "placementId": "6425c7b9886e0045972" }
}]
},
{
"code": "/21784675435/steemit_left-navigation/steemit_left-navigation_prebid",
"mediaTypes": { "banner": { "sizes": [[120, 600], [160, 600]] } },
"bids": [{
"bidder": "coinzilla",
"params": { "placementId": "3575c7b9886e2cb3619" }
}]
}
],
"custom_config": {
"buckets": [
{
"precision": 2,
"min": 0,
"max": 1,
"increment": 0.05
},
{
"precision": 2,
"min": 1,
"max": 8,
"increment": 0.1
}
]
},
"system_currency": {
"adServerCurrency": "USD",
"granularityMultiplier": 1
}
},
"cookie_consent_enabled": null,
"cookie_consent_api_key": null,
"steem_market_endpoint": null,
......
......@@ -36,11 +36,8 @@
@import "./elements/SanitizedLink/styles";
@import "./elements/Dropdown";
@import "./elements/Notices";
@import "./elements/GoogleAd";
@import "./elements/GptAd";
@import "./elements/PostCategoryBanner";
@import "./elements/FlagButton";
@import "./elements/VideoAd";
@import "./elements/VisualEditor";
// modules
......
......@@ -6,9 +6,7 @@ import debounce from 'lodash.debounce';
import { actions as fetchDataSagaActions } from 'app/redux/FetchDataSaga';
import PostSummary from 'app/components/cards/PostSummary';
import LoadingIndicator from 'app/components/elements/LoadingIndicator';
import GptAd from 'app/components/elements/GptAd';
import VideoAd from 'app/components/elements/VideoAd';
// import shouldComponentUpdate from 'app/utils/shouldComponentUpdate';
// import shouldComponentUpdate from 'app/utils/shouldComponentUpdate';
function topPosition(domElt) {
if (!domElt) {
......@@ -21,7 +19,6 @@ class PostsList extends PureComponent {
static propTypes = {
posts: PropTypes.object,
loading: PropTypes.bool,
category: PropTypes.string,
loadMore: PropTypes.func,
nsfwPref: PropTypes.string.isRequired,
};
......@@ -96,7 +93,7 @@ class PostsList extends PureComponent {
render() {
const {
posts, loading, category, order, nsfwPref, hideCategory
posts, loading, order, nsfwPref, hideCategory
} = this.props;
const { thumbSize } = this.state;
......@@ -114,23 +111,6 @@ class PostsList extends PureComponent {
const summary = [];
summary.push(<li key={i}>{ps}</li>);
const every = this.props.adSlots.in_feed_1.every;
if (false && this.props.videoAdsEnabled && i === 4) {
summary.push(
<div key={`id-${i}`}>
<div className="articles__content-block--ad video-ad">
<VideoAd id="bsa-zone_1572296522077-3_123456" />
</div>
</div>
);
} else if (this.props.shouldSeeAds && i >= every && i % every === 0) {
summary.push(
<div key={`ad-${i}`} className="articles__content-block--ad">
<GptAd tags={[category]} type="Freestar" id="bsa-zone_1566495089502-1_123456" />
</div>
);
}
return summary;
});
......@@ -153,9 +133,6 @@ export default connect(
(state, props) => {
const userPreferences = state.app.get('user_preferences').toJS();
const nsfwPref = userPreferences.nsfwPref || 'warn';
const shouldSeeAds = state.app.getIn(['googleAds', 'enabled']);
const videoAdsEnabled = state.app.getIn(['googleAds', 'videoAdsEnabled']);
const adSlots = state.app.getIn(['googleAds', 'adSlots']).toJS();
const current = state.user.get('current');
const username = current ? current.get('username') : state.offchain.get('account');
......@@ -186,9 +163,6 @@ export default connect(
...props, //loading,category,order,hideCategory
posts,
nsfwPref,
shouldSeeAds,
videoAdsEnabled,
adSlots,
};
},
(dispatch) => ({
......
/*global googletag, pbjs*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
class BiddingAd extends Component {
componentDidMount() {
if (!this.ad.path || !this.enabled) return;
googletag.cmd.push(() => {
const slot = googletag.defineSlot(this.ad.path, this.ad.dimensions, this.ad.path);
if (slot) {
slot.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
googletag.cmd.push(() => {
googletag.display(this.ad.path);
this.refreshBid(this.ad.path, slot);
googletag.pubads().addEventListener('impressionViewable', (e) => {
window.dispatchEvent(new Event('gptadshown', e));
});
googletag.pubads().addEventListener('slotRenderEnded', (e) => {
window.dispatchEvent(new Event('gptadshown', e));
});
});
}
});
}
refreshBid(path, slot) {
pbjs.que.push(() => {
pbjs.requestBids({
timeout: 2000,
adUnitCodes: [path],
bidsBackHandler() {
pbjs.setTargetingForGPTAsync([path]);
googletag.pubads().refresh([slot]);
},
});
});
}
constructor(props) {
super(props);
const { ad, enabled, type } = props;
this.ad = {};
this.type = type;
this.enabled = false;
if (ad) {
// console.info(
// `Slot named '${props.slotName}' will render with given data:`,
// ad
// );
this.enabled = enabled;
this.ad = ad.toJS();
} else {
// console.info(
// `Slot named '${
// props.slotName
// }' will be disabled because we were unable to find the ad details.`
// );
}
}
render() {
return <div className="bidding-ad gpt-ad" style={{ width: '100%' }} id={this.ad.path} />;
}
}
BiddingAd.propTypes = {
ad: PropTypes.shape({
path: PropTypes.string,
dimensions: PropTypes.array,
}).isRequired,
enabled: PropTypes.bool.isRequired,
type: PropTypes.oneOf(['Bidding', 'Category', 'Basic']),
};
export default connect(
(state, props) => {
const enabled = !!state.app.getIn(['googleAds', 'gptEnabled']) && !!process.env.BROWSER && !!window.googletag;
const slotName = props.slotName;
const type = props.type;
const slot = state.app.getIn(['googleAds', `gpt${type}Slots`, slotName]);
return {
enabled,
ad: slot,
...props,
};
},
)(BiddingAd);
import React from 'react';
import { connect } from 'react-redux';
class GoogleAd extends React.Component {
componentDidMount() {
if (!this.props.shouldSeeAds) {
return;
}
(window.adsbygoogle = window.adsbygoogle || []).push({});
}
render() {
if (!this.props.shouldSeeAds) {
return null;
}
const style = Object.assign(
{
display: 'inline-block',
width: '100%',
},
this.props.style || {}
);
const className = ['adsbygoogle']
.concat(this.props.env === 'development' ? ['ad-dev'] : [])
.concat(this.props.name ? [this.props.name] : [])
.join(' ');
return (
<ins
className={className}
style={style}
data-adtest={this.props.test}
data-ad-client={this.props.client}
data-ad-slot={this.props.slot}
data-ad-format={this.props.format || 'auto'}
data-ad-layout-key={this.props.layoutKey}
data-full-width-responsive={this.props.fullWidthResponsive}
/>
);
}
}
export default connect((state, ownProps) => {
const env = state.app.get('env');
const shouldSeeAds = state.app.getIn(['googleAds', 'enabled']);
const test = state.app.getIn(['googleAds', 'test']);
const client = state.app.getIn(['googleAds', 'client']);
return { env, shouldSeeAds, test, client, ...ownProps };
})(GoogleAd);
.adsbygoogle.ad-dev {
background-color: #ddd;
min-height: 64px;
}
.c-sidebar .sidebar-ad {
text-align: center;
}
.articles__content-block--ad {
text-align: center;
margin-top: 1em;
margin-bottom: 2.5em;
}
.Post_footer__ad {
max-width: 50rem;
margin-right: auto;
margin-left: auto;
margin-bottom: 1.5rem;
margin-top: 1.5rem;
}
/*global googletag*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
class GptAd extends Component {
constructor(props) {
super(props);
const {
ad_identifier, enabled, type, tags, bannedTags
} = props;
this.ad_identifier = '';
this.type = type;
this.enabled = false;
this.tags = tags;
this.bannedTags = bannedTags;
if (ad_identifier != '') {
// console.info(
// `ad_identifier of '${ad_identifier}' will render.`,
// ad_identifier
// );
this.enabled = enabled;
this.ad_identifier = ad_identifier;
} else {
// console.info(
// `Slot named '${
// props.slotName
// }' will be disabled because we were unable to find the ad details.`
// );
}
this.unique_slot_id = `${this.ad_identifier}_${Date.now()}`;
}
componentDidMount() {
if (!this.ad_identifier || !this.enabled) return;
const unique_slot_id = this.unique_slot_id;
window.optimize.queue.push(() => {
window.optimize.push(unique_slot_id);
googletag.pubads().addEventListener('impressionViewable', (e) => {
window.dispatchEvent(new Event('gptadshown', e));
});
googletag.pubads().addEventListener('slotRenderEnded', (e) => {
window.dispatchEvent(new Event('gptadshown', e));
});
});
}
render() {
if (!this.ad_identifier || !this.enabled) {
return <div id="disabled_ad" style={{ display: 'none' }} />;
}
return <div className="gpt-ad" style={{ width: '100%' }} id={this.unique_slot_id} />;
}
}
GptAd.propTypes = {
ad_identifier: PropTypes.string.isRequired,
enabled: PropTypes.bool.isRequired,
type: PropTypes.oneOf(['Bidding', 'Category', 'Basic', 'Freestar']),
tags: PropTypes.arrayOf(PropTypes.string),
bannedTags: PropTypes.arrayOf(PropTypes.string),
};
GptAd.defaultProps = {
type: 'Freestar',
tags: [],
bannedTags: [],
};
export default connect(
(state, props) => {
const enabled = !!state.app.getIn(['googleAds', 'gptEnabled']) && !!process.env.BROWSER;
const bannedTags = state.app.getIn(['googleAds', 'gptBannedTags']);
const bannedTagsJS = bannedTags ? bannedTags.toJS() : [];
let slotName = props.slotName;
if (!slotName) {
slotName = props.id;
}
const type = props.type;
let slot = slotName; // in case it's Freestar
if (type != 'Freestar') {
slot = state.app.getIn(['googleAds', `gpt${type}Slots`, slotName]);
}
return {
enabled,
ad: slot, //TODO: Clean this up. This is from old GPT/Coinzilla stuffs
ad_identifier: slotName,
bannedTagsJS,
...props,
};
},
)(GptAd);
import React, { Component } from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
class VideoAd extends Component {
constructor(props) {
super(props);
const { ad_identifier, enabled } = props;
this.ad_identifier = '';
this.enabled = false;
if (ad_identifier != '') {
this.enabled = enabled;
this.ad_identifier = ad_identifier;
}
}
render() {
if (!this.ad_identifier || !this.enabled) {
return <div id="disabled_video_ad" style={{ display: 'none' }} />;
}
return <div id={this.ad_identifier} />;
}
}
VideoAd.propTypes = {
ad_identifier: PropTypes.string.isRequired,