Merge lp:~mitya57/ubuntu/raring/sphinx/fix-search-in-webkit into lp:ubuntu/raring/sphinx
- Raring (13.04)
- fix-search-in-webkit
- Merge into raring
Proposed by
Dmitry Shachnev
Status: | Merged |
---|---|
Merged at revision: | 41 |
Proposed branch: | lp:~mitya57/ubuntu/raring/sphinx/fix-search-in-webkit |
Merge into: | lp:ubuntu/raring/sphinx |
Diff against target: |
627 lines (+530/-14) 9 files modified
.pc/applied-patches (+1/-0) .pc/fix_search_in_webkit.diff/sphinx/themes/basic/search.html (+56/-0) .pc/fix_search_in_webkit.diff/sphinx/themes/basic/static/searchtools.js_t (+378/-0) debian/changelog (+6/-0) debian/patches/fix_search_in_webkit.diff (+64/-0) debian/patches/series (+1/-0) debian/rules (+2/-2) sphinx/themes/basic/search.html (+3/-0) sphinx/themes/basic/static/searchtools.js_t (+19/-12) |
To merge this branch: | bzr merge lp:~mitya57/ubuntu/raring/sphinx/fix-search-in-webkit |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Holbach (community) | Approve | ||
Ubuntu branches | Pending | ||
Review via email: mp+156305@code.launchpad.net |
Commit message
Description of the change
This fixes a long-standing issue where the search was not working when browsing the documentation locally in WebKit-based browsers (such as Epiphany or Chromium).
Note that this won't be applied to existing packages in the archive unless they are rebuilt (maybe we should do a mass-rebuild?), but the fix will be applied to (a) new uploads (b) non-packaged documentation.
To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote : | # |
It builds fine on raring amd64 with the testsuite enabled.
Revision history for this message
Dmitry Shachnev (mitya57) wrote : | # |
Oops, please uncomment that, I did that for debugging purposes and forgot to revert.
Revision history for this message
Daniel Holbach (dholbach) wrote : | # |
Ok great, will upload.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.pc/applied-patches' |
2 | --- .pc/applied-patches 2013-02-16 14:51:12 +0000 |
3 | +++ .pc/applied-patches 2013-03-31 15:07:21 +0000 |
4 | @@ -15,3 +15,4 @@ |
5 | manpage_writer_docutils_0.10_api.diff |
6 | parallel_2to3.diff |
7 | fix_literal_block_warning.diff |
8 | +fix_search_in_webkit.diff |
9 | |
10 | === added directory '.pc/fix_search_in_webkit.diff' |
11 | === added directory '.pc/fix_search_in_webkit.diff/sphinx' |
12 | === added directory '.pc/fix_search_in_webkit.diff/sphinx/themes' |
13 | === added directory '.pc/fix_search_in_webkit.diff/sphinx/themes/basic' |
14 | === added file '.pc/fix_search_in_webkit.diff/sphinx/themes/basic/search.html' |
15 | --- .pc/fix_search_in_webkit.diff/sphinx/themes/basic/search.html 1970-01-01 00:00:00 +0000 |
16 | +++ .pc/fix_search_in_webkit.diff/sphinx/themes/basic/search.html 2013-03-31 15:07:21 +0000 |
17 | @@ -0,0 +1,56 @@ |
18 | +{# |
19 | + basic/search.html |
20 | + ~~~~~~~~~~~~~~~~~ |
21 | + |
22 | + Template for the search page. |
23 | + |
24 | + :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. |
25 | + :license: BSD, see LICENSE for details. |
26 | +#} |
27 | +{% extends "layout.html" %} |
28 | +{% set title = _('Search') %} |
29 | +{% set script_files = script_files + ['_static/searchtools.js'] %} |
30 | +{% block extrahead %} |
31 | + <script type="text/javascript"> |
32 | + jQuery(function() { Search.loadIndex("{{ pathto('searchindex.js', 1) }}"); }); |
33 | + </script> |
34 | + {{ super() }} |
35 | +{% endblock %} |
36 | +{% block body %} |
37 | + <h1 id="search-documentation">{{ _('Search') }}</h1> |
38 | + <div id="fallback" class="admonition warning"> |
39 | + <script type="text/javascript">$('#fallback').hide();</script> |
40 | + <p> |
41 | + {% trans %}Please activate JavaScript to enable the search |
42 | + functionality.{% endtrans %} |
43 | + </p> |
44 | + </div> |
45 | + <p> |
46 | + {% trans %}From here you can search these documents. Enter your search |
47 | + words into the box below and click "search". Note that the search |
48 | + function will automatically search for all of the words. Pages |
49 | + containing fewer words won't appear in the result list.{% endtrans %} |
50 | + </p> |
51 | + <form action="" method="get"> |
52 | + <input type="text" name="q" value="" /> |
53 | + <input type="submit" value="{{ _('search') }}" /> |
54 | + <span id="search-progress" style="padding-left: 10px"></span> |
55 | + </form> |
56 | + {% if search_performed %} |
57 | + <h2>{{ _('Search Results') }}</h2> |
58 | + {% if not search_results %} |
59 | + <p>{{ _('Your search did not match any results.') }}</p> |
60 | + {% endif %} |
61 | + {% endif %} |
62 | + <div id="search-results"> |
63 | + {% if search_results %} |
64 | + <ul> |
65 | + {% for href, caption, context in search_results %} |
66 | + <li><a href="{{ pathto(item.href) }}">{{ caption }}</a> |
67 | + <div class="context">{{ context|e }}</div> |
68 | + </li> |
69 | + {% endfor %} |
70 | + </ul> |
71 | + {% endif %} |
72 | + </div> |
73 | +{% endblock %} |
74 | |
75 | === added directory '.pc/fix_search_in_webkit.diff/sphinx/themes/basic/static' |
76 | === added file '.pc/fix_search_in_webkit.diff/sphinx/themes/basic/static/searchtools.js_t' |
77 | --- .pc/fix_search_in_webkit.diff/sphinx/themes/basic/static/searchtools.js_t 1970-01-01 00:00:00 +0000 |
78 | +++ .pc/fix_search_in_webkit.diff/sphinx/themes/basic/static/searchtools.js_t 2013-03-31 15:07:21 +0000 |
79 | @@ -0,0 +1,378 @@ |
80 | +/* |
81 | + * searchtools.js_t |
82 | + * ~~~~~~~~~~~~~~~~ |
83 | + * |
84 | + * Sphinx JavaScript utilties for the full-text search. |
85 | + * |
86 | + * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. |
87 | + * :license: BSD, see LICENSE for details. |
88 | + * |
89 | + */ |
90 | + |
91 | +/** |
92 | + * helper function to return a node containing the |
93 | + * search summary for a given text. keywords is a list |
94 | + * of stemmed words, hlwords is the list of normal, unstemmed |
95 | + * words. the first one is used to find the occurance, the |
96 | + * latter for highlighting it. |
97 | + */ |
98 | + |
99 | +jQuery.makeSearchSummary = function(text, keywords, hlwords) { |
100 | + var textLower = text.toLowerCase(); |
101 | + var start = 0; |
102 | + $.each(keywords, function() { |
103 | + var i = textLower.indexOf(this.toLowerCase()); |
104 | + if (i > -1) |
105 | + start = i; |
106 | + }); |
107 | + start = Math.max(start - 120, 0); |
108 | + var excerpt = ((start > 0) ? '...' : '') + |
109 | + $.trim(text.substr(start, 240)) + |
110 | + ((start + 240 - text.length) ? '...' : ''); |
111 | + var rv = $('<div class="context"></div>').text(excerpt); |
112 | + $.each(hlwords, function() { |
113 | + rv = rv.highlightText(this, 'highlighted'); |
114 | + }); |
115 | + return rv; |
116 | +} |
117 | + |
118 | +{{ search_language_stemming_code|safe }} |
119 | + |
120 | +/** |
121 | + * Search Module |
122 | + */ |
123 | +var Search = { |
124 | + |
125 | + _index : null, |
126 | + _queued_query : null, |
127 | + _pulse_status : -1, |
128 | + |
129 | + init : function() { |
130 | + var params = $.getQueryParameters(); |
131 | + if (params.q) { |
132 | + var query = params.q[0]; |
133 | + $('input[name="q"]')[0].value = query; |
134 | + this.performSearch(query); |
135 | + } |
136 | + }, |
137 | + |
138 | + loadIndex : function(url) { |
139 | + $.ajax({type: "GET", url: url, data: null, success: null, |
140 | + dataType: "script", cache: true}); |
141 | + }, |
142 | + |
143 | + setIndex : function(index) { |
144 | + var q; |
145 | + this._index = index; |
146 | + if ((q = this._queued_query) !== null) { |
147 | + this._queued_query = null; |
148 | + Search.query(q); |
149 | + } |
150 | + }, |
151 | + |
152 | + hasIndex : function() { |
153 | + return this._index !== null; |
154 | + }, |
155 | + |
156 | + deferQuery : function(query) { |
157 | + this._queued_query = query; |
158 | + }, |
159 | + |
160 | + stopPulse : function() { |
161 | + this._pulse_status = 0; |
162 | + }, |
163 | + |
164 | + startPulse : function() { |
165 | + if (this._pulse_status >= 0) |
166 | + return; |
167 | + function pulse() { |
168 | + Search._pulse_status = (Search._pulse_status + 1) % 4; |
169 | + var dotString = ''; |
170 | + for (var i = 0; i < Search._pulse_status; i++) |
171 | + dotString += '.'; |
172 | + Search.dots.text(dotString); |
173 | + if (Search._pulse_status > -1) |
174 | + window.setTimeout(pulse, 500); |
175 | + }; |
176 | + pulse(); |
177 | + }, |
178 | + |
179 | + /** |
180 | + * perform a search for something |
181 | + */ |
182 | + performSearch : function(query) { |
183 | + // create the required interface elements |
184 | + this.out = $('#search-results'); |
185 | + this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out); |
186 | + this.dots = $('<span></span>').appendTo(this.title); |
187 | + this.status = $('<p style="display: none"></p>').appendTo(this.out); |
188 | + this.output = $('<ul class="search"/>').appendTo(this.out); |
189 | + |
190 | + $('#search-progress').text(_('Preparing search...')); |
191 | + this.startPulse(); |
192 | + |
193 | + // index already loaded, the browser was quick! |
194 | + if (this.hasIndex()) |
195 | + this.query(query); |
196 | + else |
197 | + this.deferQuery(query); |
198 | + }, |
199 | + |
200 | + query : function(query) { |
201 | + var stopwords = {{ search_language_stop_words }}; |
202 | + |
203 | + // Stem the searchterms and add them to the correct list |
204 | + var stemmer = new Stemmer(); |
205 | + var searchterms = []; |
206 | + var excluded = []; |
207 | + var hlterms = []; |
208 | + var tmp = query.split(/\s+/); |
209 | + var objectterms = []; |
210 | + for (var i = 0; i < tmp.length; i++) { |
211 | + if (tmp[i] != "") { |
212 | + objectterms.push(tmp[i].toLowerCase()); |
213 | + } |
214 | + |
215 | + if ($u.indexOf(stopwords, tmp[i]) != -1 || tmp[i].match(/^\d+$/) || |
216 | + tmp[i] == "") { |
217 | + // skip this "word" |
218 | + continue; |
219 | + } |
220 | + // stem the word |
221 | + var word = stemmer.stemWord(tmp[i]).toLowerCase(); |
222 | + // select the correct list |
223 | + if (word[0] == '-') { |
224 | + var toAppend = excluded; |
225 | + word = word.substr(1); |
226 | + } |
227 | + else { |
228 | + var toAppend = searchterms; |
229 | + hlterms.push(tmp[i].toLowerCase()); |
230 | + } |
231 | + // only add if not already in the list |
232 | + if (!$.contains(toAppend, word)) |
233 | + toAppend.push(word); |
234 | + }; |
235 | + var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" ")); |
236 | + |
237 | + // console.debug('SEARCH: searching for:'); |
238 | + // console.info('required: ', searchterms); |
239 | + // console.info('excluded: ', excluded); |
240 | + |
241 | + // prepare search |
242 | + var filenames = this._index.filenames; |
243 | + var titles = this._index.titles; |
244 | + var terms = this._index.terms; |
245 | + var fileMap = {}; |
246 | + var files = null; |
247 | + // different result priorities |
248 | + var importantResults = []; |
249 | + var objectResults = []; |
250 | + var regularResults = []; |
251 | + var unimportantResults = []; |
252 | + $('#search-progress').empty(); |
253 | + |
254 | + // lookup as object |
255 | + for (var i = 0; i < objectterms.length; i++) { |
256 | + var others = [].concat(objectterms.slice(0,i), |
257 | + objectterms.slice(i+1, objectterms.length)) |
258 | + var results = this.performObjectSearch(objectterms[i], others); |
259 | + // Assume first word is most likely to be the object, |
260 | + // other words more likely to be in description. |
261 | + // Therefore put matches for earlier words first. |
262 | + // (Results are eventually used in reverse order). |
263 | + objectResults = results[0].concat(objectResults); |
264 | + importantResults = results[1].concat(importantResults); |
265 | + unimportantResults = results[2].concat(unimportantResults); |
266 | + } |
267 | + |
268 | + // perform the search on the required terms |
269 | + for (var i = 0; i < searchterms.length; i++) { |
270 | + var word = searchterms[i]; |
271 | + // no match but word was a required one |
272 | + if ((files = terms[word]) == null) |
273 | + break; |
274 | + if (files.length == undefined) { |
275 | + files = [files]; |
276 | + } |
277 | + // create the mapping |
278 | + for (var j = 0; j < files.length; j++) { |
279 | + var file = files[j]; |
280 | + if (file in fileMap) |
281 | + fileMap[file].push(word); |
282 | + else |
283 | + fileMap[file] = [word]; |
284 | + } |
285 | + } |
286 | + |
287 | + // now check if the files don't contain excluded terms |
288 | + for (var file in fileMap) { |
289 | + var valid = true; |
290 | + |
291 | + // check if all requirements are matched |
292 | + if (fileMap[file].length != searchterms.length) |
293 | + continue; |
294 | + |
295 | + // ensure that none of the excluded terms is in the |
296 | + // search result. |
297 | + for (var i = 0; i < excluded.length; i++) { |
298 | + if (terms[excluded[i]] == file || |
299 | + $.contains(terms[excluded[i]] || [], file)) { |
300 | + valid = false; |
301 | + break; |
302 | + } |
303 | + } |
304 | + |
305 | + // if we have still a valid result we can add it |
306 | + // to the result list |
307 | + if (valid) |
308 | + regularResults.push([filenames[file], titles[file], '', null]); |
309 | + } |
310 | + |
311 | + // delete unused variables in order to not waste |
312 | + // memory until list is retrieved completely |
313 | + delete filenames, titles, terms; |
314 | + |
315 | + // now sort the regular results descending by title |
316 | + regularResults.sort(function(a, b) { |
317 | + var left = a[1].toLowerCase(); |
318 | + var right = b[1].toLowerCase(); |
319 | + return (left > right) ? -1 : ((left < right) ? 1 : 0); |
320 | + }); |
321 | + |
322 | + // combine all results |
323 | + var results = unimportantResults.concat(regularResults) |
324 | + .concat(objectResults).concat(importantResults); |
325 | + |
326 | + // print the results |
327 | + var resultCount = results.length; |
328 | + function displayNextItem() { |
329 | + // results left, load the summary and display it |
330 | + if (results.length) { |
331 | + var item = results.pop(); |
332 | + var listItem = $('<li style="display:none"></li>'); |
333 | + if (DOCUMENTATION_OPTIONS.FILE_SUFFIX == '') { |
334 | + // dirhtml builder |
335 | + var dirname = item[0] + '/'; |
336 | + if (dirname.match(/\/index\/$/)) { |
337 | + dirname = dirname.substring(0, dirname.length-6); |
338 | + } else if (dirname == 'index/') { |
339 | + dirname = ''; |
340 | + } |
341 | + listItem.append($('<a/>').attr('href', |
342 | + DOCUMENTATION_OPTIONS.URL_ROOT + dirname + |
343 | + highlightstring + item[2]).html(item[1])); |
344 | + } else { |
345 | + // normal html builders |
346 | + listItem.append($('<a/>').attr('href', |
347 | + item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX + |
348 | + highlightstring + item[2]).html(item[1])); |
349 | + } |
350 | + if (item[3]) { |
351 | + listItem.append($('<span> (' + item[3] + ')</span>')); |
352 | + Search.output.append(listItem); |
353 | + listItem.slideDown(5, function() { |
354 | + displayNextItem(); |
355 | + }); |
356 | + } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) { |
357 | + $.get(DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + |
358 | + item[0] + '.txt', function(data) { |
359 | + if (data != '') { |
360 | + listItem.append($.makeSearchSummary(data, searchterms, hlterms)); |
361 | + Search.output.append(listItem); |
362 | + } |
363 | + listItem.slideDown(5, function() { |
364 | + displayNextItem(); |
365 | + }); |
366 | + }, "text"); |
367 | + } else { |
368 | + // no source available, just display title |
369 | + Search.output.append(listItem); |
370 | + listItem.slideDown(5, function() { |
371 | + displayNextItem(); |
372 | + }); |
373 | + } |
374 | + } |
375 | + // search finished, update title and status message |
376 | + else { |
377 | + Search.stopPulse(); |
378 | + Search.title.text(_('Search Results')); |
379 | + if (!resultCount) |
380 | + Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.')); |
381 | + else |
382 | + Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount)); |
383 | + Search.status.fadeIn(500); |
384 | + } |
385 | + } |
386 | + displayNextItem(); |
387 | + }, |
388 | + |
389 | + performObjectSearch : function(object, otherterms) { |
390 | + var filenames = this._index.filenames; |
391 | + var objects = this._index.objects; |
392 | + var objnames = this._index.objnames; |
393 | + var titles = this._index.titles; |
394 | + |
395 | + var importantResults = []; |
396 | + var objectResults = []; |
397 | + var unimportantResults = []; |
398 | + |
399 | + for (var prefix in objects) { |
400 | + for (var name in objects[prefix]) { |
401 | + var fullname = (prefix ? prefix + '.' : '') + name; |
402 | + if (fullname.toLowerCase().indexOf(object) > -1) { |
403 | + var match = objects[prefix][name]; |
404 | + var objname = objnames[match[1]][2]; |
405 | + var title = titles[match[0]]; |
406 | + // If more than one term searched for, we require other words to be |
407 | + // found in the name/title/description |
408 | + if (otherterms.length > 0) { |
409 | + var haystack = (prefix + ' ' + name + ' ' + |
410 | + objname + ' ' + title).toLowerCase(); |
411 | + var allfound = true; |
412 | + for (var i = 0; i < otherterms.length; i++) { |
413 | + if (haystack.indexOf(otherterms[i]) == -1) { |
414 | + allfound = false; |
415 | + break; |
416 | + } |
417 | + } |
418 | + if (!allfound) { |
419 | + continue; |
420 | + } |
421 | + } |
422 | + var descr = objname + _(', in ') + title; |
423 | + anchor = match[3]; |
424 | + if (anchor == '') |
425 | + anchor = fullname; |
426 | + else if (anchor == '-') |
427 | + anchor = objnames[match[1]][1] + '-' + fullname; |
428 | + result = [filenames[match[0]], fullname, '#'+anchor, descr]; |
429 | + switch (match[2]) { |
430 | + case 1: objectResults.push(result); break; |
431 | + case 0: importantResults.push(result); break; |
432 | + case 2: unimportantResults.push(result); break; |
433 | + } |
434 | + } |
435 | + } |
436 | + } |
437 | + |
438 | + // sort results descending |
439 | + objectResults.sort(function(a, b) { |
440 | + return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0); |
441 | + }); |
442 | + |
443 | + importantResults.sort(function(a, b) { |
444 | + return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0); |
445 | + }); |
446 | + |
447 | + unimportantResults.sort(function(a, b) { |
448 | + return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0); |
449 | + }); |
450 | + |
451 | + return [importantResults, objectResults, unimportantResults] |
452 | + } |
453 | +} |
454 | + |
455 | +$(document).ready(function() { |
456 | + Search.init(); |
457 | +}); |
458 | |
459 | === modified file 'debian/changelog' |
460 | --- debian/changelog 2013-02-16 14:51:12 +0000 |
461 | +++ debian/changelog 2013-03-31 15:07:21 +0000 |
462 | @@ -1,3 +1,9 @@ |
463 | +sphinx (1.1.3+dfsg-7ubuntu2) raring; urgency=low |
464 | + |
465 | + * Backport upstream patch to fix broken search in WebKit-based browsers. |
466 | + |
467 | + -- Dmitry Shachnev <mitya57@ubuntu.com> Sat, 30 Mar 2013 15:49:49 +0400 |
468 | + |
469 | sphinx (1.1.3+dfsg-7ubuntu1) raring; urgency=low |
470 | |
471 | * Merge with Debian experimental. Remaining Ubuntu changes: |
472 | |
473 | === added file 'debian/patches/fix_search_in_webkit.diff' |
474 | --- debian/patches/fix_search_in_webkit.diff 1970-01-01 00:00:00 +0000 |
475 | +++ debian/patches/fix_search_in_webkit.diff 2013-03-31 15:07:21 +0000 |
476 | @@ -0,0 +1,64 @@ |
477 | +Description: fix search in WebKit-based browsers |
478 | +Origin: upstream, https://bitbucket.org/birkenfeld/sphinx/commits/81e4a8f0cb |
479 | +Bug: https://bitbucket.org/birkenfeld/sphinx/issue/723/ |
480 | +Last-Update: 2013-03-31 |
481 | + |
482 | +--- a/sphinx/themes/basic/search.html |
483 | ++++ b/sphinx/themes/basic/search.html |
484 | +@@ -14,6 +14,9 @@ |
485 | + <script type="text/javascript"> |
486 | + jQuery(function() { Search.loadIndex("{{ pathto('searchindex.js', 1) }}"); }); |
487 | + </script> |
488 | ++ {# this is used when loading the search index using $.ajax fails, |
489 | ++ such as on Chrome for documents on localhost #} |
490 | ++ <script type="text/javascript" id="searchindexloader"></script> |
491 | + {{ super() }} |
492 | + {% endblock %} |
493 | + {% block body %} |
494 | +--- a/sphinx/themes/basic/static/searchtools.js_t |
495 | ++++ b/sphinx/themes/basic/static/searchtools.js_t |
496 | +@@ -57,8 +57,13 @@ |
497 | + }, |
498 | + |
499 | + loadIndex : function(url) { |
500 | +- $.ajax({type: "GET", url: url, data: null, success: null, |
501 | +- dataType: "script", cache: true}); |
502 | ++ $.ajax({type: "GET", url: url, data: null, |
503 | ++ dataType: "script", cache: true, |
504 | ++ complete: function(jqxhr, textstatus) { |
505 | ++ if (textstatus != "success") { |
506 | ++ document.getElementById("searchindexloader").src = url; |
507 | ++ } |
508 | ++ }}); |
509 | + }, |
510 | + |
511 | + setIndex : function(index) { |
512 | +@@ -275,16 +280,18 @@ |
513 | + displayNextItem(); |
514 | + }); |
515 | + } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) { |
516 | +- $.get(DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + |
517 | +- item[0] + '.txt', function(data) { |
518 | +- if (data != '') { |
519 | +- listItem.append($.makeSearchSummary(data, searchterms, hlterms)); |
520 | +- Search.output.append(listItem); |
521 | +- } |
522 | +- listItem.slideDown(5, function() { |
523 | +- displayNextItem(); |
524 | +- }); |
525 | +- }, "text"); |
526 | ++ $.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[0] + '.txt', |
527 | ++ dataType: "text", |
528 | ++ complete: function(jqxhr, textstatus) { |
529 | ++ var data = jqxhr.responseText; |
530 | ++ if (data !== '') { |
531 | ++ listItem.append($.makeSearchSummary(data, searchterms, hlterms)); |
532 | ++ } |
533 | ++ Search.output.append(listItem); |
534 | ++ listItem.slideDown(5, function() { |
535 | ++ displayNextItem(); |
536 | ++ }); |
537 | ++ }}); |
538 | + } else { |
539 | + // no source available, just display title |
540 | + Search.output.append(listItem); |
541 | |
542 | === modified file 'debian/patches/series' |
543 | --- debian/patches/series 2013-02-16 14:51:12 +0000 |
544 | +++ debian/patches/series 2013-03-31 15:07:21 +0000 |
545 | @@ -15,3 +15,4 @@ |
546 | manpage_writer_docutils_0.10_api.diff |
547 | parallel_2to3.diff |
548 | fix_literal_block_warning.diff |
549 | +fix_search_in_webkit.diff |
550 | |
551 | === modified file 'debian/rules' |
552 | --- debian/rules 2013-02-16 14:51:12 +0000 |
553 | +++ debian/rules 2013-03-31 15:07:21 +0000 |
554 | @@ -44,8 +44,8 @@ |
555 | find sphinx/locale/ -name '*.po' | sed -e 's/[.]po$$//' \ |
556 | | xargs -t -I {} msgfmt $(msgfmt_options) {}.po -o {}.mo |
557 | ifeq "$(filter nocheck,$(DEB_BUILD_OPTIONS))" "" |
558 | - $(python_all) tests/run.py --verbose --no-skip |
559 | - $(python3_all) tests/run.py --verbose |
560 | + #$(python_all) tests/run.py --verbose --no-skip |
561 | + #$(python3_all) tests/run.py --verbose |
562 | cd build/py3/ && rm -rf tests/ sphinx/pycode/Grammar.pickle |
563 | xvfb-run -a ./debian/jstest/run-tests build/html/ |
564 | endif |
565 | |
566 | === modified file 'sphinx/themes/basic/search.html' |
567 | --- sphinx/themes/basic/search.html 2011-01-08 15:54:59 +0000 |
568 | +++ sphinx/themes/basic/search.html 2013-03-31 15:07:21 +0000 |
569 | @@ -14,6 +14,9 @@ |
570 | <script type="text/javascript"> |
571 | jQuery(function() { Search.loadIndex("{{ pathto('searchindex.js', 1) }}"); }); |
572 | </script> |
573 | + {# this is used when loading the search index using $.ajax fails, |
574 | + such as on Chrome for documents on localhost #} |
575 | + <script type="text/javascript" id="searchindexloader"></script> |
576 | {{ super() }} |
577 | {% endblock %} |
578 | {% block body %} |
579 | |
580 | === modified file 'sphinx/themes/basic/static/searchtools.js_t' |
581 | --- sphinx/themes/basic/static/searchtools.js_t 2011-11-20 15:56:50 +0000 |
582 | +++ sphinx/themes/basic/static/searchtools.js_t 2013-03-31 15:07:21 +0000 |
583 | @@ -57,8 +57,13 @@ |
584 | }, |
585 | |
586 | loadIndex : function(url) { |
587 | - $.ajax({type: "GET", url: url, data: null, success: null, |
588 | - dataType: "script", cache: true}); |
589 | + $.ajax({type: "GET", url: url, data: null, |
590 | + dataType: "script", cache: true, |
591 | + complete: function(jqxhr, textstatus) { |
592 | + if (textstatus != "success") { |
593 | + document.getElementById("searchindexloader").src = url; |
594 | + } |
595 | + }}); |
596 | }, |
597 | |
598 | setIndex : function(index) { |
599 | @@ -275,16 +280,18 @@ |
600 | displayNextItem(); |
601 | }); |
602 | } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) { |
603 | - $.get(DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + |
604 | - item[0] + '.txt', function(data) { |
605 | - if (data != '') { |
606 | - listItem.append($.makeSearchSummary(data, searchterms, hlterms)); |
607 | - Search.output.append(listItem); |
608 | - } |
609 | - listItem.slideDown(5, function() { |
610 | - displayNextItem(); |
611 | - }); |
612 | - }, "text"); |
613 | + $.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[0] + '.txt', |
614 | + dataType: "text", |
615 | + complete: function(jqxhr, textstatus) { |
616 | + var data = jqxhr.responseText; |
617 | + if (data !== '') { |
618 | + listItem.append($.makeSearchSummary(data, searchterms, hlterms)); |
619 | + } |
620 | + Search.output.append(listItem); |
621 | + listItem.slideDown(5, function() { |
622 | + displayNextItem(); |
623 | + }); |
624 | + }}); |
625 | } else { |
626 | // no source available, just display title |
627 | Search.output.append(listItem); |
Thanks for your work on this. The change looks fine.
I'm just not 100% sure about commenting out the test suite. Is this necessary or just an oversight?