better handling for enter

This commit is contained in:
Edward Betts 2017-02-20 20:03:36 +00:00
parent ca92fc8046
commit d652208e94
2 changed files with 8 additions and 4 deletions

View file

@ -8,9 +8,9 @@ div#text { font-family: Courier; }
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<h1>{{ title }} <h1>{{ title }}
{% if doc.user == current_user %} {# {% if doc.user == current_user %} #}
<a href="{{ doc.edit_url }}" class="btn btn-default">edit</a> <a href="{{ doc.edit_url }}" class="btn btn-default">edit</a>
{% endif %} {# {% endif %} #}
{% if doc.type == 'xanadoc' %} {% if doc.type == 'xanadoc' %}
<a href="{{ doc.url }}" class="btn btn-default">fulfil</a> <a href="{{ doc.url }}" class="btn btn-default">fulfil</a>
{% endif %} {% endif %}
@ -23,7 +23,9 @@ div#text { font-family: Courier; }
<p data-start="{{ start }}"> <p data-start="{{ start }}">
{% for i in line %} {% for i in line %}
{%- if i.highlight -%} {%- if i.highlight -%}
<span class="highlight">{{- i.highlight -}}</span> {% if i.highlight != '\n' and i.highlight != '\r\n' %}
<span class="highlight">{{- i.highlight -}}</span>
{% endif %}
{%- else -%} {%- else -%}
{{- i.text -}} {{- i.text -}}
{%- endif -%} {%- endif -%}
@ -32,6 +34,8 @@ div#text { font-family: Courier; }
{%- endfor -%} {%- endfor -%}
{% else %} {% else %}
{%- for start, line in iter_lines(doc.text) if line -%} {%- for start, line in iter_lines(doc.text) if line -%}
{# <p data-start="{{ start }}">{% if line != "\n" and line != "\r\n" %}{{ line }}{% else %}&nbsp;{% endif
%}</p>#}
<p data-start="{{ start }}">{{ line }}</p> <p data-start="{{ start }}">{{ line }}</p>
{%- endfor -%} {%- endfor -%}
{% endif %} {% endif %}

View file

@ -166,7 +166,7 @@ def view_item(username, hashid, raw=False):
@bp.route('/<username>/<hashid>/edit', methods=['GET', 'POST']) @bp.route('/<username>/<hashid>/edit', methods=['GET', 'POST'])
def edit_item(username, hashid): def edit_item(username, hashid):
obj = get_item(current_user.username, hashid) obj = get_item(username, hashid)
form = SourceDocForm(obj=obj) form = SourceDocForm(obj=obj)
if form.validate_on_submit(): if form.validate_on_submit():
form.populate_obj(obj) form.populate_obj(obj)