switch layout to use tabs

This commit is contained in:
Edward Betts 2017-04-07 13:20:59 +01:00
parent 7a112ab1d4
commit 956dbadabd
3 changed files with 56 additions and 22 deletions

View file

@ -1,17 +1,37 @@
{% extends "base.html" %}
{% from "form/controls.html" import render_field %}
{% set title="edit " + doc.title() %}
{% block title %}edit {{ doc.title() }}{% endblock %}
{% block content %}
{% set action=doc.edit_url %}
{% set label="save" %}
{% set fields %}
{#
{{ render_field(form.filename) }}
{{ render_field(form.db_price_per_character) }}
{{ render_field(form.db_document_price) }}
#}
{{ render_field(form.text, rows=20) }}
{% endset %}
{% include "form/simple.html" %}
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link" href="{{ doc.url }}">View</a>
</li>
{% if doc.type == 'xanadoc' %}
<li class="nav-item">
<a class="nav-link" href="{{ doc.url }}/fulfil">Fulfil</a>
</li>
{% endif %}
<li class="nav-item">
<a class="nav-link" href="#">History</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="{{ doc.edit_url }}">Edit</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ request.url }}/raw">Raw</a>
</li>
</ul>
<h1 class="mt-3">{{ doc.title() }}</h1>
{% include "form/main.html" %}
{% endblock %}

View file

@ -3,16 +3,28 @@
{% block title %}{{ doc.title() }}{% endblock %}
{% block content %}
<h1>{{ self.title() }}
{# {% if doc.user == current_user %} #}
<a href="{{ doc.edit_url }}" class="btn btn-primary">edit</a>
{# {% endif %} #}
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" href="{{ doc.url }}">View</a>
</li>
{% if doc.type == 'xanadoc' %}
<a href="{{ doc.url }}" class="btn btn-primary">fulfil</a>
<li class="nav-item">
<a class="nav-link" href="{{ doc.url }}/fulfil">Fulfil</a>
</li>
{% endif %}
<a href="{{ request.url }}/raw" class="btn btn-primary">raw</a>
</h1>
<p><a href="{{ url_for('.home') }}">back to index</a></p>
<li class="nav-item">
<a class="nav-link" href="#">History</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ doc.edit_url }}">Edit</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ request.url }}/raw">Raw</a>
</li>
</ul>
<h1 class="mt-3">{{ self.title() }}</h1>
<div id="text">
{% if span_length %}

View file

@ -174,11 +174,6 @@ def get_item(username, hashid):
doc = None
return doc if doc else abort(404)
def view_xanadoc(item):
return render_template('view/xanadoc.html',
item=item,
doc=fulfil_edl_with_sources(item.text))
@bp.route('/<username>/<hashid>/edl')
def view_edl(username, hashid):
item = get_item(username, hashid)
@ -194,6 +189,15 @@ def view_edl(username, hashid):
def view_item_raw(username, hashid):
return view_item(username, hashid, raw=True)
@bp.route('/<username>/<hashid>/fulfil')
def fulfil(username, hashid):
item = get_item(username, hashid)
if item.type != 'xanadoc':
return abort(404)
return render_template('view/xanadoc.html',
item=item,
doc=fulfil_edl_with_sources(item.text))
@bp.route('/<username>/<hashid>')
def view_item(username, hashid, raw=False):
if ',' in hashid:
@ -207,8 +211,6 @@ def view_item(username, hashid, raw=False):
item = get_item(username, hashid)
if raw:
return Response(item.text, mimetype='text/plain')
if item.type == 'xanadoc':
return view_xanadoc(item)
return render_template('view.html',
doc=item,