Skip to content

Commit fc7bb7e

Browse files
committed
Enumerate ad themes explicitly
1 parent fa57188 commit fc7bb7e

File tree

5 files changed

+38
-25
lines changed

5 files changed

+38
-25
lines changed

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,34 @@ var exports = {
55
THEME_ALABASTER: 'alabaster',
66
THEME_MKDOCS_RTD: 'readthedocs',
77

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+
819
DEFAULT_PROMO_PRIORITY: 5,
920
MINIMUM_PROMO_PRIORITY: 10,
1021
MAXIMUM_PROMO_PRIORITY: 1,
1122
LOW_PROMO_PRIORITY: 10,
1223
};
1324

14-
exports.PROMO_SUPPORTED_THEMES = [
15-
exports.THEME_RTD,
25+
exports.ALABASTER_LIKE_THEMES = [
1626
exports.THEME_ALABASTER,
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,
1736
];
1837

1938
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: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +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;
1217
},
1318

14-
is_alabaster_theme: function () {
19+
is_alabaster_like_theme: function () {
1520
// Returns true for Alabaster-like themes (eg. flask, celery)
16-
return this.get_theme_name() === constants.THEME_ALABASTER;
21+
return constants.ALABASTER_LIKE_THEMES.indexOf(this.get_theme_name()) > -1;
1722
},
1823

1924
theme_supports_promo: function () {
20-
return constants.PROMO_SUPPORTED_THEMES.indexOf(this.get_theme_name()) > -1;
25+
return this.is_rtd_like_theme() || this.is_alabaster_like_theme();
2126
},
2227

2328
is_sphinx_builder: function () {
@@ -29,17 +34,6 @@ var configMethods = {
2934
},
3035

3136
get_theme_name: function () {
32-
// Crappy heuristic, but people change the theme name on us.
33-
// So we have to do some duck typing.
34-
if (this.theme !== constants.THEME_RTD && this.theme !== constants.THEME_ALABASTER) {
35-
if (this.theme === constants.THEME_MKDOCS_RTD) {
36-
return constants.THEME_RTD;
37-
} else if ($('div.rst-other-versions').length === 1) {
38-
return constants.THEME_RTD;
39-
} else if ($('div.sphinxsidebar > div.sphinxsidebarwrapper').length === 1) {
40-
return constants.THEME_ALABASTER;
41-
}
42-
}
4337
return this.theme;
4438
},
4539

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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +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.is_alabaster_theme()) {
27+
} else if (rtd.is_alabaster_like_theme()) {
2828
selector = 'div.sphinxsidebar > div.sphinxsidebarwrapper';
2929
class_name = 'ethical-alabaster';
3030
}
@@ -62,10 +62,10 @@ function create_footer_placement() {
6262
var class_name;
6363
var offset;
6464

65-
if (rtd.is_rtd_theme()) {
65+
if (rtd.is_rtd_like_theme()) {
6666
selector = $('<div />').insertAfter('footer hr');
6767
class_name = 'ethical-rtd';
68-
} else if (rtd.is_alabaster_theme()) {
68+
} else if (rtd.is_alabaster_like_theme()) {
6969
selector = 'div.bodywrapper .body';
7070
class_name = 'ethical-alabaster';
7171
}

0 commit comments

Comments
 (0)