diff --git a/media/css/readthedocs-doc-embed.css b/media/css/readthedocs-doc-embed.css index d75e3ec4c74..8488690cfc8 100644 --- a/media/css/readthedocs-doc-embed.css +++ b/media/css/readthedocs-doc-embed.css @@ -161,3 +161,26 @@ div.ethical-sidebar, div.ethical-footer { display: table; margin-top: 3em; } + +/* Ad block nag */ +.keep-us-sustainable { + padding: .5em; + margin: 1em 0; + text-align: center; + border: 1px dotted #8ECC4C; +} +.keep-us-sustainable a, +.keep-us-sustainable a:hover, +.keep-us-sustainable a:visited { + text-decoration: none; +} +/* Read the Docs theme specific fixes */ +.wy-body-for-nav .keep-us-sustainable { + margin: 1em 2em 1em 1em; + color: #b3b3b3; +} +.wy-body-for-nav .keep-us-sustainable a { + color: #efefef; + font-size: 14px; + line-height: 20px; +} diff --git a/readthedocs/core/static-src/core/js/doc-embed/sponsorship.js b/readthedocs/core/static-src/core/js/doc-embed/sponsorship.js index cd81e2137eb..2f0f0e34721 100644 --- a/readthedocs/core/static-src/core/js/doc-embed/sponsorship.js +++ b/readthedocs/core/static-src/core/js/doc-embed/sponsorship.js @@ -138,11 +138,28 @@ function adblock_admonition() { console.log(' - only show advertisements of interest to developers'); console.log('Read more about our approach to advertising here: https://docs.readthedocs.io/en/latest/ethical-advertising.html'); console.log('Read more about Ads for Open Source: https://ads-for-open-source.readthedocs.io'); + console.log('Or go ad-free: https://readthedocs.org/sustainability/'); console.log('%cPlease whitelist Read the Docs on your adblocker using the following filter:', 'font-size: 2em'); console.log('https://ads-for-open-source.readthedocs.io/en/latest/_static/lists/readthedocs-ads.txt'); console.log('--------------------------------------------------------------------------------------'); } +function adblock_nag() { + // Place an ad block nag into the sidebar + var placement = create_sidebar_placement(); + var unblock_url = 'https://ads-for-open-source.readthedocs.io/'; + var ad_free_url = 'https://readthedocs.org/sustainability/'; + var container = null; + + if (placement && placement.div_id) { + container = $('#' + placement.div_id).attr('class', 'keep-us-sustainable'); + + $('

').text('Support Read the Docs!').appendTo(container); + $('

').html('Please help keep us sustainable by allowing our Ethical Ads in your ad blocker or go ad-free by subscribing.').appendTo(container); + $('

').text('Thank you! \u2764\ufe0f').appendTo(container); + } +} + function init() { var request_data = {format: "jsonp"}; var div_ids = []; @@ -207,6 +224,7 @@ function init() { if (xhr && xhr.status === 404 && rtd.api_host === 'https://readthedocs.org') { adblock_admonition(); + adblock_nag(); } }, });