From 858107a929e826681629f34b384926488aeb1cd1 Mon Sep 17 00:00:00 2001 From: yvesf Date: Mon, 22 Nov 2010 19:54:33 +0100 Subject: scroll preview page to page-match; sort matches by pagenumber --- static/style.css | 10 ++++++++-- templates/search.html | 25 +++++++++++++++---------- web.py | 7 +++---- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/static/style.css b/static/style.css index dec9982..0a036ed 100644 --- a/static/style.css +++ b/static/style.css @@ -22,11 +22,17 @@ div#footer { div.book { } -div.book img.frontpage { +div.book div.c_frontpage { width: 260px; height: 390px; - border: 1px solid gray; float: left; + border: 1px solid gray; +} + +div.book div.c_frontpage img.frontpage { + border: 1px solid black; + overflow-x: hidden; + overflow-y: visible; } div.book div.c_matches, diff --git a/templates/search.html b/templates/search.html index d4e8590..b99c053 100644 --- a/templates/search.html +++ b/templates/search.html @@ -1,31 +1,34 @@ {% extends "_base.html" %} {% block title %} - {% if term != "" %} - {{ term }} - {% else %} - Start a new Search - {% endif %} + {% if term: %}{{ term }}{% else %}Start a new Search{% endif %} {% endblock %} {% block searchValue %}{{ term }}{% endblock %} {% block javascript %} @@ -36,7 +39,9 @@ {% for docnum, matches in matches.items() %}

book: {{ docnum }}

- +
+ +
filename, creationtime, indexed-time, +any pdf metadata
diff --git a/web.py b/web.py index 0fc770d..a8dcbca 100644 --- a/web.py +++ b/web.py @@ -6,7 +6,6 @@ from StringIO import StringIO from whoosh.index import open_dir from whoosh.qparser import QueryParser import whoosh.searching as searching -import whoosh.fields as fields import whoosh.analysis as analysis import whoosh.highlight as highlight import whoosh.query as query @@ -95,8 +94,8 @@ def excerpt(docnum, term): if fieldname == "content" ] excerpt = highlight.highlight(result.get("content"), terms, - analysis.FancyAnalyzer(), - highlight.SentenceFragmenter(), + analysis.StandardAnalyzer(), + highlight.ContextFragmenter(terms, maxchars=400, charsbefore=40, charsafter=40), #highlight.SentenceFragmenter(maxchars=500), MyHtmlFormatter()) yield json.dumps( { 'pagenumber':result.get("pagenumber"), @@ -125,7 +124,7 @@ def do_search(skip=0,term=None): searcher = index_book.searcher() query = QueryParser("content").parse(term) facets = searching.Facets.from_field(searcher, "path") - results = searcher.search(query, limit=None) + results = searcher.search(query, limit=None, sortedby="pagenumber") categories = facets.categorize(results) searcher.close() -- cgit v1.2.1