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

Disable the ad block nag for ad-free projects #4329

Merged
merged 3 commits into from
Jul 16, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been rtd.ad_free. How did this ever work?

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