Changeset View
Changeset View
Standalone View
Standalone View
swh/web/ui/templates/upload_and_search.html
{% extends "layout.html" %} | {% extends "layout.html" %} | ||||
{% block title %}Search or Upload/Hash/Search{% endblock %} | {% block title %}Search SWH{% endblock %} | ||||
{% block content %} | {% block content %} | ||||
<div> | |||||
Input some hash: | <!-- CryptoJS assumed to be installed as a debian package --> | ||||
<form action="{{ url_for('search') }}" | <script src="{{ url_for('static', filename='lib/core.js') }}"></script> | ||||
<script src="{{ url_for('static', filename='lib/lib-typedarrays.js') }}"></script> | |||||
<script src="{{ url_for('static', filename='lib/sha1.js') }}"></script> | |||||
<script src="{{ url_for('static', filename='lib/sha256.js') }}"></script> | |||||
<script src="{{ url_for('static', filename='js/filedrop.js') }}"></script> | |||||
<div class="container"> | |||||
<form id="searchForm" | |||||
action="{{ url_for('search') }}" | |||||
class="form" | |||||
method="post" | method="post" | ||||
enctype="multipart/form-data"> | enctype="multipart/form-data"> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
<input type="text" class="form-control" | <label for="sha1_textinput">Search with SHA-1 or SHA-256:</label> | ||||
name="q" value="{{ q }}" | <br/> | ||||
<div id="textinput" class="input-group"> | |||||
<input id="sha1_textinput" | |||||
type="text" class="form-control" | |||||
name="q" | |||||
placeholder="SHA-1 or SHA-256 checksum" /> | placeholder="SHA-1 or SHA-256 checksum" /> | ||||
or some file to hash: | </div> | ||||
</div> | |||||
<div id="filesinput" class="input-group"> | |||||
<label for="fileElem">Search with files</label> | |||||
<div id="fileinput" class="container text-center" style="border: 1px dashed black"> | |||||
Drag and drop or click here to hash files and search for them. | |||||
Your files will NOT be uploaded, hashing is done locally. | |||||
Filesizes over 20Mb are slow to process, we recommend obtaining their hash via | |||||
GNU sha1sum or some other online tool. | |||||
zack: as we are not sure whether we are going to have a form to insert checksums by hand, I suggest… | |||||
<div id="filelist" class="row"> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="text-center" style="margin-top: 10px"> | |||||
<button id="submitall" type="submit" class="btn btn-primary"> | |||||
<span class="glyphicon glyphicon-search" aria-hidden="true"></span> | |||||
Search | |||||
</button> | |||||
</div> | |||||
</form> | |||||
<input type="file" | <input type="file" | ||||
id="fileElem" | |||||
class="form-control" | class="form-control" | ||||
multiple | |||||
name="filename" | name="filename" | ||||
value="{{ filename }}" | value="" | ||||
placeholder="File to upload, hash and search for SHA-1 or SHA-256 checksum" /> | style="display:none" | ||||
</div> | placeholder="File(s) to upload, hash and search for SHA-1 or SHA-256 checksum" /> | ||||
<button type="submit" class="btn btn-default">(Upload &) Search</button> | {% if search_stats is not none and search_stats %} | ||||
</form> | <label id="stats"> | ||||
{% if messages is not none %} | Files available in SWH: {{ '%.2f' | format(search_stats['pct']) }}% of | ||||
{{ search_stats['nbfiles'] }} files. | |||||
</label> | |||||
{% endif %} | |||||
{% if responses is not none and responses %} | |||||
<table id="results" class="table table-striped"> | |||||
<thead class="thead-default"> | |||||
<th>File name</th> | |||||
<th>SHA1 hash</th> | |||||
zackUnsubmitted Done Inline Actionss/hash/checksum/ zack: s/hash/checksum/ | |||||
<th>Result</th> | |||||
</thead> | |||||
{% for resp in responses %} | |||||
<tr> | |||||
<td>{{ resp['filename'] }}</td> | |||||
{% if resp['found'] %} | |||||
<td><a href="sha1:{{ url_for('browse_content') }}{{ resp['sha1'] }}">{{ resp['sha1'] }}</a></td> | |||||
<td><span class="glyphicon glyphicon-ok file-found"></span></td> | |||||
{% else %} | |||||
<td>{{ resp['sha1'] }}</td> | |||||
<td><span class="glyphicon glyphicon-remove file-nfound"></span></td> | |||||
{% endif %} | |||||
</tr> | |||||
{% endfor %} | |||||
</table> | |||||
{% endif %} | |||||
{% if messages is not none and messages %} | |||||
<div id="messages" class="row"> | |||||
{% for message in messages %} | {% for message in messages %} | ||||
<br /> | <br /> | ||||
<div id="message">{{ message | safe }}</div> | <div class="span8">{{ message | safe }}</div> | ||||
{% endfor %} | {% endfor %} | ||||
</div> | |||||
{% endif %} | {% endif %} | ||||
<!-- jQuery setup --> | |||||
<div id="test"></div> | |||||
<script> | |||||
// Delegate dropbox click | |||||
$("#fileinput").inputclick($("#fileElem")); | |||||
// Make the dropbox available for drag & drop | |||||
$("#fileElem").filedialog($("#filelist"), $("#searchForm")); | |||||
$("#fileinput").filedrop($("#filelist"), $("#searchForm")); | |||||
// Make the submission button receptive to files | |||||
</script> | |||||
</div> | </div> | ||||
{% endblock %} | {% endblock %} |
as we are not sure whether we are going to have a form to insert checksums by hand, I suggest rephrasing this as something like "Filesizes over 20Mb can be slow to process, so use with care".