From 230772d380b7da7e1cfd74c25f6bf45153c4c80a Mon Sep 17 00:00:00 2001 From: David Fischer Date: Fri, 27 Apr 2018 11:43:16 -0700 Subject: [PATCH 1/3] Ad block nag to get people to whitelist --- media/css/readthedocs-doc-embed.css | 22 +++++++++++++++++++ .../core/js/doc-embed/sponsorship.js | 22 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/media/css/readthedocs-doc-embed.css b/media/css/readthedocs-doc-embed.css index d75e3ec4c74..610b9f7b63b 100644 --- a/media/css/readthedocs-doc-embed.css +++ b/media/css/readthedocs-doc-embed.css @@ -161,3 +161,25 @@ 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; +} +.wy-body-for-nav .keep-us-sustainable a { + color: #b3b3b3; + 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..9e8ad2fc6ee 100644 --- a/readthedocs/core/static-src/core/js/doc-embed/sponsorship.js +++ b/readthedocs/core/static-src/core/js/doc-embed/sponsorship.js @@ -143,6 +143,27 @@ function adblock_admonition() { console.log('--------------------------------------------------------------------------------------'); } +function adblock_nag() { + // Place an ad block nag into the sidebar + var placement = create_sidebar_placement(); + var url = 'https://ads-for-open-source.readthedocs.io/'; + var container = null; + var div; + var link; + + if (placement && placement.div_id) { + container = $('#' + placement.div_id); + container.attr('class', 'keep-us-sustainable'); + + link = $('').attr('href', url).appendTo(container); + div = $('
').appendTo(link); + + $('

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

').text('Please whitelist Read the Docs on your ad blocker and help keep us sustainable.').appendTo(div); + $('

').text('Thank you! \u2764\ufe0f').appendTo(div); + } +} + function init() { var request_data = {format: "jsonp"}; var div_ids = []; @@ -207,6 +228,7 @@ function init() { if (xhr && xhr.status === 404 && rtd.api_host === 'https://readthedocs.org') { adblock_admonition(); + adblock_nag(); } }, }); From affe6e4051ff78c0fc2fa19feb62edb0c094d532 Mon Sep 17 00:00:00 2001 From: David Fischer Date: Fri, 27 Apr 2018 13:49:05 -0700 Subject: [PATCH 2/3] Chage verbiage slightly --- readthedocs/core/static-src/core/js/doc-embed/sponsorship.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9e8ad2fc6ee..db773366f84 100644 --- a/readthedocs/core/static-src/core/js/doc-embed/sponsorship.js +++ b/readthedocs/core/static-src/core/js/doc-embed/sponsorship.js @@ -159,7 +159,7 @@ function adblock_nag() { div = $('

').appendTo(link); $('

').text('Support Read the Docs!').appendTo(div); - $('

').text('Please whitelist Read the Docs on your ad blocker and help keep us sustainable.').appendTo(div); + $('

').text('Please help keep us sustainable by allowing our ethical ads in your ad blocker.').appendTo(div); $('

').text('Thank you! \u2764\ufe0f').appendTo(div); } } From eb4f10f916cb31426db1d241c73ab8ba3b918b99 Mon Sep 17 00:00:00 2001 From: David Fischer Date: Wed, 6 Jun 2018 10:23:52 -0700 Subject: [PATCH 3/3] Add a link to go ad-free --- media/css/readthedocs-doc-embed.css | 3 ++- .../core/js/doc-embed/sponsorship.js | 18 +++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/media/css/readthedocs-doc-embed.css b/media/css/readthedocs-doc-embed.css index 610b9f7b63b..8488690cfc8 100644 --- a/media/css/readthedocs-doc-embed.css +++ b/media/css/readthedocs-doc-embed.css @@ -177,9 +177,10 @@ div.ethical-sidebar, div.ethical-footer { /* 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: #b3b3b3; + 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 db773366f84..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,6 +138,7 @@ 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('--------------------------------------------------------------------------------------'); @@ -146,21 +147,16 @@ function adblock_admonition() { function adblock_nag() { // Place an ad block nag into the sidebar var placement = create_sidebar_placement(); - var url = 'https://ads-for-open-source.readthedocs.io/'; + var unblock_url = 'https://ads-for-open-source.readthedocs.io/'; + var ad_free_url = 'https://readthedocs.org/sustainability/'; var container = null; - var div; - var link; if (placement && placement.div_id) { - container = $('#' + placement.div_id); - container.attr('class', 'keep-us-sustainable'); + container = $('#' + placement.div_id).attr('class', 'keep-us-sustainable'); - link = $('').attr('href', url).appendTo(container); - div = $('

').appendTo(link); - - $('

').text('Support Read the Docs!').appendTo(div); - $('

').text('Please help keep us sustainable by allowing our ethical ads in your ad blocker.').appendTo(div); - $('

').text('Thank you! \u2764\ufe0f').appendTo(div); + $('

').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); } }