diff --git a/readthedocs/core/static-src/core/js/doc-embed/rtd-data.js b/readthedocs/core/static-src/core/js/doc-embed/rtd-data.js index 6336d7f55ed..867c6295b83 100644 --- a/readthedocs/core/static-src/core/js/doc-embed/rtd-data.js +++ b/readthedocs/core/static-src/core/js/doc-embed/rtd-data.js @@ -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); 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 c9df2d26e43..11c4f7a0178 100644 --- a/readthedocs/core/static-src/core/js/doc-embed/sponsorship.js +++ b/readthedocs/core/static-src/core/js/doc-embed/sponsorship.js @@ -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(); } diff --git a/readthedocs/doc_builder/backends/mkdocs.py b/readthedocs/doc_builder/backends/mkdocs.py index 1468fcd35ed..c33931fbe16 100644 --- a/readthedocs/doc_builder/backends/mkdocs.py +++ b/readthedocs/doc_builder/backends/mkdocs.py @@ -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, diff --git a/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl b/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl index d6eb89ecaa8..5ac457feb25 100644 --- a/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl +++ b/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl @@ -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 #}