Skip to content

Commit

Permalink
Merge pull request #3922 from davidfischer/ads-on-mkdocs-rtd-theme
Browse files Browse the repository at this point in the history
Enable ads on the readthedocs mkdocs theme
  • Loading branch information
davidfischer authored May 16, 2018
2 parents 26c0d7a + 7a248ec commit b05c82a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion readthedocs/core/static-src/core/js/doc-embed/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
var exports = {
THEME_RTD: 'sphinx_rtd_theme',
THEME_ALABASTER: 'alabaster',
THEME_CELERY: 'sphinx_celery'
THEME_CELERY: 'sphinx_celery',
THEME_MKDOCS_RTD: 'readthedocs'
};

exports.PROMO_SUPPORTED_THEMES = [
Expand Down
8 changes: 7 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 @@ -19,10 +19,17 @@ var configMethods = {
return (!('builder' in this) || this.builder !== 'mkdocs');
},

is_mkdocs_builder: function () {
return (!('builder' in this) || this.builder === 'mkdocs');
},

get_theme_name: function () {
// Crappy heuristic, but people change the theme name on us. So we have to
// do some duck typing.
if (this.theme !== constants.THEME_RTD) {
if (this.theme === constants.THEME_MKDOCS_RTD) {
return constants.THEME_RTD;
}
if ($('div.rst-other-versions').length === 1) {
return constants.THEME_RTD;
}
Expand All @@ -33,7 +40,6 @@ var configMethods = {
show_promo: function () {
return (
this.api_host !== 'https://readthedocs.com' &&
this.is_sphinx_builder() &&
this.theme_supports_promo());
}
};
Expand Down
5 changes: 4 additions & 1 deletion readthedocs/core/static-src/core/js/doc-embed/sponsorship.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ function create_sidebar_placement() {
var selector = null;
var class_name; // Used for theme specific CSS customizations

if (rtd.is_rtd_theme()) {
if (rtd.is_mkdocs_builder() && rtd.is_rtd_theme()) {
selector = 'nav.wy-nav-side';
class_name = 'ethical-rtd';
} else if (rtd.is_rtd_theme()) {
selector = 'nav.wy-nav-side > div.wy-side-scroll';
class_name = 'ethical-rtd';
} else if (rtd.get_theme_name() === constants.THEME_ALABASTER ||
Expand Down

0 comments on commit b05c82a

Please sign in to comment.