diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json index e6e16276ff4217b0f29526a9c21b644eebe5aa67..f4ee1259318b5481d5e50b37bf994195c5e4eb68 100644 --- a/config/custom-environment-variables.json +++ b/config/custom-environment-variables.json @@ -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", diff --git a/config/default.json b/config/default.json index 7677a3f8ec7054d1ed4da716eb1cb942314245a6..35c7ef2fe0c0e56c1de93e0be7beffc9ae218ad4 100644 --- a/config/default.json +++ b/config/default.json @@ -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, diff --git a/src/app/assets/stylesheets/markdown.scss b/src/app/assets/stylesheets/markdown.scss index 74b1aa5355dc834546f2ea629c00f8afbd0867ac..d38ed5c9a3d19dd2d299a270e4fb67ed23df5e76 100644 --- a/src/app/assets/stylesheets/markdown.scss +++ b/src/app/assets/stylesheets/markdown.scss @@ -102,6 +102,7 @@ max-width: 100%; height: auto; max-height: none; + margin-bottom: 10px; } iframe { diff --git a/src/app/components/all.scss b/src/app/components/all.scss index 31869d397eae542931500bb12bd535cfdebc3014..c01ccd776142cae5bdcb3317e553e6be6310ad31 100644 --- a/src/app/components/all.scss +++ b/src/app/components/all.scss @@ -37,11 +37,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 diff --git a/src/app/components/cards/NotFoundMessage.jsx b/src/app/components/cards/NotFoundMessage.jsx index fbac213eceb9b1c59195ad6d9b6e2636963511a0..eb061576265b8e50510ac7f2a21047b308185f66 100644 --- a/src/app/components/cards/NotFoundMessage.jsx +++ b/src/app/components/cards/NotFoundMessage.jsx @@ -7,7 +7,7 @@ export default class NotFoundMessage extends React.Component { <div className="NotFound float-center"> <div> <Icon name="hive" size="4x" /> - <h4 className="NotFound__header">Sorry! This page doesn&aquote;t exist.</h4> + <h4 className="NotFound__header">Sorry! This page does not exist.</h4> <p> Not to worry. You can head back to {' '} diff --git a/src/app/components/cards/NotificationsList.jsx b/src/app/components/cards/NotificationsList.jsx index c6fe9d67fb93dff0b16d88b53bb970b1b362a3b2..4b7fce52ea026ee036240b7afa0e790233fe434a 100644 --- a/src/app/components/cards/NotificationsList.jsx +++ b/src/app/components/cards/NotificationsList.jsx @@ -316,7 +316,7 @@ class NotificationsList extends React.Component { <div style={{ lineHeight: '1rem' }}>{notifications.map((item) => renderItem(item))}</div> )} {!notifications && !notificationActionPending && process.env.BROWSER && ( - <Callout>Welcome! You don&aquote;t have any notifications yet.</Callout> + <Callout>Welcome! You do not have any notifications yet.</Callout> )} {!notificationActionPending && notifications && !isLastPage && ( diff --git a/src/app/components/cards/PostSummary.jsx b/src/app/components/cards/PostSummary.jsx index d6cf90596c5b7ce610f5d73571a13ba05dfb6477..fa24809ea56737986197c04e2c7083befdd9184e 100644 --- a/src/app/components/cards/PostSummary.jsx +++ b/src/app/components/cards/PostSummary.jsx @@ -70,7 +70,7 @@ class PostSummary extends React.Component { } const { - ignore, hideCategory, net_vests, sessionId, + ignore, hideCategory, net_vests, } = this.props; const { post } = this.props; if (!post) return null; @@ -294,7 +294,7 @@ class PostSummary extends React.Component { } if (!image_link && !isReply) { - image_link = `https://images.hive.blog/u/${author}/avatar${sessionId ? `?ord=${sessionId}` : ''}`; + image_link = `https://images.hive.blog/u/${author}/avatar`; } let thumb = null; @@ -357,7 +357,6 @@ class PostSummary extends React.Component { export default connect((state, props) => { const { post, hideCategory, nsfwPref } = props; const net_vests = state.user.getIn(['current', 'effective_vests'], 0.0); - const sessionId = state.user.get('sessionId'); return { post, @@ -366,6 +365,5 @@ export default connect((state, props) => { blogmode: state.app.getIn(['user_preferences', 'blogmode']), nsfwPref, net_vests, - sessionId, }; })(PostSummary); diff --git a/src/app/components/cards/PostsList.jsx b/src/app/components/cards/PostsList.jsx index 6f4a3b0a6bbb882646aa4101aed068c22d1dc649..e92f2bdc2c855dae186cc062f30805a667fb3278 100644 --- a/src/app/components/cards/PostsList.jsx +++ b/src/app/components/cards/PostsList.jsx @@ -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) => ({ diff --git a/src/app/components/cards/SubscriptionsList.jsx b/src/app/components/cards/SubscriptionsList.jsx index ec27b74647e2b4832e9b7cbc33c874b7c322204a..61e592fd4d0d05e5402c96d32824dd3e6b79e8b9 100644 --- a/src/app/components/cards/SubscriptionsList.jsx +++ b/src/app/components/cards/SubscriptionsList.jsx @@ -29,7 +29,7 @@ class SubscriptionsList extends React.Component { render() { const { - subscriptions, loading, badges, username, sessionId, + subscriptions, loading, badges, username, } = this.props; const badgesTypes = { activity: [], @@ -76,7 +76,7 @@ class SubscriptionsList extends React.Component { rel="noopener noreferrer" > <img - src={`${badge.get('url')}${sessionId ? `?ord=${sessionId}` : ''}`} + src={`${badge.get('url')}`} alt={badge.get('title')} title={badge.get('title')} className="UserProfile__badge_image" @@ -176,14 +176,12 @@ export default connect( const isOwnAccount = user.getIn(['current', 'username'], '') === username; const loading = global.getIn(['subscriptions', 'loading']); const subscriptions = global.getIn(['subscriptions', username]); - const sessionId = state.user.get('sessionId'); return { ...props, subscriptions: subscriptions ? subscriptions.toJS() : [], isOwnAccount, loading, - sessionId, }; }, (dispatch) => ({ diff --git a/src/app/components/elements/BiddingAd.jsx b/src/app/components/elements/BiddingAd.jsx deleted file mode 100644 index 08581fb7a88f8081377f97be2ee681554ef23951..0000000000000000000000000000000000000000 --- a/src/app/components/elements/BiddingAd.jsx +++ /dev/null @@ -1,99 +0,0 @@ -/*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); diff --git a/src/app/components/elements/GoogleAd.jsx b/src/app/components/elements/GoogleAd.jsx deleted file mode 100644 index b81b62b5c4ddb9df81e90f2d360cd09b23810395..0000000000000000000000000000000000000000 --- a/src/app/components/elements/GoogleAd.jsx +++ /dev/null @@ -1,52 +0,0 @@ -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); diff --git a/src/app/components/elements/GoogleAd.scss b/src/app/components/elements/GoogleAd.scss deleted file mode 100644 index e08c571c68ef547c8a726e8d198d8c0857ea18cf..0000000000000000000000000000000000000000 --- a/src/app/components/elements/GoogleAd.scss +++ /dev/null @@ -1,22 +0,0 @@ -.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; -} diff --git a/src/app/components/elements/GptAd.jsx b/src/app/components/elements/GptAd.jsx deleted file mode 100644 index 341e832582e1b92cdd3e0a66420d87863b998302..0000000000000000000000000000000000000000 --- a/src/app/components/elements/GptAd.jsx +++ /dev/null @@ -1,100 +0,0 @@ -/*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); diff --git a/src/app/components/elements/GptAd.scss b/src/app/components/elements/GptAd.scss deleted file mode 100644 index 03ee82596607abf793fda290eef77819c3acb649..0000000000000000000000000000000000000000 --- a/src/app/components/elements/GptAd.scss +++ /dev/null @@ -1,3 +0,0 @@ -.gpt-ad { - text-align: center; -} diff --git a/src/app/components/elements/Userpic.jsx b/src/app/components/elements/Userpic.jsx index 90bca6e46b891ecfddf3cdae34af1690bf355994..1b8b7dfcd91be30877de28c10dd2df12aa08d4e0 100644 --- a/src/app/components/elements/Userpic.jsx +++ b/src/app/components/elements/Userpic.jsx @@ -13,9 +13,9 @@ class Userpic extends Component { render() { if (this.props.hide) return null; - const { account, size, sessionId } = this.props; + const { account, size } = this.props; - const url = `${imageProxy()}u/${account}/avatar${size}${sessionId ? `?ord=${sessionId}` : ''}`; + const url = `${imageProxy()}u/${account}/avatar${size}`; const style = { backgroundImage: `url(${url})` }; return <div className="Userpic" style={style} />; } @@ -34,12 +34,9 @@ export default connect((state, ownProps) => { hide = !url || !/^(https?:)\/\//.test(url); } - const sessionId = state.user.get('sessionId'); - return { account: account === 'steemitblog' ? 'steemitdev' : account, size: size && sizeList.indexOf(size) > -1 ? '/' + size : '', hide, - sessionId, }; })(Userpic); diff --git a/src/app/components/elements/VideoAd.jsx b/src/app/components/elements/VideoAd.jsx deleted file mode 100644 index 2d751118fa1ed24fb9b978348ae5df74e707a750..0000000000000000000000000000000000000000 --- a/src/app/components/elements/VideoAd.jsx +++ /dev/null @@ -1,45 +0,0 @@ -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, - enabled: PropTypes.bool.isRequired, -}; - -VideoAd.defaultProps = {}; - -export default connect( - (state, props) => { - const enabled = !!state.app.getIn(['googleAds', 'videoAdsEnabled']) && !!process.env.BROWSER; - - return { - enabled, - ad_identifier: props.id, - ...props, - }; - }, -)(VideoAd); diff --git a/src/app/components/elements/VideoAd.scss b/src/app/components/elements/VideoAd.scss deleted file mode 100644 index 58b054b8d6be7ad2dee85195681e28246782f9f0..0000000000000000000000000000000000000000 --- a/src/app/components/elements/VideoAd.scss +++ /dev/null @@ -1,3 +0,0 @@ -.video-ad { - div {margin: 0 auto;} -} diff --git a/src/app/components/modules/Header/index.jsx b/src/app/components/modules/Header/index.jsx index 45837a7104a237101402889365a9aade3b70688a..afed304b0b20df11993f48b8095fa1a94d1aa3a1 100644 --- a/src/app/components/modules/Header/index.jsx +++ b/src/app/components/modules/Header/index.jsx @@ -3,7 +3,6 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Link, browserHistory } from 'react-router'; import { connect } from 'react-redux'; -import { parseJsonTags } from 'app/utils/StateFunctions'; import Headroom from 'react-headroom'; import resolveRoute from 'app/ResolveRoute'; import tt from 'counterpart'; @@ -20,9 +19,7 @@ import UserpicInfoWrapper from 'app/components/elements/UserpicInfoWrapper'; import { SIGNUP_URL } from 'shared/constants'; import SteemLogo from 'app/components/elements/SteemLogo'; import Announcement from 'app/components/elements/Announcement'; -import GptAd from 'app/components/elements/GptAd'; import { Map } from 'immutable'; -import ReactMutationObserver from '../../utils/ReactMutationObserver'; class Header extends React.Component { static propTypes = { @@ -40,9 +37,6 @@ class Header extends React.Component { super(props); this.state = { - // eslint-disable-next-line react/no-unused-state - gptAdRendered: false, - showAd: false, showAnnouncement: this.props.showAnnouncement, }; } @@ -54,20 +48,6 @@ class Header extends React.Component { } } - componentDidMount() { - if (!this.props.gptEnabled || !process.env.BROWSER || !window.googletag || !window.googletag.pubads) { - return null; - } - - window.addEventListener('gptadshown', (e) => this.gptAdRendered(e)); - } - - componentWillUnmount() { - if (!this.props.gptEnabled || !process.env.BROWSER || !window.googletag || !window.googletag.pubads) { - return null; - } - } - // Consider refactor. // I think 'last sort order' is something available through react-router-redux history. // Therefore no need to store it in the window global like this. @@ -84,18 +64,6 @@ class Header extends React.Component { } } - headroomOnUnpin() { - this.setState({ showAd: false }); - } - - headroomOnUnfix() { - this.setState({ showAd: true }); - } - - gptAdRendered() { - this.setState({ showAd: true, gptAdRendered: true }); - } - hideAnnouncement() { this.setState({ showAnnouncement: false }); this.props.hideAnnouncement(); @@ -113,7 +81,7 @@ class Header extends React.Component { showSidePanel, navigate, display_name, - content, + // content, walletUrl, unreadNotificationCount, notificationActionPending, @@ -123,7 +91,6 @@ class Header extends React.Component { /*Set the document.title on each header render.*/ const route = resolveRoute(pathname); - let gptTags = []; let page_title = route.page; let sort_order = ''; let topic = ''; @@ -133,7 +100,6 @@ class Header extends React.Component { page_title = 'My Friends'; //tt('header_jsx.home'); } else { topic = route.params.length > 1 ? route.params[1] || '' : ''; - gptTags = [topic]; let prefix = route.params[0]; if (prefix == 'created') prefix = 'New'; @@ -150,14 +116,7 @@ class Header extends React.Component { } } } else if (route.page === 'Post') { - if (content) { - const user = `${route.params[1]}`.replace('@', ''); - const slug = `${route.params[2]}`; - const post = content.get(`${user}/${slug}`); - gptTags = post ? parseJsonTags(post) : []; - } - sort_order = ''; - topic = route.params[0]; + // @TODO check what this should be } else if (route.page == 'SubmitPost') { page_title = tt('header_jsx.create_a_post'); } else if (route.page == 'Privacy') { @@ -261,122 +220,107 @@ class Header extends React.Component { value: tt('g.logout'), }, ]; - const showAd = false; // TODO: fix header ad overlap bug - const headerMutated = (mutation, discconnectObserver) => { - if (mutation.target.id.indexOf('google_ads_iframe_') !== -1) { - this.gptAdRendered(); - if (typeof discconnectObserver === 'function') { - discconnectObserver(); - } - } - }; return ( - <ReactMutationObserver onChildListChanged={headerMutated}> - <Headroom - onUnpin={(e) => this.headroomOnUnpin(e)} - onUnfix={(e) => this.headroomOnUnfix(e)} - > - <header className="Header"> - {showAnnouncement && ( - <Announcement - onClose={(e) => this.hideAnnouncement(e)} - /> - )} - {/*<div className="beta-disclaimer"> + <Headroom + onUnpin={(e) => this.headroomOnUnpin(e)} + onUnfix={(e) => this.headroomOnUnfix(e)} + > + <header className="Header"> + {showAnnouncement && ( + <Announcement + onClose={(e) => this.hideAnnouncement(e)} + /> + )} + {/*<div className="beta-disclaimer"> Viewing <strong>Hive.blog beta</strong>. Note that availability of features or service may change at any time. </div>*/} - {/* If announcement is shown, ad will not render unless it's in a parent div! */} - <div style={showAd ? {} : { display: 'none' }}> - <GptAd tags={gptTags} type="Freestar" id="bsa-zone_1566493796250-1_123456" /> + + <nav className="row Header__nav"> + <div className="small-6 medium-4 large-3 columns Header__logotype"> + <Link to={logo_link}> + <SteemLogo nightmodeEnabled={nightmodeEnabled} /> + </Link> </div> - <nav className="row Header__nav"> - <div className="small-6 medium-4 large-3 columns Header__logotype"> - <Link to={logo_link}> - <SteemLogo nightmodeEnabled={nightmodeEnabled} /> - </Link> - </div> - - <div className="large-5 columns show-for-large large-centered Header__sort"> - <ul className="nav__block-list"> - <li className="nav__block-list-item"> - <Link to="/">Posts</Link> - </li> - <li className="nav__block-list-item"> - <Link to={`${walletUrl}/proposals`} target="_blank" rel="noopener noreferrer"> - Proposals - </Link> - </li> - <li className="nav__block-list-item"> - <Link to={`${walletUrl}/~witnesses`} target="_blank" rel="noopener noreferrer"> - Witnesses - </Link> - </li> - <li className="nav__block-list-item"> - <Link to="https://hive.io/eco/" target="_blank" rel="noopener noreferrer"> - Our dApps - </Link> - </li> - </ul> - </div> - - <div className="small-6 medium-8 large-4 columns Header__buttons"> - {/*NOT LOGGED IN SIGN IN AND SIGN UP LINKS*/} - {!loggedIn && ( - <span className="Header__user-signup show-for-medium"> - <a className="Header__login-link" href="/login.html" onClick={showLogin}> - {tt('g.login')} - </a> - <a className="Header__signup-link" href={SIGNUP_URL}> - {tt('g.sign_up')} - </a> - </span> - )} - - {/*CUSTOM SEARCH*/} - <span className="Header__search--desktop"> - <ElasticSearchInput redirect /> - </span> - <span className="Header__search"> - <a href="/search"> - <IconButton icon="magnifyingGlass" /> - </a> - </span> + <div className="large-5 columns show-for-large large-centered Header__sort"> + <ul className="nav__block-list"> + <li className="nav__block-list-item"> + <Link to="/">Posts</Link> + </li> + <li className="nav__block-list-item"> + <Link to={`${walletUrl}/proposals`} target="_blank" rel="noopener noreferrer"> + Proposals + </Link> + </li> + <li className="nav__block-list-item"> + <Link to={`${walletUrl}/~witnesses`} target="_blank" rel="noopener noreferrer"> + Witnesses + </Link> + </li> + <li className="nav__block-list-item"> + <Link to="https://hive.io/eco/" target="_blank" rel="noopener noreferrer"> + Our dApps + </Link> + </li> + </ul> + </div> - {/*SUBMIT STORY*/} - {submit_story} - {/*USER AVATAR */} - {loggedIn && ( - <DropdownMenu - className="Header__usermenu" - items={user_menu} - title={username} - el="span" - position="left" - > - <li className="Header__userpic "> - <UserpicInfoWrapper> - <Userpic account={username} /> - </UserpicInfoWrapper> - </li> - {!notificationActionPending && unreadNotificationCount > 0 && ( - <div className="Header__notification"> - <span>{unreadNotificationCount}</span> - </div> - )} - </DropdownMenu> - )} - {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */} - <span onClick={showSidePanel} className="toggle-menu Header__hamburger"> - <span className="hamburger" /> + <div className="small-6 medium-8 large-4 columns Header__buttons"> + {/*NOT LOGGED IN SIGN IN AND SIGN UP LINKS*/} + {!loggedIn && ( + <span className="Header__user-signup show-for-medium"> + <a className="Header__login-link" href="/login.html" onClick={showLogin}> + {tt('g.login')} + </a> + <a className="Header__signup-link" href={SIGNUP_URL}> + {tt('g.sign_up')} + </a> </span> - </div> - </nav> - </header> - </Headroom> - </ReactMutationObserver> + )} + + {/*CUSTOM SEARCH*/} + <span className="Header__search--desktop"> + <ElasticSearchInput redirect /> + </span> + <span className="Header__search"> + <a href="/search"> + <IconButton icon="magnifyingGlass" /> + </a> + </span> + + {/*SUBMIT STORY*/} + {submit_story} + {/*USER AVATAR */} + {loggedIn && ( + <DropdownMenu + className="Header__usermenu" + items={user_menu} + title={username} + el="span" + position="left" + > + <li className="Header__userpic "> + <UserpicInfoWrapper> + <Userpic account={username} /> + </UserpicInfoWrapper> + </li> + {!notificationActionPending && unreadNotificationCount > 0 && ( + <div className="Header__notification"> + <span>{unreadNotificationCount}</span> + </div> + )} + </DropdownMenu> + )} + {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */} + <span onClick={showSidePanel} className="toggle-menu Header__hamburger"> + <span className="hamburger" /> + </span> + </div> + </nav> + </header> + </Headroom> ); } } @@ -407,7 +351,6 @@ const mapStateToProps = (state, ownProps) => { const loggedIn = !!username; const current_account_name = username ? username : state.offchain.get('account'); - const gptEnabled = state.app.getIn(['googleAds', 'gptEnabled']); const content = state.global.get('content'); // TODO: needed for SSR? let unreadNotificationCount = 0; if (loggedIn && state.global.getIn(['notifications', current_account_name, 'unreadNotifications'])) { @@ -428,7 +371,6 @@ const mapStateToProps = (state, ownProps) => { current_account_name, showAnnouncement: state.user.get('showAnnouncement'), walletUrl: state.app.get('walletUrl'), - gptEnabled, content, unreadNotificationCount, notificationActionPending: state.global.getIn(['notifications', 'loading']), diff --git a/src/app/components/pages/CommunitiesIndex.jsx b/src/app/components/pages/CommunitiesIndex.jsx index f72f587448e09340f4a71cd2693061d8888c5c28..3635638ccedc22ca84afb8578946463605e1cea7 100644 --- a/src/app/components/pages/CommunitiesIndex.jsx +++ b/src/app/components/pages/CommunitiesIndex.jsx @@ -114,7 +114,7 @@ export default class CommunitiesIndex extends React.Component { const { searchQuery, searchOrder } = this.state; return ( - <PostsIndexLayout category={null} enableAds={false} blogmode={false}> + <PostsIndexLayout category={null} blogmode={false}> <div className="CommunitiesIndex c-sidebar__module"> {username && ( <div style={{ float: 'right' }}> diff --git a/src/app/components/pages/CommunityRoles.jsx b/src/app/components/pages/CommunityRoles.jsx index d567365e77ffcb560054d3efb5cc14405f7939f4..56608501b609a0cba29fbfc6f2d4abea29c05ed8 100644 --- a/src/app/components/pages/CommunityRoles.jsx +++ b/src/app/components/pages/CommunityRoles.jsx @@ -18,7 +18,6 @@ class CommunityRoles extends React.Component { title: '', updateRoleModal: false, addUserToCommunityModal: false, - updatedRole: '', }; this.onAccountChange = this.onAccountChange.bind(this); this.onRoleChange = this.onRoleChange.bind(this); @@ -72,8 +71,8 @@ class CommunityRoles extends React.Component { render() { const { - community, loading, updating, roles, communityMetadata -} = this.props; + community, loading, updating, roles, communityMetadata, + } = this.props; const canEdit = { owner: ['admin', 'mod', 'member', 'guest', 'muted'], @@ -222,7 +221,7 @@ class CommunityRoles extends React.Component { } return ( - <PostsIndexLayout category={community} enableAds={false} blogmode={false}> + <PostsIndexLayout category={community} blogmode={false}> <div className="CommunityRoles"> <div className="row"> <div className="column large-9 medium-12 small-12">{body}</div> @@ -237,8 +236,11 @@ const CommunityRolesWrapped = connect( (state, ownProps) => { const { community } = ownProps.params; const tree = state.community.get(community, Map()); - const roles = tree.get('roles', List()); - const loading = roles.size == 0; + let roles = tree.get('roles', List()); + if (typeof roles === 'string') { + roles = List(); + } + const loading = roles.size === 0; const updating = tree.get('updatePending', false); const communityMetadata = state.global.getIn(['community', community]); return { diff --git a/src/app/components/pages/Post.jsx b/src/app/components/pages/Post.jsx index 425afaad77ab083a9e7cebb8ada7114d5d635588..b06d93505ee342865d5c4467fe47fe9ef96e5d83 100644 --- a/src/app/components/pages/Post.jsx +++ b/src/app/components/pages/Post.jsx @@ -5,11 +5,9 @@ import tt from 'counterpart'; import { SIGNUP_URL } from 'shared/constants'; import PostFull from 'app/components/cards/PostFull'; import NotFoundMessage from 'app/components/cards/NotFoundMessage'; -import { parseJsonTags } from 'app/utils/StateFunctions'; import Comment, { sortComments } from 'app/components/cards/Comment'; import DropdownMenu from 'app/components/elements/DropdownMenu'; import { serverApiRecordEvent } from 'app/utils/ServerApiClient'; -import GptAd from 'app/components/elements/GptAd'; import { isLoggedIn } from 'app/utils/UserUtil'; import LoadingIndicator from 'app/components/elements/LoadingIndicator'; @@ -76,8 +74,6 @@ class Post extends React.Component { } } - const gptTags = parseJsonTags(dis); - // A post should be hidden if it is not special, is not told to "show // anyway", and is designated "gray". let postBody; @@ -120,11 +116,7 @@ class Post extends React.Component { if (global.process !== undefined && replies.length > commentLimit) { replies = replies.slice(0, commentLimit); } - let commentCount = 0; const positiveComments = replies.map((reply) => { - commentCount += 1; - const showAd = commentCount % 5 === 0 && commentCount !== replies.length && commentCount !== commentLimit; - return ( <div key={post + reply}> <Comment @@ -134,12 +126,6 @@ class Post extends React.Component { showNegativeComments={showNegativeComments} onHide={this.onHideComment} /> - - {this.props.gptEnabled && showAd ? ( - <div className="Post_footer__ad"> - <GptAd tags={gptTags} type="Freestar" id="bsa-zone_1566494240874-7_123456" /> - </div> - ) : null} </div> ); }); @@ -202,11 +188,6 @@ class Post extends React.Component { </div> </div> )} - {this.props.gptEnabled && commentCount >= 5 ? ( - <div className="Post_footer__ad"> - <GptAd tags={gptTags} type="Freestar" id="bsa-zone_1566494147292-7_123456" /> - </div> - ) : null} <div id="#comments" className="Post_comments row hfeed"> <div className="column large-12"> <div className="Post_comments__content"> @@ -222,11 +203,6 @@ class Post extends React.Component { </div> </div> </div> - {this.props.gptEnabled ? ( - <div className="Post_footer__ad"> - <GptAd tags={gptTags} type="Freestar" id="bsa-zone_1566494371533-0_123456" /> - </div> - ) : null} </div> ); } @@ -244,7 +220,6 @@ export default connect((state, ownProps) => { content, dis, sortOrder: currLocation.query.sort || 'trending', - gptEnabled: state.app.getIn(['googleAds', 'gptEnabled']), loading: state.app.get('loading'), }; })(Post); diff --git a/src/app/components/pages/PostsIndex.jsx b/src/app/components/pages/PostsIndex.jsx index d34e149ed7ebddc03956c23810a697a3c1386ce1..adb080773bab681d1e1ba03b2c8cc19d845702ac 100644 --- a/src/app/components/pages/PostsIndex.jsx +++ b/src/app/components/pages/PostsIndex.jsx @@ -10,7 +10,6 @@ import { actions as fetchDataSagaActions } from 'app/redux/FetchDataSaga'; import PostsList from 'app/components/cards/PostsList'; import { isFetchingOrRecentlyUpdated } from 'app/utils/StateFunctions'; import Callout from 'app/components/elements/Callout'; -import { GptUtils } from 'app/utils/GptUtils'; import SortOrder from 'app/components/elements/SortOrder'; import { ifHive } from 'app/utils/Community'; import PostsIndexLayout from 'app/components/pages/PostsIndexLayout'; @@ -101,7 +100,6 @@ class PostsIndex extends PureComponent { const { topics, subscriptions, - enableAds, community, category, account_name, // TODO: for feed @@ -176,7 +174,7 @@ class PostsIndex extends PureComponent { } return ( - <PostsIndexLayout category={category} enableAds={enableAds} blogmode={this.props.blogmode}> + <PostsIndexLayout category={category} blogmode={this.props.blogmode}> <div className="articles__header row"> <div className="small-8 medium-7 large-8 column"> <h1 className="articles__h1 show-for-mq-large articles__h1--no-wrap">{page_title}</h1> @@ -247,8 +245,6 @@ module.exports = { community = null; } - const enableAds = ownProps.gptEnabled && !GptUtils.HasBannedTags([category], state.app.getIn(['googleAds', 'gptBannedTags'])); - const key = ['discussion_idx', category || '', order]; let posts = state.global.getIn(key, List()); @@ -275,7 +271,6 @@ module.exports = { blogmode: state.app.getIn(['user_preferences', 'blogmode']), topics: state.global.getIn(['topics'], List()), isBrowser: process.env.BROWSER, - enableAds, }; }, (dispatch) => ({ diff --git a/src/app/components/pages/PostsIndexLayout.jsx b/src/app/components/pages/PostsIndexLayout.jsx index 64ac45b04d7de2121105ba6469950fed8572e75e..66152df71d06af2d807e60644fc8de670393bf78 100644 --- a/src/app/components/pages/PostsIndexLayout.jsx +++ b/src/app/components/pages/PostsIndexLayout.jsx @@ -8,7 +8,6 @@ import SidebarLinks from 'app/components/elements/SidebarLinks'; import SidebarNewUsers from 'app/components/elements/SidebarNewUsers'; import Notices from 'app/components/elements/Notices'; import SteemMarket from 'app/components/elements/SteemMarket'; -import GptAd from 'app/components/elements/GptAd'; import CommunityPane from 'app/components/elements/CommunityPane'; import CommunityPaneMobile from 'app/components/elements/CommunityPaneMobile'; import Topics from './Topics'; @@ -38,7 +37,7 @@ class PostsIndexLayout extends React.Component { render() { const { - topics, subscriptions, enableAds, community, username, blogmode, isBrowser, children + topics, subscriptions, community, username, blogmode, isBrowser, children, } = this.props; return ( @@ -58,25 +57,10 @@ class PostsIndexLayout extends React.Component { {isBrowser && !community && username && <SidebarLinks username={username} topics={topics} />} {false && !community && <Notices />} {!community && <SteemMarket />} - {enableAds && ( - <div className="sidebar-ad"> - <GptAd type="Freestar" id="bsa-zone_1566495004689-0_123456" /> - </div> - )} </aside> <aside className="c-sidebar c-sidebar--left"> <Topics compact={false} username={username} subscriptions={subscriptions} topics={topics} /> - {enableAds && ( - <div> - <div className="sidebar-ad"> - <GptAd type="Freestar" slotName="bsa-zone_1566494461953-7_123456" /> - </div> - <div className="sidebar-ad" style={{ marginTop: 20 }}> - <GptAd type="Freestar" slotName="bsa-zone_1566494856923-9_123456" /> - </div> - </div> - )} </aside> </div> ); @@ -96,7 +80,6 @@ export default connect( return { blogmode: props.blogmode, - enableAds: props.enableAds, community, subscriptions: state.global.getIn(['subscriptions', username], null), topics: state.global.getIn(['topics'], List()), diff --git a/src/app/utils/GptUtils.js b/src/app/utils/GptUtils.js deleted file mode 100644 index 359c53353a0f556de509ea53284dc698041c45e1..0000000000000000000000000000000000000000 --- a/src/app/utils/GptUtils.js +++ /dev/null @@ -1,44 +0,0 @@ -import { getViewportDimensions } from './DomUtils'; - -class GptUtils { - /** - * Should we show the mobile version of an ad? - * - * @returns {boolean} - */ - static ShowGptMobileSize() { - return getViewportDimensions().w <= 768; - } - - /** - * Naively append-mobile to a given string representing an ad slot name. - * - * @param {string} slotName - * @returns {string} - */ - static MobilizeSlotName(slotName) { - let mobileSlotAddendum = ''; - if (this.ShowGptMobileSize()) mobileSlotAddendum = '-mobile'; - return `${slotName}${mobileSlotAddendum}`; - } - - /** - * Takes an array of tags and determines whether one or more tags are banned from showing ads. - * - * @param {array[strings]} tags - * @param {array[strings]} bannedTags - * @returns {boolean} - */ - static HasBannedTags(tags = [], bannedTags) { - // eslint-disable-next-line no-restricted-syntax - for (const tag of tags) { - if (bannedTags.indexOf(tag) != -1) { - return true; - } - } - return false; - } -} - -// eslint-disable-next-line import/prefer-default-export -export { GptUtils }; diff --git a/src/app/utils/steemApi.js b/src/app/utils/steemApi.js index 91e915467ca040aba45639ff42ccc151354a1490..be26008446c9205212d2f178555aa77a7b6a1749 100644 --- a/src/app/utils/steemApi.js +++ b/src/app/utils/steemApi.js @@ -7,6 +7,7 @@ import stateCleaner from 'app/redux/stateCleaner'; import { fetchCrossPosts, augmentContentWithCrossPost } from 'app/utils/CrossPosts'; export async function callBridge(method, params) { + console.log('callbrdige', method, params); // [JES] Hivemind throws an exception if you call for my/[trending/payouts/new/etc] with a null observer // so just delete the 'my' tag if there is no observer specified if ( @@ -28,6 +29,7 @@ export async function callBridge(method, params) { && method !== 'get_post_header' && method !== 'list_subscribers' && method !== 'normalize_post' + && method !== 'list_community_roles' && (params.observer === null || params.observer === undefined) ) params.observer = $STM_Config.default_observer; diff --git a/src/server/app_render.jsx b/src/server/app_render.jsx index 39f39f6461ec128cdd91bebb07c24ea6181665ec..f7b81a2c417d80f04a3fd391ebf23a73bc8cdb10 100644 --- a/src/server/app_render.jsx +++ b/src/server/app_render.jsx @@ -1,23 +1,21 @@ +/*global $STM_Config*/ import React from 'react'; import config from 'config'; import { renderToString } from 'react-dom/server'; -import { VIEW_MODE_WHISTLE, PARAM_VIEW_MODE } from '../shared/constants'; -import ServerHTML from './server-html'; -import { serverRender } from '../shared/UniversalRender'; import secureRandom from 'secure-random'; import ErrorPage from 'server/server-error'; +import ServerHTML from './server-html'; +import { serverRender } from '../shared/UniversalRender'; import { determineViewMode } from '../app/utils/Links'; import { getSupportedLocales } from './utils/misc'; const path = require('path'); + const ROOT = path.join(__dirname, '../..'); -const DB_RECONNECT_TIMEOUT = process.env.NODE_ENV === 'development' ? 1000 * 60 * 60 : 1000 * 60 * 10; -const supportedLocales = getSupportedLocales(); async function appRender(ctx, locales = false, resolvedAssets = false) { ctx.state.requestTimer.startTimer('appRender_ms'); - const store = {}; // This is the part of SSR where we make session-specific changes: try { let userPreferences = {}; @@ -49,19 +47,6 @@ async function appRender(ctx, locales = false, resolvedAssets = false) { login_challenge, }; - const googleAds = { - enabled: !!config.google_ad_enabled, - test: !!config.google_ad_test, - client: config.google_ad_client, - adSlots: config.google_ad_slots, - gptEnabled: !!config.gpt_enabled, - gptBidding: config.gpt_bidding, - gptBasicSlots: config.gpt_basic_slots, - gptCategorySlots: config.gpt_category_slots, - gptBiddingSlots: config.gpt_bidding_slots, - gptBannedTags: config.gpt_banned_tags, - videoAdsEnabled: !!config.video_ads_enabled, - }; const cookieConsent = { enabled: !!config.cookie_consent_enabled, api_key: config.cookie_consent_api_key, @@ -70,14 +55,15 @@ async function appRender(ctx, locales = false, resolvedAssets = false) { const initial_state = { app: { viewMode: determineViewMode(ctx.request.search), - googleAds: googleAds, env: process.env.NODE_ENV, walletUrl: config.wallet_url, steemMarket: ctx.steemMarketData, }, }; - const { body, title, statusCode, meta, redirectUrl } = await serverRender( + const { + body, title, statusCode, meta, redirectUrl, + } = await serverRender( ctx.request.url, initial_state, ErrorPage, @@ -99,6 +85,7 @@ async function appRender(ctx, locales = false, resolvedAssets = false) { if (!resolvedAssets) { // Assets name are found in `webpack-stats` file const assets_filename = ROOT + '/tmp/webpack-stats-dev.json'; + // eslint-disable-next-line global-require,import/no-dynamic-require assets = require(assets_filename); delete require.cache[require.resolve(assets_filename)]; } else { @@ -109,11 +96,6 @@ async function appRender(ctx, locales = false, resolvedAssets = false) { assets, title, meta, - shouldSeeAds: googleAds.enabled, - gptEnabled: googleAds.gptEnabled, - adClient: googleAds.client, - videoAdsEnabled: googleAds.videoAdsEnabled, - gptBidding: googleAds.gptBidding, shouldSeeCookieConsent: cookieConsent.enabled, cookieConsentApiKey: cookieConsent.api_key, }; diff --git a/src/server/server-html.jsx b/src/server/server-html.jsx index ee96f2b96872444003416aa60414622ab9590332..b6513882ad94e70f6b2e603a565cbf544a3261c9 100644 --- a/src/server/server-html.jsx +++ b/src/server/server-html.jsx @@ -5,7 +5,6 @@ export default function ServerHTML({ assets, title, meta, - gptEnabled, shouldSeeCookieConsent, cookieConsentApiKey, }) { @@ -101,25 +100,6 @@ export default function ServerHTML({ {assets.style.map((href) => ( <link href={href} key={href} rel="stylesheet" type="text/css" /> ))} - {gptEnabled ? ( - <script - dangerouslySetInnerHTML={{ - __html: ` - (function() { - var bsa_optimize = document.createElement('script'); - window.optimize = { queue: [] }; - bsa_optimize.type = 'text/javascript'; - bsa_optimize.async = true; - bsa_optimize.src = 'https://cdn-s2s.buysellads.net/pub/steemit.js?' + (new Date() - new Date() % 3600000); - (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(bsa_optimize); - })(); - `, - }} - /> - ) : null} - {gptEnabled ? ( - <script src="//m.servedby-buysellads.com/monetization.js" type="text/javascript" /> - ) : null} {shouldSeeCookieConsent ? ( <script id="Cookiebot" @@ -161,19 +141,6 @@ export default function ServerHTML({ {assets.script.map((href) => ( <script key={href} src={href} /> ))} - {/* gptEnabled ? ( - <script - dangerouslySetInnerHTML={{ - __html: ` - (function(){ - if(typeof _bsa !== 'undefined' && _bsa) { - _bsa.init('fancybar', 'CE7D653L', 'placement:steemitcom'); - } - })(); - `, - }} - /> - ) : null*/} </body> </html> ); diff --git a/src/server/server.js b/src/server/server.js index 32a95f62ac6c5171a0908b025ee3abb5120d9a49..e39c0fc394b629c6532f30a9d6b54043c6a04ef7 100644 --- a/src/server/server.js +++ b/src/server/server.js @@ -15,10 +15,8 @@ import minimist from 'minimist'; import config from 'config'; import secureRandom from 'secure-random'; import koaLocale from 'koa-locale'; -import fs from 'fs'; import { routeRegex } from 'app/ResolveRoute'; import userIllegalContent from 'app/utils/userIllegalContent'; -// eslint-disable-next-line import/named import { getSupportedLocales } from './utils/misc'; import { specialPosts } from './utils/SpecialPosts'; import usePostJson from './json/post_json'; @@ -41,9 +39,6 @@ const env = process.env.NODE_ENV || 'development'; // cache of a thousand days const cacheOpts = { maxAge: 86400000, gzip: true, buffer: true }; -// import ads.txt to be served statically -const adstxt = fs.readFileSync(path.join(__dirname, '../app/assets/ads.txt'), 'utf8'); - // Serve static assets without fanfare app.use(favicon(path.join(__dirname, '../app/assets/images/favicons/favicon.ico'))); @@ -53,14 +48,6 @@ app.use(mount('/images', staticCache(path.join(__dirname, '../app/assets/images' app.use(mount('/javascripts', staticCache(path.join(__dirname, '../app/assets/javascripts'), cacheOpts))); -app.use( - // eslint-disable-next-line require-yield - mount('/ads.txt', function* () { - this.type = 'text/plain'; - this.body = adstxt; - }) -); - // Proxy asset folder to webpack development server in development mode if (env === 'development') { const webpack_dev_port = process.env.PORT ? parseInt(process.env.PORT) + 1 : 8081; diff --git a/src/server/utils/misc.js b/src/server/utils/misc.js index 620486985000ee11a13ee46f56fdad64a2a6e42d..08e46c18147c249466d2172294e4e195b3ea499b 100644 --- a/src/server/utils/misc.js +++ b/src/server/utils/misc.js @@ -1,14 +1,14 @@ import path from 'path'; import fs from 'fs'; -function getRemoteIp(req) { +export function getRemoteIp(req) { const remote_address = req.headers['x-forwarded-for'] || req.connection.remoteAddress; const ip_match = remote_address ? remote_address.match(/(\d+\.\d+\.\d+\.\d+)/) : null; return ip_match ? ip_match[1] : remote_address; } const ip_last_hit = new Map(); -function rateLimitReq(ctx, req) { +export function rateLimitReq(ctx, req) { const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; const now = Date.now(); @@ -36,7 +36,7 @@ function rateLimitReq(ctx, req) { return result; } -function checkCSRF(ctx, csrf) { +export function checkCSRF(ctx, csrf) { try { ctx.assertCSRF(csrf); } catch (e) { @@ -48,7 +48,7 @@ function checkCSRF(ctx, csrf) { return true; } -function getSupportedLocales() { +export function getSupportedLocales() { const locales = []; const files = fs.readdirSync(path.join(__dirname, '../../..', 'src/app/locales')); // eslint-disable-next-line no-restricted-syntax @@ -59,7 +59,7 @@ function getSupportedLocales() { return locales; } -module.exports = { +export default { getRemoteIp, rateLimitReq, checkCSRF,