summaryrefslogtreecommitdiff
path: root/web.py
diff options
context:
space:
mode:
authoryvesf <yvesf-git@xapek.org>2010-11-22 14:34:55 +0100
committeryvesf <yvesf-git@xapek.org>2010-11-22 14:34:55 +0100
commitaf15f2c4a192dea02aab9e519defc68c71763ec4 (patch)
tree56edbb3964a98d4b172dcf3a1e5c10c9a5323abc /web.py
parentf9e1648d011302bc0055737034b01774c58f584a (diff)
downloadbooksearch-af15f2c4a192dea02aab9e519defc68c71763ec4.tar.gz
booksearch-af15f2c4a192dea02aab9e519defc68c71763ec4.zip
jquery ui
Diffstat (limited to 'web.py')
-rw-r--r--web.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/web.py b/web.py
index edb4a34..985b293 100644
--- a/web.py
+++ b/web.py
@@ -47,7 +47,7 @@ def pdf_to_image(filepath, page):
out = pyPdf.PdfFileWriter()
out.addPage(page)
out.write(pdffile)
- process = subprocess.Popen(["/usr/bin/convert", "pdf:-", "jpeg:-"],
+ process = subprocess.Popen(["/usr/bin/convert", "-resize", "260x", "pdf:-", "jpeg:-"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
return werkzeug.Response(generator(process,pdffile), mimetype="image/jpeg")
@@ -85,11 +85,11 @@ def do_page_file(docnum):
class MyHtmlFormatter(highlight.HtmlFormatter):
def _format_fragment(self, text, fragment, seen):
- text = unicode( flask.Markup.escape(text) )
+# text = unicode( flask.Markup.escape(text) )
return highlight.HtmlFormatter._format_fragment(self, text, fragment, seen)
-@app.route("/json/excerpt/<int:docnum>/<path:term>", methods=["GET"])
-def json_excerpt(docnum, term):
+@app.route("/excerpt/<int:docnum>/<path:term>", methods=["GET"])
+def excerpt(docnum, term):
def generator(q):
for result in searcher.search(q, limit=1, sortedby="pagenumber"):
terms = [ text for fieldname, text in q.all_terms()
@@ -97,7 +97,7 @@ def json_excerpt(docnum, term):
excerpt = highlight.highlight(result.get("content"),
terms,
analysis.FancyAnalyzer(),
- highlight.SimpleFragmenter(),
+ highlight.SentenceFragmenter(),
MyHtmlFormatter())
yield json.dumps( { 'pagenumber':result.get("pagenumber"),
@@ -111,7 +111,7 @@ def json_excerpt(docnum, term):
if fieldname == "content" ]
excerpt = highlight.highlight(document['content'],
terms,
- analysis.FancyAnalyzer(),
+ analysis.StandardAnalyzer(),
highlight.SimpleFragmenter(),
MyHtmlFormatter())
return unicode( excerpt )