Add link type to facet browser.
This commit is contained in:
parent
bd9dd70877
commit
aa3b42c918
|
@ -1,11 +1,24 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% macro new_buttons() %}
|
||||||
|
<p>
|
||||||
|
<a href="{{ url_for('.new_sourcedoc') }}" class="btn btn-primary">new source document</a>
|
||||||
|
<a href="{{ url_for('.new_xanalink') }}" class="btn btn-primary">new xanalink</a>
|
||||||
|
<a href="{{ url_for('.new_xanadoc') }}" class="btn btn-primary">new xanadoc</a>
|
||||||
|
</p>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
{% block title %}perma.pub{% endblock %}
|
{% block title %}perma.pub{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{{ self.title() }}</h1>
|
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="row">
|
||||||
|
<div class="col-md-2"></div>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<h1>{{ self.title() }}</h1>
|
||||||
|
{{ new_buttons() }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
item type<br>
|
item type<br>
|
||||||
|
@ -13,15 +26,20 @@
|
||||||
<input type="checkbox" checked="checked" id="type_{{ item_type }}">
|
<input type="checkbox" checked="checked" id="type_{{ item_type }}">
|
||||||
<label for="type_{{ item_type }}"> {{ item_type }}</label><br/>
|
<label for="type_{{ item_type }}"> {{ item_type }}</label><br/>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
users<br>
|
user<br>
|
||||||
{% for item_user in users %}
|
{% for item_user in users %}
|
||||||
<input type="checkbox" checked="checked" id="user_{{ item_user }}">
|
<input type="checkbox" checked="checked" id="user_{{ item_user }}">
|
||||||
<label for="user_{{ item_user }}">{{ item_user }}</label><br/>
|
<label for="user_{{ item_user }}">{{ item_user }}</label><br/>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
link type<br>
|
||||||
|
{% for link_type in link_types %}
|
||||||
|
<input type="checkbox" checked="checked" id="link_type_{{ link_type }}">
|
||||||
|
<label for="link_type_{{ link_type }}">{{ link_type }}</label><br/>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
{% for doc in docs %}
|
{% for doc in docs %}
|
||||||
<div data-id="{{ doc.id }}" class="card border-primary w-50 my-2">
|
<div data-id="{{ doc.id }}" class="card border-primary my-2">
|
||||||
<h5 class="card-header"><a href="{{ doc.url }}">{{ doc.title() }}</a>
|
<h5 class="card-header"><a href="{{ doc.url }}">{{ doc.title() }}</a>
|
||||||
— {{ doc.user.username }} — {{ doc.created | datetime }}</h5>
|
— {{ doc.user.username }} — {{ doc.created | datetime }}</h5>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
@ -33,18 +51,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
{{ new_buttons() }}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>
|
</div>
|
||||||
<a href="{{ url_for('.new_sourcedoc') }}" class="btn btn-primary">new source document</a>
|
</div>
|
||||||
<a href="{{ url_for('.new_xanalink') }}" class="btn btn-primary">new xanalink</a>
|
|
||||||
<a href="{{ url_for('.new_xanadoc') }}" class="btn btn-primary">new xanadoc</a>
|
|
||||||
{#
|
|
||||||
<a href="#" class="btn btn-default">upload a source document</a>
|
|
||||||
#}
|
|
||||||
</p>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
|
@ -56,10 +66,13 @@
|
||||||
var element = $('[data-id=' + doc['id'] + ']');
|
var element = $('[data-id=' + doc['id'] + ']');
|
||||||
var show_type = document.getElementById('type_' + doc['type']).checked;
|
var show_type = document.getElementById('type_' + doc['type']).checked;
|
||||||
var show_user = document.getElementById('user_' + doc['user']).checked;
|
var show_user = document.getElementById('user_' + doc['user']).checked;
|
||||||
element.toggle(show_type && show_user);
|
var show_link_type = doc['type'] != 'xanalink' || document.getElementById('link_type_' + doc['link_type']).checked;
|
||||||
|
element.toggle(show_type && show_user && show_link_type);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(update_list());
|
||||||
|
|
||||||
$('input').change(update_list);
|
$('input').change(update_list);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,20 @@ def show_errors(f):
|
||||||
@bp.route('/')
|
@bp.route('/')
|
||||||
def home():
|
def home():
|
||||||
docs = Item.query.order_by(Item.created)
|
docs = Item.query.order_by(Item.created)
|
||||||
docs_info = [{'user': doc.user.username, 'id': doc.id, 'type': doc.type}
|
docs_info = []
|
||||||
for doc in docs]
|
for item in docs:
|
||||||
|
cur = {'user': item.user.username, 'id': item.id, 'type': item.type}
|
||||||
|
if item.type == 'xanalink':
|
||||||
|
cur['link_type'] = item.link_type
|
||||||
|
docs_info.append(cur)
|
||||||
|
|
||||||
users = [item_user.username for item_user in User.query]
|
users = [item_user.username for item_user in User.query]
|
||||||
|
|
||||||
|
link_types = {item['link_type'] for item in docs_info if item.get('link_type')}
|
||||||
|
|
||||||
return render_template('home.html',
|
return render_template('home.html',
|
||||||
docs=docs,
|
docs=docs,
|
||||||
|
link_types=link_types,
|
||||||
docs_info=docs_info,
|
docs_info=docs_info,
|
||||||
nbsp_at_start=nbsp_at_start,
|
nbsp_at_start=nbsp_at_start,
|
||||||
users=users)
|
users=users)
|
||||||
|
|
Loading…
Reference in a new issue