Skip to content

Commit 8d43433

Browse files
committed
add download url to form, only show license when it exists
1 parent d98a44f commit 8d43433

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

app.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ def render_template(template, dataset):
8686
else:
8787
kwargs["filesize"] = "N/A"
8888

89+
# Compute download_url based on presence of url in the dataset
90+
if kwargs.get("url") and kwargs["url"] != "":
91+
kwargs["download_url"] = kwargs["url"]
92+
else:
93+
kwargs["download_url"] = f"https://data.aifarms.org/download/{dataset}"
94+
8995
keywords = set(["AIFARMS"])
9096
keywords.update(kwargs.get("keywords", ""))
9197
kwargs["aifarms_keywords"] = keywords
@@ -263,7 +269,7 @@ def downloads():
263269
def serve_image(dataset, name):
264270
import mimetypes
265271
from flask import abort, send_file
266-
allowed_exts = {".png", ".jpg", ".jpeg"}
272+
allowed_exts = {".png", ".jpg", ".jpeg", ".gif"}
267273
ext = os.path.splitext(name)[1].lower()
268274
if ext not in allowed_exts:
269275
abort(404)

templates/croissant.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"conformsTo": "http://mlcommons.org/croissant/1.0",
99
"description": "{{ short_description }}",
1010
"citeAs": "{{ citation }}",
11+
{% if license and license != 'N/A' and license != '' %}
1112
"license": "https://data.aifarms.org/license/{{ dataset }}",
13+
{% endif %}
1214
"url": "https://data.aifarms.org/view/{{ dataset }}",
1315
"datePublished": "{{ created }}",
1416
"creator": [
@@ -28,8 +30,10 @@
2830
{
2931
"@type": "cr:FileSet",
3032
"@id": "{{ dataset }}.zip",
31-
"contentUrl": "https://data.aifarms.org/download/{{ dataset }}",
33+
"contentUrl": "{{ download_url }}",
34+
{% if filesize and filesize != 'N/A' and filesize != '' %}
3235
"contentSize": "{{ filesize }}",
36+
{% endif %}
3337
"encodingFormat": "application/x-zip-compressed"
3438
}
3539
],

templates/view.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
<div id="nextToCarousel" class="col-3 position-absolute top-0 end-0" >
3939
<div class="vstack gap-3">
4040
<row>
41-
{% if filesize and filesize != 'N/A' and filesize != '' %}
42-
<a href="download/{{ dataset }}"><button type="submit" data-bs-toggle="tooltip" data-bs-placement="top"
41+
{% if (filesize and filesize != 'N/A' and filesize != '') or (url and url != '') %}
42+
<a href="{{ download_url }}"><button type="submit" data-bs-toggle="tooltip" data-bs-placement="top"
4343
title="Download" class="btn btn-secondary bi bi-cloud-download"></button></a>
4444
{% endif %}
4545
{% if license and license != 'N/A' and license != '' %}

0 commit comments

Comments
 (0)