Skip to content

Commit

Permalink
Merge pull request #4329 from rtfd/davidfischer/no-nag-for-adfree-pro…
Browse files Browse the repository at this point in the history
…jects

Disable the ad block nag for ad-free projects
  • Loading branch information
davidfischer authored Jul 16, 2018
2 parents 2d95d21 + dda848a commit 09f19a4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion readthedocs/core/static-src/core/js/doc-embed/rtd-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ function get() {
var config = Object.create(configMethods);

var defaults = {
api_host: 'https://readthedocs.org'
api_host: 'https://readthedocs.org',
ad_free: false,
};

$.extend(config, defaults, window.READTHEDOCS_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function init() {
error: function (xhr, textStatus, errorThrown) {
console.error('Error loading Read the Docs promo');

if (xhr && xhr.status === 404 && rtd.api_host === 'https://readthedocs.org') {
if (!rtddata.ad_free && xhr && xhr.status === 404 && rtd.api_host === 'https://readthedocs.org') {
adblock_admonition();
adblock_nag();
}
Expand Down
1 change: 1 addition & 0 deletions readthedocs/doc_builder/backends/mkdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def generate_rtd_data(self, docs_dir, mkdocs_config):
'docroot': docs_dir,
'source_suffix': ".md",
'api_host': getattr(settings, 'PUBLIC_API_URL', 'https://readthedocs.org'),
'ad_free': self.project.ad_free or self.project.gold_owners.exists(),
'commit': self.version.project.vcs_repo(self.version.slug).commit,
'global_analytics_code': getattr(settings, 'GLOBAL_ANALYTICS_CODE', 'UA-17997319-1'),
'user_analytics_code': analytics_code,
Expand Down
7 changes: 2 additions & 5 deletions readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,10 @@ context = {
'using_theme': (html_theme == "default"),
'new_theme': (html_theme == "sphinx_rtd_theme"),
'source_suffix': SUFFIX,
'ad_free': {% if project.gold_owners.exists or project.ad_free %}True{% else %}False{% endif %},
'user_analytics_code': '{{ project.analytics_code|default_if_none:'' }}',
'global_analytics_code': '{{ settings.GLOBAL_ANALYTICS_CODE }}',
{% if project.repo_type == 'git' %}
'commit': '{{ commit|slice:"8" }}',
{% else %}
'commit': '{{ commit }}',
{% endif %}
'commit': {% if project.repo_type == 'git' %}'{{ commit|slice:"8" }}'{% else %}'{{ commit }}'{% endif %},
}

{# Provide block for extending context data from child template #}
Expand Down

0 comments on commit 09f19a4

Please sign in to comment.