From af15f2c4a192dea02aab9e519defc68c71763ec4 Mon Sep 17 00:00:00 2001 From: yvesf Date: Mon, 22 Nov 2010 14:34:55 +0100 Subject: jquery ui --- web.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'web.py') 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//", methods=["GET"]) -def json_excerpt(docnum, term): +@app.route("/excerpt//", 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 ) -- cgit v1.2.1