Skip to content

Commit ea7d37e

Browse files
authored
Merge pull request #4499 from rtfd/davidfischer/ads-on-pallets-themes
Support ads on pallets themes
2 parents a7d100d + fc7bb7e commit ea7d37e

File tree

5 files changed

+41
-26
lines changed

5 files changed

+41
-26
lines changed

readthedocs/core/static-src/core/js/doc-embed/constants.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,36 @@
33
var exports = {
44
THEME_RTD: 'sphinx_rtd_theme',
55
THEME_ALABASTER: 'alabaster',
6-
THEME_CELERY: 'sphinx_celery',
76
THEME_MKDOCS_RTD: 'readthedocs',
87

8+
// Alabaster-like
9+
THEME_CELERY: 'sphinx_celery',
10+
THEME_BABEL: 'babel',
11+
THEME_CLICK: 'click',
12+
THEME_FLASK_SQLALCHEMY: 'flask-sqlalchemy',
13+
THEME_FLASK: 'flask',
14+
THEME_JINJA: 'jinja',
15+
THEME_PLATTER: 'platter',
16+
THEME_POCOO: 'pocoo',
17+
THEME_WERKZEUG: 'werkzeug',
18+
919
DEFAULT_PROMO_PRIORITY: 5,
1020
MINIMUM_PROMO_PRIORITY: 10,
1121
MAXIMUM_PROMO_PRIORITY: 1,
1222
LOW_PROMO_PRIORITY: 10,
1323
};
1424

15-
exports.PROMO_SUPPORTED_THEMES = [
16-
exports.THEME_RTD,
25+
exports.ALABASTER_LIKE_THEMES = [
1726
exports.THEME_ALABASTER,
18-
exports.THEME_CELERY
27+
exports.THEME_CELERY,
28+
exports.THEME_BABEL,
29+
exports.THEME_CLICK,
30+
exports.THEME_FLASK_SQLALCHEMY,
31+
exports.THEME_FLASK,
32+
exports.THEME_JINJA,
33+
exports.THEME_PLATTER,
34+
exports.THEME_POCOO,
35+
exports.THEME_WERKZEUG,
1936
];
2037

2138
exports.PROMO_TYPES = {

readthedocs/core/static-src/core/js/doc-embed/footer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function injectFooter(data) {
77

88
// If the theme looks like ours, update the existing badge
99
// otherwise throw a a full one into the page.
10-
if (config.is_rtd_theme()) {
10+
if (config.is_rtd_like_theme()) {
1111
$("div.rst-other-versions").html(data['html']);
1212
} else {
1313
$("body").append(data['html']);

readthedocs/core/static-src/core/js/doc-embed/rtd-data.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,22 @@
77
var constants = require('./constants');
88

99
var configMethods = {
10-
is_rtd_theme: function () {
11-
return this.get_theme_name() === constants.THEME_RTD;
10+
is_rtd_like_theme: function () {
11+
if ($('div.rst-other-versions').length === 1) {
12+
// Crappy heuristic, but people change the theme name
13+
// So we have to do some duck typing.
14+
return true;
15+
}
16+
return this.theme === constants.THEME_RTD || this.theme === constants.THEME_MKDOCS_RTD;
17+
},
18+
19+
is_alabaster_like_theme: function () {
20+
// Returns true for Alabaster-like themes (eg. flask, celery)
21+
return constants.ALABASTER_LIKE_THEMES.indexOf(this.get_theme_name()) > -1;
1222
},
1323

1424
theme_supports_promo: function () {
15-
return constants.PROMO_SUPPORTED_THEMES.indexOf(this.get_theme_name()) > -1;
25+
return this.is_rtd_like_theme() || this.is_alabaster_like_theme();
1626
},
1727

1828
is_sphinx_builder: function () {
@@ -24,16 +34,6 @@ var configMethods = {
2434
},
2535

2636
get_theme_name: function () {
27-
// Crappy heuristic, but people change the theme name on us. So we have to
28-
// do some duck typing.
29-
if (this.theme !== constants.THEME_RTD) {
30-
if (this.theme === constants.THEME_MKDOCS_RTD) {
31-
return constants.THEME_RTD;
32-
}
33-
if ($('div.rst-other-versions').length === 1) {
34-
return constants.THEME_RTD;
35-
}
36-
}
3737
return this.theme;
3838
},
3939

readthedocs/core/static-src/core/js/doc-embed/sphinx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function init() {
4444
}, 1000);
4545
});
4646

47-
if (rtd.is_rtd_theme()) {
47+
if (rtd.is_rtd_like_theme()) {
4848
// Add a scrollable element to the sidebar on the RTD sphinx theme
4949
// This fix is for sphinx_rtd_theme<=0.1.8
5050
var navBar = jquery('div.wy-side-scroll:first');

readthedocs/core/static-src/core/js/doc-embed/sponsorship.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ function create_sidebar_placement() {
1818
var class_name; // Used for theme specific CSS customizations
1919
var offset;
2020

21-
if (rtd.is_mkdocs_builder() && rtd.is_rtd_theme()) {
21+
if (rtd.is_mkdocs_builder() && rtd.is_rtd_like_theme()) {
2222
selector = 'nav.wy-nav-side';
2323
class_name = 'ethical-rtd';
24-
} else if (rtd.is_rtd_theme()) {
24+
} else if (rtd.is_rtd_like_theme()) {
2525
selector = 'nav.wy-nav-side > div.wy-side-scroll';
2626
class_name = 'ethical-rtd';
27-
} else if (rtd.get_theme_name() === constants.THEME_ALABASTER ||
28-
rtd.get_theme_name() === constants.THEME_CELERY) {
27+
} else if (rtd.is_alabaster_like_theme()) {
2928
selector = 'div.sphinxsidebar > div.sphinxsidebarwrapper';
3029
class_name = 'ethical-alabaster';
3130
}
@@ -63,11 +62,10 @@ function create_footer_placement() {
6362
var class_name;
6463
var offset;
6564

66-
if (rtd.is_rtd_theme()) {
65+
if (rtd.is_rtd_like_theme()) {
6766
selector = $('<div />').insertAfter('footer hr');
6867
class_name = 'ethical-rtd';
69-
} else if (rtd.get_theme_name() === constants.THEME_ALABASTER ||
70-
rtd.get_theme_name() === constants.THEME_CELERY) {
68+
} else if (rtd.is_alabaster_like_theme()) {
7169
selector = 'div.bodywrapper .body';
7270
class_name = 'ethical-alabaster';
7371
}

0 commit comments

Comments
 (0)