From 3f1d8ce882e1a9467f94be19288536f9d2f69d47 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Wed, 21 Jan 2015 15:01:39 +0100 Subject: [PATCH 1/7] document 401 --- app/annotation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/annotation.py b/app/annotation.py index f608146..ed2730b 100644 --- a/app/annotation.py +++ b/app/annotation.py @@ -36,6 +36,7 @@ def new(): :>json int id: The new ID. :status 400: Document ID does not exist. + :status 401: Unauthorized """ doc = coerce_to(int, request.form['doc']) page = coerce_to(int, request.form['page']) From b78a23995fd718eb5568f0944d4fb4df06b726c9 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Wed, 21 Jan 2015 15:02:23 +0100 Subject: [PATCH 2/7] Add 'route' command to manager --- manage.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/manage.py b/manage.py index 636710d..f3b58bc 100644 --- a/manage.py +++ b/manage.py @@ -10,6 +10,7 @@ from random import choice import faker +from flask import url_for from flask.ext.assets import ManageAssets from flask.ext.migrate import MigrateCommand from flask.ext.migrate import stamp @@ -111,6 +112,24 @@ def resetpassword(username): db.session.commit() print password + @manager.command + def routes(): + import urllib + output = [] + for rule in manager.app.url_map.iter_rules(): + + options = {} + for arg in rule.arguments: + options[arg] = "[{0}]".format(arg) + + methods = ','.join(rule.methods) + url = url_for(rule.endpoint, **options) + line = "{:40s} {:25s} {}".format(rule.endpoint, methods, url) + output.append(urllib.unquote(line)) + + for line in sorted(output): + print line + manager.run() if __name__ == '__main__': From 2e4ef4093087eff25aecb69455e3785d7c01059a Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Wed, 21 Jan 2015 16:00:54 +0100 Subject: [PATCH 3/7] extract glyph_button --- templates/macros.html | 7 +++++++ templates/view.html | 21 +++++---------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/templates/macros.html b/templates/macros.html index 6e175a1..d97500d 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -78,3 +78,10 @@ {%- endmacro %} + +{% macro glyph_button(content, id, icon) %} + +{% endmacro %} diff --git a/templates/view.html b/templates/view.html index 4199131..9b90483 100644 --- a/templates/view.html +++ b/templates/view.html @@ -1,4 +1,5 @@ {% from 'macros.html' import glyphicon %} +{% from 'macros.html' import glyph_button %} {% from 'macros.html' import js_bool %} {% from 'macros.html' import render_share_form %} {% from 'macros.html' import upload_form %} @@ -50,27 +51,15 @@

{{doc.title}}

{% endif %} -

{{ glyphicon('comment') }} Comments

+ {{ glyph_title ('Comments', 'comment') }}
{{form_comm.hidden_tag()}}

{{form_comm.comment()}}

From 848a9fc2b7ade20a10c9c73868de72cd0fbef955 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Wed, 21 Jan 2015 16:10:01 +0100 Subject: [PATCH 6/7] Add download link Closes #70 --- templates/view.html | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/view.html b/templates/view.html index 6083488..ec43ad9 100644 --- a/templates/view.html +++ b/templates/view.html @@ -52,6 +52,7 @@

{{doc.title}}

{{ glyph_button('Full screen', 'fullscreen_button', 'fullscreen') }} {{ glyph_button('List mode', 'listmode_button', 'list') }} {{ glyph_button('Document mode', 'docmode_button', 'file') }} + {{ glyph_link('Download', url_for('document.raw', id=doc.id), 'download') }} {% if can_edit %} {{ glyph_link('Edit', url_for('document.edit', id=doc.id), 'pencil') }} {{ glyph_button('Generate a review link', 'share_link', 'share') }} From 5f5aaec28638c2e6648c26dd0902cd78c4e7b580 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Wed, 21 Jan 2015 16:56:08 +0100 Subject: [PATCH 7/7] Add thumbnails in list view Closes #74 --- static/coffee/page.coffee | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/static/coffee/page.coffee b/static/coffee/page.coffee index a182b29..fd5aade 100644 --- a/static/coffee/page.coffee +++ b/static/coffee/page.coffee @@ -11,6 +11,7 @@ class Page height = viewport.height canvas.width = width canvas.height = height + @canvas = canvas else if params.width? and params.height? width = params.width height = params.height @@ -26,6 +27,7 @@ class Page params.page.render canvasContext: canvas.getContext '2d' viewport: viewport + .then @updatePagePreview @readOnly = false if params.readOnly? @readOnly = params.readOnly @@ -47,11 +49,25 @@ class Page for ann in anns @addAnnotation ann.text, ann.id, ann, ann.state + updatePagePreview: => + if @previewCtx? + @previewCtx.drawImage(@canvas, 0, 0) + addAnnotation: (text, id, geom, state) -> ann = new Annotation @$textLayerDiv, @docid, @i, text, id, geom, state, @readOnly $row = $('') - $row.append($('').text(@i)) + $previewCanvas = $('').attr + width: @canvas.width + height: @canvas.height + .css + width: "#{@canvas.width / 10}px" + height: "#{@canvas.height / 10}px" + + @previewCtx = $previewCanvas[0].getContext('2d') + + $previewCell = $('').append($previewCanvas).append(@i) + $row.append $previewCell $row.append($('').text(text)) annotation_state = (st) ->