summaryrefslogtreecommitdiff
path: root/web.py
diff options
context:
space:
mode:
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 )