Browse Source

Can show documents by path; show folders in navbar; better show document

master
Dashie der otter 5 years ago
parent
commit
280fc5770e
5 changed files with 62 additions and 19 deletions
  1. +10
    -1
      app.py
  2. +6
    -1
      static/stylesheets/sb-admin.css
  3. +25
    -0
      templates/documents/documents_path.jinja2
  4. +13
    -6
      templates/documents/show.jinja2
  5. +8
    -11
      templates/layout.jinja2

+ 10
- 1
app.py View File

@@ -59,10 +59,12 @@ class DocumentUploadForm(Form):
def global_vars():
glob = {
'files_count': File.query.count(),
'documents_count': Document.query.count()
'documents_count': Document.query.count(),
'paths_tree': db.session.query(File.path).distinct().order_by(File.path).all()
}
return glob


# Views
@app.route('/', methods=['GET'])
@app.route('/documents', methods=['GET'])
@@ -111,6 +113,13 @@ def document_serve(size, hashi):
return send_from_directory(fdir, file)


@app.route('/document/path/<path:path>')
@app.route('/document/page/<int:page>/path/<path:path>')
@login_required
def document_path(path, page=1):
f = File.query.filter_by(path=path).paginate(page=page, per_page=app.config['YAGED_PAGINATION_NB'])
return render_template('documents/documents_path.jinja2', documents=f, cur_path=path)

# Other commands
@manager.command
def routes():


+ 6
- 1
static/stylesheets/sb-admin.css View File

@@ -329,4 +329,9 @@ table.dataTable thead .sorting:after {
.show-grid {
margin: 15px 0;
}
}
.nopadding {
padding-top: 0px !important;
padding-bottom: 0px !important;
}

+ 25
- 0
templates/documents/documents_path.jinja2 View File

@@ -0,0 +1,25 @@
{% extends "layout.jinja2" %}
{% from "_docs_list.jinja2" import documents_list %}
{% import '_helpers.jinja2' as helpers %}

{% block body %}
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Documents from path <small>{{ cur_path }}</small></h1>
<div class="ẗable-responsive">
{{ documents_list(documents.items) }}
</div>
{{ helpers.paginate(documents) }}
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
{% endblock %}

{% block jslol %}
<script type="text/javascript">
$(function () {
$('[data-toggle="popover"]').popover()
})
</script>
{% endblock %}

+ 13
- 6
templates/documents/show.jinja2 View File

@@ -5,7 +5,11 @@
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">#{{ document.id }} &raquo; {{ document.title }}</h1>
</div>
</div>

<div class="row">
<div class="col-lg-9">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#view" aria-controls="view" role="tab"
data-toggle="tab">View</a></li>
@@ -15,11 +19,7 @@

<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="view">
{{ document.title }}<br/>
{{ document.description }}<br/>
Filename: {{ document.filename }}<br/>
Size: {{ document.bytes_size }} bytes<br/>

<br />
{% if document.mimetype=="image/jpeg" %}
<a href="{{ url_for('document_serve', size='full', hashi=document.hash) }}" target="_blank">
<img src="{{ url_for('document_serve', size="preview", hashi=document.hash) }}"/>
@@ -30,11 +30,18 @@
</div>

<div role="tabpanel" class="tab-pane" id="text">
<br/>
<pre>{{ document.content|e }}</pre>
</div>
</div>
</div>
<!-- /.col-lg-12 -->
<div class="col-lg-3">
{{ document.title }}<br/>
{% if document.description %}{{ document.description }}<br/>{% endif %}
Filename: {{ document.filename }}<br/>
Size: {{ document.bytes_size }} bytes<br/>

</div>
</div>
<!-- /.row -->
{% endblock %}


+ 8
- 11
templates/layout.jinja2 View File

@@ -84,18 +84,15 @@
<li>
<a href="{# url_for('documents_new') #}"><i class="fa fa-file-text fa-fw"></i> Upload new document</a>
</li>
<li>
<a href="#"><i class="fa fa-bar-chart-o fa-fw"></i> Whatever<span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li>
<a href="flot.html">whatever</a>
</li>
<li>
<a href="morris.html">bleh</a>
</li>
</ul>
<li><br/></li>
{% for p in paths_tree %}
<li>
<a href="{{ url_for('document_path', path=p[0]) }}" class="nopadding">
<i class="fa fa-folder"></i> {{ p[0] }}
</a>
</li>
{% endfor %}
<!-- /.nav-second-level -->
</li>
</ul>
<!-- /#side-menu -->
</div>


Loading…
Cancel
Save