Commit d1a92df1 authored by Roger Jungemann's avatar Roger Jungemann
Browse files

Remove ad and notices code

parent f77628cf
......@@ -70,10 +70,5 @@
"chain_id": "SDC_CHAIN_ID",
"address_prefix": "SDC_ADDRESS_PREFIX",
"conveyor_posting_wif": "CONVEYOR_POSTING_WIF",
"conveyor_username": "CONVEYOR_USERNAME",
"pinned_posts_url": "PINNED_POSTS_URL",
"google_ad_enabled": "GOOGLE_AD_ENABLED",
"google_ad_test": "GOOGLE_AD_TEST",
"google_ad_client": "GOOGLE_AD_CLIENT",
"gpt_enabled": "GPT_ENABLED"
"conveyor_username": "CONVEYOR_USERNAME"
}
......@@ -75,32 +75,5 @@
"chain_id": "0000000000000000000000000000000000000000000000000000000000000000",
"address_prefix": "STM",
"conveyor_posting_wif": false,
"conveyor_username": false,
"pinned_posts_url": false,
"google_ad_enabled": null,
"google_ad_test": null,
"google_ad_client": null,
"google_ad_slots": {
"sidebar_1": {
"slot_id": "9855000063"
},
"in_feed_1": {
"slot_id": "9514544128",
"layout_key": "-fb+5w+4e-db+86",
"every": 8
},
"post_footer_1": {
"slot_id": "5796459261"
},
"market_1": {
"slot_id": "2777377820"
}
},
"gpt_enabled": null,
"gpt_slots": {
"top_navi": {
"slot_id": "div-gpt-ad-1547492443353-0",
"args": ["/21784675435/steemit_top-navi", [[728, 90], [970, 90]], "div-gpt-ad-1547492443353-0"]
}
}
"conveyor_username": false
}
......@@ -39,15 +39,8 @@ class App extends React.Component {
this.state = {
showCallout: true,
showBanner: true,
gptBannerHeight: 0,
};
this.listenerActive = null;
this.gptadshownListener = this.gptadshown.bind(this);
}
gptadshown(e) {
const height = document.querySelector('header .gpt-ad').offsetHeight;
this.setState({ gptBannerHeight: height });
}
componentWillMount() {
......@@ -56,17 +49,11 @@ class App extends React.Component {
}
componentDidMount() {
window.addEventListener('gptadshown', this.gptadshownListener);
if (pageRequiresEntropy(this.props.pathname)) {
this._addEntropyCollector();
}
}
componentWillUnmount() {
window.removeEventListener('gptadshown', this.gptadshownListener);
}
componentWillReceiveProps(np) {
// Add listener if the next page requires entropy and the current page didn't
if (
......@@ -114,7 +101,6 @@ class App extends React.Component {
new_visitor !== n.new_visitor ||
this.state.showBanner !== nextState.showBanner ||
this.state.showCallout !== nextState.showCallout ||
this.state.gptBannerHeight !== nextState.gptBannerHeight ||
nightmodeEnabled !== n.nightmodeEnabled ||
showAnnouncement !== n.showAnnouncement
);
......@@ -255,10 +241,7 @@ class App extends React.Component {
/>
)}
<div
className="App__content"
style={{ paddingTop: `${this.state.gptBannerHeight}px` }}
>
<div className="App__content">
{process.env.BROWSER &&
ip &&
new_visitor &&
......
......@@ -34,9 +34,6 @@
@import "./elements/SanitizedLink/styles";
@import "./elements/HelpTip/styles";
@import "./elements/Dropdown";
@import "./elements/Notices";
@import "./elements/GoogleAd";
@import "./elements/GptAd";
// modules
@import "./modules/Header/styles";
......
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', 'shouldSeeAds']);
const test = state.app.getIn(['googleAds', 'test']);
const client = state.app.getIn(['googleAds', 'client']);
return { env, shouldSeeAds, test, client, ...ownProps };
})(GoogleAd);
import React from 'react';
import { connect } from 'react-redux';
class GptAd extends React.Component {
componentDidMount() {
if (!this.props.gptEnabled) {
return;
}
googletag.cmd.push(() => {
const slot = googletag.defineSlot.apply(googletag, this.props.args);
slot.addService(googletag.pubads());
googletag.cmd.push(() => {
googletag.display(this.props.slot);
googletag.pubads().refresh([slot]);
googletag
.pubads()
.addEventListener('slotRenderEnded', function(event) {
console.log('Slot has been rendered:', event);
window.dispatchEvent(new Event('gptadshown'));
});
});
});
}
render() {
if (!this.props.gptEnabled) {
return null;
}
return (
<div
className="gpt-ad"
style={{ width: '100%' }}
id={this.props.slot}
/>
);
}
}
export default connect((state, ownProps) => {
const env = state.app.get('env');
const gptEnabled = state.app.getIn(['googleAds', 'gptEnabled']);
return { env, gptEnabled, ...ownProps };
})(GptAd);
import React from 'react';
import tt from 'counterpart';
import { Link } from 'react-router';
import TimeAgoWrapper from 'app/components/elements/TimeAgoWrapper';
const Notice = ({ notice }) => {
if (!notice || !notice.title) {
return null;
}
const url = notice.permalink
? `/@${notice.author}/${notice.permlink}`
: notice.url;
const tag = notice.tag ? (
<p className="Notices__featured">{notice.tag}</p>
) : null;
const title = url ? (
<Link className="Notices__title-link" to={url}>
{notice.title}
</Link>
) : (
notice.title
);
const by = notice.author ? (
<span className="Notices__by"> {tt('g.by')}&nbsp;</span>
) : null;
const author = notice.author ? (
<Link className="Notices__author-link" to={'/@' + notice.author}>
{notice.author}
</Link>
) : null;
const date = notice.created ? (
<span>
{' . '}
<TimeAgoWrapper date={notice.created} />
</span>
) : null;
return (
<li className="Notices__notice">
{tag}
<p className="Notices__title">{title}</p>
<p className="Notices__metadata">
{by}
{author}
{date}
</p>
</li>
);
};
const SteemitNotices = ({ notices }) => {
if (!notices || notices.length === 0) {
return null;
}
return (
<div className="c-sidebar__module">
<div className="c-sidebar__header">
<h3 className="c-sidebar__h3">Updates Log</h3>
</div>
<div className="c-sidebar__content">
<ul className="Notices">
{notices.map(notice => (
<Notice key={notice.title} notice={notice} />
))}
</ul>
</div>
</div>
);
};
export default SteemitNotices;
.Notices {
margin: 0;
padding: 0;
&__notice {
list-style: none;
margin-bottom: 0rem;
line-height: 1.1;
}
&__featured {
background: $color-orange;
padding: 3px 4px;
text-transform: uppercase;
color: white;
line-height: 1;
display: inline-block;
margin: 0;
border-radius: 4px;
letter-spacing: 1px;
letter-spacing: 0.4px;
font-weight: bold;
@include font-size(11px);
margin-right: 6px;
}
&__featured + &__title {
line-height: 1.4;
}
&__featured + &__title + &__metadata {
margin-top: 1px;
}
&__title {
margin: 0;
@include font-size(14px);
line-height: 1.3;
display: inline;
}
&__metadata {
@include font-size(12px);
margin-top: 4px;
line-height: 1.4;
@include themify($themes) {
color: themed('textColorSecondary');
}
}
&__author-link {
@extend .link;
@extend .link--secondary;
}
&__title-link {
@extend .link;
@extend .link--primary;
}
&__by {
text-transform: capitalize;
}
}
\ No newline at end of file
......@@ -16,7 +16,6 @@ import { SIGNUP_URL } from 'shared/constants';
import SteemLogo from 'app/components/elements/SteemLogo';
import normalizeProfile from 'app/utils/NormalizeProfile';
import Announcement from 'app/components/elements/Announcement';
import GptAd from 'app/components/elements/GptAd';
class Header extends React.Component {
static propTypes = {
......@@ -25,7 +24,6 @@ class Header extends React.Component {
category: PropTypes.string,
order: PropTypes.string,
pathname: PropTypes.string,
gptSlots: PropTypes.object,
};
constructor() {
......@@ -204,12 +202,6 @@ class Header extends React.Component {
{this.props.showAnnouncement && (
<Announcement onClose={this.props.hideAnnouncement} />
)}
{this.props.gptSlots ? (
<GptAd
slot={this.props.gptSlots['top_navi']['slot_id']}
args={this.props.gptSlots['top_navi']['args']}
/>
) : null}
<nav className="row Header__nav">
<div className="small-5 large-6 columns Header__logotype">
{/*LOGO*/}
......@@ -308,8 +300,6 @@ const mapStateToProps = (state, ownProps) => {
? username
: state.offchain.get('account');
const gptSlots = state.app.getIn(['googleAds', 'gptSlots']).toJS();
return {
username,
loggedIn,
......@@ -318,7 +308,6 @@ const mapStateToProps = (state, ownProps) => {
account_meta: user_profile,
current_account_name,
showAnnouncement: state.user.get('showAnnouncement'),
gptSlots,
...ownProps,
};
};
......
......@@ -457,7 +457,6 @@ export default connect(
const loginBroadcastOperation = state.user.get(
'loginBroadcastOperation'
);
const shouldSeeAds = state.app.getIn(['googleAds', 'shouldSeeAds']);
const initialValues = {
saveLogin: saveLoginDefault,
};
......@@ -486,7 +485,6 @@ export default connect(
return {
login_error,
loginBroadcastOperation,
shouldSeeAds,
initialValues,
initialUsername,
msg,
......
......@@ -13,7 +13,6 @@ import TransactionError from 'app/components/elements/TransactionError';
import DepthChart from 'app/components/elements/DepthChart';
import Orderbook from 'app/components/elements/Orderbook';
import OrderHistory from 'app/components/elements/OrderHistory';
import GoogleAd from 'app/components/elements/GoogleAd';
import { Order, TradeHistory } from 'app/utils/MarketClasses';
import { roundUp, roundDown } from 'app/utils/MarketUtils';
import tt from 'counterpart';
......@@ -926,17 +925,6 @@ class Market extends React.Component {
<h4>{tt('market_jsx.trade_history')}</h4>
{trade_history_table(this.props.history)}
</div>
{this.props.shouldSeeAds && (
<div className="small-12 large-12 column">
<GoogleAd
name="market-1"
slot={this.props.adSlots['market_1'].slot_id}
fullWidthResponsive="true"
style={{ display: 'block' }}
/>
</div>
)}
</div>
{account && (
......@@ -959,8 +947,6 @@ module.exports = {
const username = state.user.get('current')
? state.user.get('current').get('username')
: null;
const shouldSeeAds = state.app.getIn(['googleAds', 'shouldSeeAds']);
const adSlots = state.app.getIn(['googleAds', 'adSlots']).toJS();
return {
orderbook: state.market.get('orderbook'),
open_orders: process.env.BROWSER
......@@ -972,8 +958,6 @@ module.exports = {
user: username,
feed: state.global.get('feed_price'),
open_orders_sort: state.market.get('open_orders_sort'),
shouldSeeAds,
adSlots,
};
},
dispatch => ({
......
......@@ -396,21 +396,6 @@ function* usernamePasswordLogin2({
console.log('Logging in as', username);
const response = yield serverApiLogin(username, signatures);
const body = yield response.json();
if (justLoggedIn) {
// If ads are enabled, reload the page instead of changing the browser
// history when they log in, so headers will get re-requested.
const adsEnabled = yield select(state =>
state.app.getIn(['googleAds', 'enabled'])
);
if (adsEnabled) {
var url = new URL(window.location.href);
url.searchParams.set('auth', 'true');
console.log('New post-login URL', url.toString());
window.location.replace(url.toString());
return;
}
}
}
} catch (error) {
// Does not need to be fatal
......@@ -530,15 +515,6 @@ function* logout(action) {
}
yield serverApiLogout();
// If ads are enabled, reload the page instead of changing the browser
// history when they log out, so headers will get re-requested.
const adsEnabled = yield select(state =>
state.app.getIn(['googleAds', 'enabled'])
);
if (logoutType == 'default' && adsEnabled) {
window.location.reload();
}
}
function* loginError({
......
......@@ -64,21 +64,10 @@ async function appRender(ctx, locales = false, resolvedAssets = false) {
offchain.recover_account = account_recovery_record.account_name;
}
}
const googleAds = {
shouldSeeAds: !!ctx.adsEnabled,
enabled: !!config.google_ad_enabled,
test: !!config.google_ad_test,
client: config.google_ad_client,
adSlots: config.google_ad_slots,
gptEnabled: !!ctx.gptEnabled,
gptSlots: config.gpt_slots,
};
// ... and that's the end of user-session-related SSR
const initial_state = {
app: {
viewMode: determineViewMode(ctx.request.search),
googleAds: googleAds,
env: process.env.NODE_ENV,
},
};
......@@ -103,17 +92,11 @@ async function appRender(ctx, locales = false, resolvedAssets = false) {
} else {
assets = resolvedAssets;
}
const shouldSeeAds = googleAds.shouldSeeAds;
const gptEnabled = googleAds.gptEnabled;
const gptSlots = googleAds.gptSlots;
const props = {
body,
assets,
title,
meta,
shouldSeeAds,
gptEnabled,
gptSlots,
};
ctx.status = statusCode;
ctx.body =
......
import * as config from 'config';
import React from 'react';
export default function ServerHTML({
body,
assets,
locale,
title,
meta,
shouldSeeAds,
gptEnabled,
gptSlots,
}) {
export default function ServerHTML({ body, assets, locale, title, meta }) {
let page_title = title;
return (
<html lang="en">
......@@ -172,51 +163,6 @@ export default function ServerHTML({
type="text/css"
/>
))}
{gptEnabled ? (
<script
async
src="https://www.googletagservices.com/tag/js/gpt.js"
/>
) : null}
{gptEnabled ? (
<script
dangerouslySetInnerHTML={{
__html: `
window.googletag = window.googletag || {};
googletag.cmd = googletag.cmd || [];
console.log('Set up googletag');
googletag.cmd.push(function() {
console.log('Preparing to enable googletag services');
googletag.pubads().enableSingleRequest();
googletag.pubads().setTargeting('edition',['new-york']);
googletag.pubads().collapseEmptyDivs(true,true);
googletag.pubads().disableInitialLoad();
googletag.pubads().enableAsyncRendering();
googletag.enableServices();
console.log('Enabled googletag services');
});
`,
}}
/>
) : null}
{shouldSeeAds ? (
<script
async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"
/>
) : null}
{shouldSeeAds ? (
<script
dangerouslySetInnerHTML={{
__html: `
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-9368037717385698",
enable_page_level_ads: true
});
`,
}}
/>
) : null}
<title>{page_title}</title>
</head>
<body>
......
......@@ -118,25 +118,6 @@ session(app, {
});
csrf(app);
// If a user is logged in, we need to make sure that they receive the correct