Skip to content

Commit

Permalink
Merge branch 'goodies'
Browse files Browse the repository at this point in the history
  • Loading branch information
emillon committed Jan 21, 2015
2 parents 67a4101 + 5f5aaec commit 94e7307
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 29 deletions.
1 change: 1 addition & 0 deletions app/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
19 changes: 19 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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__':
Expand Down
18 changes: 17 additions & 1 deletion static/coffee/page.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 = $('<tr>')
$row.append($('<td>').text(@i))
$previewCanvas = $('<canvas>').attr
width: @canvas.width
height: @canvas.height
.css
width: "#{@canvas.width / 10}px"
height: "#{@canvas.height / 10}px"

@previewCtx = $previewCanvas[0].getContext('2d')

$previewCell = $('<td>').append($previewCanvas).append(@i)
$row.append $previewCell
$row.append($('<td>').text(text))

annotation_state = (st) ->
Expand Down
18 changes: 18 additions & 0 deletions templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,21 @@
</div>
</div>
{%- endmacro %}

{% macro glyph_button(content, id, icon) %}
<button id="{{ id }}" class="btn btn-default" style="text-align: left">
{{ glyphicon(icon) }}
{{ content }}
</button>
{% endmacro %}

{% macro glyph_link(content, href, icon) %}
<a href="{{ href }}" class="btn btn-default" style="text-align: left">
{{ glyphicon(icon) }}
{{ content }}
</a>
{% endmacro %}

{% macro glyph_title(content, icon) %}
<h3>{{ glyphicon(icon) }} {{ content }}</h3>
{% endmacro %}
41 changes: 13 additions & 28 deletions templates/view.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{% from 'macros.html' import glyphicon %}
{% from 'macros.html' import glyph_button %}
{% from 'macros.html' import glyph_link %}
{% from 'macros.html' import glyph_title %}
{% from 'macros.html' import js_bool %}
{% from 'macros.html' import render_share_form %}
{% from 'macros.html' import upload_form %}
Expand Down Expand Up @@ -41,48 +43,31 @@ <h1>{{doc.title}}</h1>
<div class="col-md-1 col-md-offset-1">
<div id="exitfullscreen">
<div class="list-group">
<a id="fullscreen_button_exit" href="#" class="list-group-item">
{{ glyphicon('resize-small') }}
Exit fullscreen
</a>
{{ glyph_button('Exit fullscreen', 'fullscreen_button_exit', 'resize-small') }}
</div>
</div>
<div id="subnav" data-spy="affix">

<div class="btn-group-vertical" role="group">
<button id="fullscreen_button" class="btn btn-default" style="text-align: left">
{{ glyphicon('fullscreen') }}
Full screen
</button>
<button id="listmode_button" class="btn btn-default" style="text-align: left">
{{ glyphicon('list') }}
List mode
</button>
<button id="docmode_button" class="btn btn-default" style="text-align: left">
{{ glyphicon('file') }}
Document mode
</button>
{{ 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 %}
<a href="{{url_for('document.edit', id=doc.id)}}" class="btn btn-default" style="text-align: left">
{{ glyphicon('pencil') }}
Edit
</a>
<button id="share_link" class="btn btn-default" style="text-align: left">
{{ glyphicon('share') }}
Generate a review link
</button>
{{ glyph_link('Edit', url_for('document.edit', id=doc.id), 'pencil') }}
{{ glyph_button('Generate a review link', 'share_link', 'share') }}
{% endif %}
</div>

<h3>{{ glyphicon('eye-open') }} View</h3>
{{ glyph_title('View', 'eye-open') }}

<div class="btn-group-vertical">
<button class="view-states-btn btn btn-default" data-view="nothing">Nothing</button>
<button class="view-states-btn btn btn-default" data-view="only-open">Only open</button>
<button class="view-states-btn btn btn-default" data-view="everything">Everything</button>
</div>

<h3>{{ glyphicon('pencil') }} History</h3>
{{ glyph_title('History', 'pencil') }}

<p>
<a href="{{url_for('.view_revisions', id=doc.id)}}">Revisions</a>
Expand All @@ -101,7 +86,7 @@ <h3>{{ glyphicon('pencil') }} History</h3>
</div>
{% endif %}

<h3>{{ glyphicon('comment') }} Comments</h3>
{{ glyph_title ('Comments', 'comment') }}
<form method="POST" action="{{ url_for('comment.new') }}" id="post_comment_form">
{{form_comm.hidden_tag()}}
<p>{{form_comm.comment()}}</p>
Expand Down

0 comments on commit 94e7307

Please sign in to comment.