Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ad block nag to urge people to whitelist #4037

Merged
merged 3 commits into from Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions media/css/readthedocs-doc-embed.css
Expand Up @@ -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;
}
18 changes: 18 additions & 0 deletions readthedocs/core/static-src/core/js/doc-embed/sponsorship.js
Expand Up @@ -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');

$('<p />').text('Support Read the Docs!').appendTo(container);
$('<p />').html('Please help keep us sustainable by <a href="' + unblock_url + '">allowing our Ethical Ads in your ad blocker</a> or <a href="' + ad_free_url + '">go ad-free</a> by subscribing.').appendTo(container);
$('<p />').text('Thank you! \u2764\ufe0f').appendTo(container);
}
}

function init() {
var request_data = {format: "jsonp"};
var div_ids = [];
Expand Down Expand Up @@ -207,6 +224,7 @@ function init() {

if (xhr && xhr.status === 404 && rtd.api_host === 'https://readthedocs.org') {
adblock_admonition();
adblock_nag();
}
},
});
Expand Down