From: Marcin Koziej Date: Fri, 27 Jan 2012 15:58:59 +0000 (+0100) Subject: add section numbers in search + fixes X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/bd1c5da61455bed0223f065bf3fa247a118e70c3?hp=--cc add section numbers in search + fixes --- bd1c5da61455bed0223f065bf3fa247a118e70c3 diff --git a/apps/search/index.py b/apps/search/index.py index 9617077d9..0f69d0725 100644 --- a/apps/search/index.py +++ b/apps/search/index.py @@ -276,7 +276,7 @@ class Index(BaseIndex): footnote_tags = ['pa', 'pt', 'pr', 'pe'] - skip_header_tags = ['autor_utworu', 'nazwa_utworu', 'dzielo_nadrzedne'] + skip_header_tags = ['autor_utworu', 'nazwa_utworu', 'dzielo_nadrzedne', '{http://www.w3.org/1999/02/22-rdf-syntax-ns#}RDF'] published_date_re = re.compile("([0-9]+)[\]. ]*$") @@ -426,9 +426,8 @@ class Index(BaseIndex): fragments = {} snippets = Snippets(book.id).open('w') - position = 0 try: - for header in list(master): + for header, position in zip(list(master), range(len(master))): if header.tag in self.skip_header_tags: continue @@ -441,15 +440,15 @@ class Index(BaseIndex): for start, end in walker(header, ignore_tags=self.ignore_content_tags): # handle footnotes - if start is not None and start.tag in self.footnote_tags: - footnote = ' '.join(start.itertext()) - elif end is not None and footnote is not None and end.tag in self.footnote_tags: - doc = add_part(snippets, header_index=position, header_type=header.tag, - content=footnote) + # if start is not None and start.tag in self.footnote_tags: + # footnote = ' '.join(start.itertext()) + # elif end is not None and footnote is not None and end.tag in self.footnote_tags: + # doc = add_part(snippets, header_index=position, header_type=header.tag, + # content=footnote) - self.index.addDocument(doc) + # self.index.addDocument(doc) - footnote = None + # footnote = None # handle fragments and themes. if start is not None and start.tag == 'begin': @@ -496,7 +495,6 @@ class Index(BaseIndex): content=fix_format(content)) self.index.addDocument(doc) - position += 1 finally: snippets.close() diff --git a/lib/librarian b/lib/librarian index b24b166cc..30d14a324 160000 --- a/lib/librarian +++ b/lib/librarian @@ -1 +1 @@ -Subproject commit b24b166cc4de6ba7e9b1559717bb5ff6e27bdacd +Subproject commit 30d14a324bb0e8a99c54cbceea01476e59748b33 diff --git a/wolnelektury/templates/catalogue/book_searched.html b/wolnelektury/templates/catalogue/book_searched.html index 935f332bd..8dfa053fd 100644 --- a/wolnelektury/templates/catalogue/book_searched.html +++ b/wolnelektury/templates/catalogue/book_searched.html @@ -8,7 +8,7 @@
{% for hit in hits %} {% if hit.snippets %} - + {% else %} {% if hit.fragment %}