Make searchtools.js compatible with pre-Sphinx1.5 templates

There are still plenty of projects which use custom templates where
DOCUMENTATION_OPTIONS does not define SOURCELINK_SUFFIX.

Currently search does not work in these projects. Make suffix fall
back to .txt since that is the default value of configuration option.
This commit is contained in:
Dmitry Shachnev 2017-10-03 18:42:06 +07:00
parent 3ec2a649b4
commit 9da3bf93ff

View File

@ -269,6 +269,9 @@ var Search = {
});
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
var suffix = DOCUMENTATION_OPTIONS.SOURCELINK_SUFFIX;
if (suffix === undefined) {
suffix = '.txt';
}
$.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[5] + (item[5].slice(-suffix.length) === suffix ? '' : suffix),
dataType: "text",
complete: function(jqxhr, textstatus) {