');
-
- contents.html("..." + content_text + "...");
- contents.find('em').addClass('highlighted');
- list_item.append(contents);
+ for (var j = 0; j < inner_hits.length; j += 1) {
+
+ var contents = $('
');
+
+ var section_template = '' +
+ '
' +
+ '<% for (var i = 0; i < section_content.length; ++i) { %>' +
+ '
' +
+ '<%= section_content[i] %>' +
+ '
' +
+ '<% } %>';
+
+ var domain_template = '' +
+ '
' +
+ '
' +
+ '<%= domain_content %>' +
+ '';
+
+ // if the result is page section
+ if(inner_hits[j].type === "sections") {
+
+ var section = inner_hits[j];
+ var section_subtitle = section._source.title;
+ var section_subtitle_link = link + "#" + section._source.id;
+ var section_content = [section._source.content.substring(0, MAX_SUBSTRING_LIMIT) + " ..."];
+
+ if (section.highlight) {
+ if (section.highlight["sections.title"]) {
+ section_subtitle = xss(section.highlight["sections.title"][0]);
+ }
+
+ if (section.highlight["sections.content"]) {
+ var content = section.highlight["sections.content"];
+ section_content = [];
+ for (
+ var k = 0;
+ k < content.length && k < MAX_RESULT_PER_SECTION;
+ k += 1
+ ) {
+ section_content.push("... " + xss(content[k]) + " ...");
+ }
+ }
}
+
+ contents.append(
+ $u.template(
+ section_template,
+ {
+ section_subtitle_link: section_subtitle_link,
+ section_subtitle: section_subtitle,
+ section_content: section_content
+ }
+ )
+ );
}
+
+ // if the result is a sphinx domain object
+ if (inner_hits[j].type === "domains") {
+
+ var domain = inner_hits[j];
+ var domain_subtitle = domain._source.role_name;
+ var domain_subtitle_link = link + "#" + domain._source.anchor;
+ var domain_content = "";
+ var domain_name = domain._source.name;
+
+ if (
+ typeof domain._source.display_name === "string" &&
+ domain._source.display_name.length >= 1
+ ) {
+ domain_subtitle = "(" + domain._source.role_name + ") " + domain._source.display_name;
+ }
+
+ if (domain.highlight) {
+ if (domain.highlight["domains.name"]) {
+ // domain_content = type_display -- name
+ domain_name = xss(domain.highlight["domains.name"][0]);
+ }
+ }
+
+ // domain_content = type_display -- name -- in doc_display
+ domain_content = domain._source.type_display + " -- " + domain_name + " -- in " + domain._source.doc_display;
+
+ contents.append(
+ $u.template(
+ domain_template,
+ {
+ domain_subtitle_link: domain_subtitle_link,
+ domain_subtitle: domain_subtitle,
+ domain_content: domain_content
+ }
+ )
+ );
+ }
+
+ contents.find('em').addClass('highlighted');
+ list_item.append(contents);
+ list_item.append($("
"));
}
Search.output.append(list_item);
diff --git a/readthedocs/core/static/core/js/readthedocs-doc-embed.js b/readthedocs/core/static/core/js/readthedocs-doc-embed.js
index c2f910fb29e..b7e28d8629c 100644
--- a/readthedocs/core/static/core/js/readthedocs-doc-embed.js
+++ b/readthedocs/core/static/core/js/readthedocs-doc-embed.js
@@ -1 +1 @@
-!function o(a,s,l){function d(t,e){if(!s[t]){if(!a[t]){var i="function"==typeof require&&require;if(!e&&i)return i(t,!0);if(c)return c(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var n=s[t]={exports:{}};a[t][0].call(n.exports,function(e){return d(a[t][1][e]||e)},n,n.exports,o,a,s,l)}return s[t].exports}for(var c="function"==typeof require&&require,e=0;e
"),i(".wy-menu-vertical ul").not(".simple").siblings("a").each(function(){var t=i(this);expand=i('
'),expand.on("click",function(e){return r.toggleCurrent(t),e.stopPropagation(),!1}),t.prepend(expand)})},reset:function(){var e=encodeURI(window.location.hash)||"#";try{var t=$(".wy-menu-vertical"),i=t.find('[href="'+e+'"]');if(0===i.length){var r=$('.document [id="'+e.substring(1)+'"]').closest("div.section");0===(i=t.find('[href="#'+r.attr("id")+'"]')).length&&(i=t.find('[href="#"]'))}0