Skip to content

Support ads on pallets themes #4499

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

Merged
merged 2 commits into from
Aug 10, 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
25 changes: 21 additions & 4 deletions readthedocs/core/static-src/core/js/doc-embed/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,36 @@
var exports = {
THEME_RTD: 'sphinx_rtd_theme',
THEME_ALABASTER: 'alabaster',
THEME_CELERY: 'sphinx_celery',
THEME_MKDOCS_RTD: 'readthedocs',

// Alabaster-like
THEME_CELERY: 'sphinx_celery',
THEME_BABEL: 'babel',
THEME_CLICK: 'click',
THEME_FLASK_SQLALCHEMY: 'flask-sqlalchemy',
THEME_FLASK: 'flask',
THEME_JINJA: 'jinja',
THEME_PLATTER: 'platter',
THEME_POCOO: 'pocoo',
THEME_WERKZEUG: 'werkzeug',

DEFAULT_PROMO_PRIORITY: 5,
MINIMUM_PROMO_PRIORITY: 10,
MAXIMUM_PROMO_PRIORITY: 1,
LOW_PROMO_PRIORITY: 10,
};

exports.PROMO_SUPPORTED_THEMES = [
exports.THEME_RTD,
exports.ALABASTER_LIKE_THEMES = [
exports.THEME_ALABASTER,
exports.THEME_CELERY
exports.THEME_CELERY,
exports.THEME_BABEL,
exports.THEME_CLICK,
exports.THEME_FLASK_SQLALCHEMY,
exports.THEME_FLASK,
exports.THEME_JINJA,
exports.THEME_PLATTER,
exports.THEME_POCOO,
exports.THEME_WERKZEUG,
];

exports.PROMO_TYPES = {
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/core/static-src/core/js/doc-embed/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function injectFooter(data) {

// If the theme looks like ours, update the existing badge
// otherwise throw a a full one into the page.
if (config.is_rtd_theme()) {
if (config.is_rtd_like_theme()) {
$("div.rst-other-versions").html(data['html']);
} else {
$("body").append(data['html']);
Expand Down
26 changes: 13 additions & 13 deletions readthedocs/core/static-src/core/js/doc-embed/rtd-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@
var constants = require('./constants');

var configMethods = {
is_rtd_theme: function () {
return this.get_theme_name() === constants.THEME_RTD;
is_rtd_like_theme: function () {
if ($('div.rst-other-versions').length === 1) {
// Crappy heuristic, but people change the theme name
// So we have to do some duck typing.
return true;
}
return this.theme === constants.THEME_RTD || this.theme === constants.THEME_MKDOCS_RTD;
},

is_alabaster_like_theme: function () {
// Returns true for Alabaster-like themes (eg. flask, celery)
return constants.ALABASTER_LIKE_THEMES.indexOf(this.get_theme_name()) > -1;
},

theme_supports_promo: function () {
return constants.PROMO_SUPPORTED_THEMES.indexOf(this.get_theme_name()) > -1;
return this.is_rtd_like_theme() || this.is_alabaster_like_theme();
},

is_sphinx_builder: function () {
Expand All @@ -24,16 +34,6 @@ var configMethods = {
},

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;
}
}
return this.theme;
},

Expand Down
2 changes: 1 addition & 1 deletion readthedocs/core/static-src/core/js/doc-embed/sphinx.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function init() {
}, 1000);
});

if (rtd.is_rtd_theme()) {
if (rtd.is_rtd_like_theme()) {
// Add a scrollable element to the sidebar on the RTD sphinx theme
// This fix is for sphinx_rtd_theme<=0.1.8
var navBar = jquery('div.wy-side-scroll:first');
Expand Down
12 changes: 5 additions & 7 deletions readthedocs/core/static-src/core/js/doc-embed/sponsorship.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ function create_sidebar_placement() {
var class_name; // Used for theme specific CSS customizations
var offset;

if (rtd.is_mkdocs_builder() && rtd.is_rtd_theme()) {
if (rtd.is_mkdocs_builder() && rtd.is_rtd_like_theme()) {
selector = 'nav.wy-nav-side';
class_name = 'ethical-rtd';
} else if (rtd.is_rtd_theme()) {
} else if (rtd.is_rtd_like_theme()) {
selector = 'nav.wy-nav-side > div.wy-side-scroll';
class_name = 'ethical-rtd';
} else if (rtd.get_theme_name() === constants.THEME_ALABASTER ||
rtd.get_theme_name() === constants.THEME_CELERY) {
} else if (rtd.is_alabaster_like_theme()) {
selector = 'div.sphinxsidebar > div.sphinxsidebarwrapper';
class_name = 'ethical-alabaster';
}
Expand Down Expand Up @@ -63,11 +62,10 @@ function create_footer_placement() {
var class_name;
var offset;

if (rtd.is_rtd_theme()) {
if (rtd.is_rtd_like_theme()) {
selector = $('<div />').insertAfter('footer hr');
class_name = 'ethical-rtd';
} else if (rtd.get_theme_name() === constants.THEME_ALABASTER ||
rtd.get_theme_name() === constants.THEME_CELERY) {
} else if (rtd.is_alabaster_like_theme()) {
selector = 'div.bodywrapper .body';
class_name = 'ethical-alabaster';
}
Expand Down