Jelajahi Sumber

Show thumbnail in dataset overview

Matthias Vogelgesang 7 tahun lalu
induk
melakukan
7fc173dbad
3 mengubah file dengan 13 tambahan dan 1 penghapusan
  1. 5 0
      nova/templates/dataset/detail.html
  2. 4 0
      nova/templates/index/search.html
  3. 4 1
      nova/views.py

+ 5 - 0
nova/templates/dataset/detail.html

@@ -10,7 +10,12 @@
 </div>
 <div class="row">
   <div class="col-md-3">
+    {% if dataset.has_thumbnail %}
+    <img class="img-responsive" width="128" height="128" src="{{
+    url_for("show_dataset", name=collection.user.name, collection_name=collection.name, dataset_name=dataset.name, path='.thumb.jpg') }}"/>
+    {% else %}
     <img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=%C3%97&w=128&h=128"/>
+    {% endif %}
   </div>
   <div class="col-md-3">
     {% if dataset.type == "samplescan" %}

+ 4 - 0
nova/templates/index/search.html

@@ -4,7 +4,11 @@
 {% for access in pagination.items %}
 <div class="row dataset-pad">
   <div class="col-sm-1">
+    {% if dataset.has_thumbnail %}
+    <img class="img-responsive" width="64" height="64" src="{{ url_for("show_dataset", name=collection.user.name, collection_name=collection.name, dataset_name=dataset.name, path='.thumb.jpg') }}"/>
+    {% else %}
     <img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=%C3%97&w=64&h=64"/>
+    {% endif %}
   </div>
   <div class="col-sm-11">
     <h3 class="dataset-link">

+ 4 - 1
nova/views.py

@@ -425,6 +425,9 @@ def show_collection(name, collection_name):
 @app.route('/user/<name>/<collection_name>/<dataset_name>/<path:path>')
 @login_required(admin=False)
 def show_dataset(name, collection_name, dataset_name, path=''):
+    collection = Collection.query.\
+        filter(Collection.name == collection_name).first()
+
     dataset = Dataset.query.join(Collection).\
         filter(Collection.name == collection_name).\
         filter(Dataset.name == dataset_name).first()
@@ -456,7 +459,7 @@ def show_dataset(name, collection_name, dataset_name, path=''):
             else:
                 subpaths.append((part, part))
 
-    params = dict(dataset=dataset, path=path, list_files=list_files,
+    params = dict(collection=collection, dataset=dataset, path=path, list_files=list_files,
                   subpaths=subpaths, files=files, dirs=dirs, origin=[])
 
     return render_template('dataset/detail.html', **params)