summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/web.py b/web.py
index a8dcbca..858019d 100644
--- a/web.py
+++ b/web.py
@@ -41,7 +41,7 @@ def pdf_to_image(filepath, page):
if stdout:
yield stdout
pdffile = StringIO()
- page = pyPdf.PdfFileReader(file(filepath, 'r')).getPage(page)
+ page = pyPdf.PdfFileReader(file(filepath, 'r')).getPage(page-1)
out = pyPdf.PdfFileWriter()
out.addPage(page)
out.write(pdffile)
@@ -69,7 +69,7 @@ def do_page_file(docnum):
filepath = document['path']
page = document['pagenumber']
inputfile = pyPdf.PdfFileReader(file(filepath, 'r'))
- pdfpage = inputfile.getPage(page)
+ pdfpage = inputfile.getPage(page-1)
outbuf = StringIO()
outfile = pyPdf.PdfFileWriter()
outfile.addPage(pdfpage)
@@ -77,13 +77,13 @@ def do_page_file(docnum):
outbuf.seek(0)
r = werkzeug.Response(outbuf, mimetype="application/pdf")
client_filename = os.path.basename(filepath)[:-3]
- client_filename += u".Page-{0}".format(page)
+ client_filename += u".Page-{0}.pdf".format(page)
r.headers.add('Content-Disposition', 'attachment', filename=client_filename)
return r
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("/excerpt/<int:docnum>/<path:term>", methods=["GET"])
@@ -114,12 +114,11 @@ def excerpt(docnum, term):
MyHtmlFormatter())
return unicode( excerpt )
-@app.route("/search/skip=<int:skip>/<path:term>",methods=["GET"])
@app.route("/search/<path:term>",methods=["GET"])
@app.route("/search/", methods=["GET"])
-def do_search(skip=0,term=None):
- if skip == 0 and not term:
- return flask.render_template('search.html', objects=[], term="", skip=0)
+def do_search(term=None):
+ if not term:
+ return flask.render_template('search.html', objects=[], term="")
searcher = index_book.searcher()
query = QueryParser("content").parse(term)