Some tiny search fixes.

This commit is contained in:
Armin Ronacher 2008-09-24 08:39:33 +00:00
parent 6a7e6315c2
commit b21d71abfd
3 changed files with 9 additions and 6 deletions

View File

@ -704,7 +704,7 @@ class StandaloneHTMLBuilder(Builder):
self.indexer.load(f, self.indexer_format) self.indexer.load(f, self.indexer_format)
finally: finally:
f.close() f.close()
except (IOError, OSError, NotImplementedError): except (IOError, OSError, NotImplementedError, ValueError):
# we catch NotImplementedError here because if no simplejson # we catch NotImplementedError here because if no simplejson
# is installed the searchindex can't be loaded # is installed the searchindex can't be loaded
pass pass

View File

@ -100,10 +100,13 @@ class IndexBuilder(object):
if isinstance(format, basestring): if isinstance(format, basestring):
format = self.formats[format] format = self.formats[format]
frozen = format.load(stream) frozen = format.load(stream)
index2fn = frozen[0] # if an old index is present, we treat it as not existing.
self._titles = dict(zip(frozen[0], frozen[1])) if not isinstance(frozen, dict):
raise ValueError('old format')
index2fn = frozen['filenames']
self._titles = dict(zip(frozen['filenames'], frozen['titles']))
self._mapping = dict((k, set(index2fn[i] for i in v)) self._mapping = dict((k, set(index2fn[i] for i in v))
for (k, v) in frozen[2].iteritems()) for (k, v) in frozen['terms'].iteritems())
def dump(self, stream, format): def dump(self, stream, format):
"""Dump the frozen index to a stream.""" """Dump the frozen index to a stream."""

View File

@ -371,7 +371,7 @@ var Search = {
// if we have still a valid result we can add it // if we have still a valid result we can add it
// to the result list // to the result list
if (valid) if (valid)
results.push([filenames[file], titles[file], null]); regularResults.push([filenames[file], titles[file], null]);
} }
// delete unused variables in order to not waste // delete unused variables in order to not waste
@ -386,7 +386,7 @@ var Search = {
}); });
// combine both // combine both
results = results.concat(regularResults); results = regularResults.concat(results);
// print the results // print the results
var resultCount = results.length; var resultCount = results.length;