From 1fc121eb239c0e997a80098f768c2e1a51a378a3 Mon Sep 17 00:00:00 2001 From: MooGoo Date: Thu, 11 Jul 2024 00:21:06 +0800 Subject: [PATCH] add images(default ppi) --- app/blueprints/frontpage.py | 4 ++-- app/static/js/data-search.js | 20 ++++++++++++-------- app/templates/data-search.html | 2 ++ app/templates/specimen-detail.html | 1 + 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/blueprints/frontpage.py b/app/blueprints/frontpage.py index da1d31d..cd3b8e9 100644 --- a/app/blueprints/frontpage.py +++ b/app/blueprints/frontpage.py @@ -95,8 +95,8 @@ def index(lang_code): @frontpage.route('/news', defaults={'lang_code': DEFAULT_LANG_CODE}) @frontpage.route('//news') def news(lang_code): - #articles = [x.to_dict() for x in Article.query.filter(Article.site_id==g.site.id).order_by(Article.publish_date.desc()).limit(10).all()] - articles = [x.to_dict() for x in Article.query.order_by(Article.publish_date.desc()).limit(10).all()] + articles = [x.to_dict() for x in Article.query.filter(Article.site_id==g.site.id).order_by(Article.publish_date.desc()).limit(10).all()] + #articles = [x.to_dict() for x in Article.query.order_by(Article.publish_date.desc()).limit(10).all()] try: return render_template(f'sites/{g.site.name}/news.html', articles=articles) diff --git a/app/static/js/data-search.js b/app/static/js/data-search.js index 39f7321..6cca5bc 100644 --- a/app/static/js/data-search.js +++ b/app/static/js/data-search.js @@ -37,7 +37,7 @@ ]; resultBody.innerHTML = ''; - fetch(`/api/v1/search?filter=${JSON.stringify(filtr)}&range=${JSON.stringify(range)}`) + fetch(`/api/v1/search?filter=${JSON.stringify(filtr)}&range=${JSON.stringify(range)}&sort=${JSON.stringify(["-created"])}`) .then( resp => resp.json()) .then( result => { console.log(result); @@ -49,15 +49,19 @@ let td = clone.querySelectorAll("td"); //let x = item.source_data; let link = document.createElement('a'); + let img = document.createElement('img'); + img.src = `https://naturedb.s3.ap-northeast-1.amazonaws.com/ppi/${item.accession_number}-m.jpg`; // TODO + img.width = '100'; link.href = `/specimens/${item.unit_id}`; - link.textContent = 'specimen'; + link.textContent = 'link'; td[0].appendChild(link); - td[1].textContent = item.accession_number; - td[2].textContent = item.taxon_text; - td[3].textContent = (item.collector) ? item.collector.display_name : ''; - td[4].innerHTML = item.field_number; - td[5].innerHTML = item.collect_date; - td[6].innerHTML = item.locality_text; + td[1].appendChild(img); + td[2].textContent = item.accession_number; + td[3].textContent = item.taxon_text; + td[4].textContent = (item.collector) ? item.collector.display_name : ''; + td[5].innerHTML = item.field_number; + td[6].innerHTML = item.collect_date; + td[7].innerHTML = item.locality_text; resultBody.appendChild(clone); }); diff --git a/app/templates/data-search.html b/app/templates/data-search.html index 5d504e2..45ff3de 100644 --- a/app/templates/data-search.html +++ b/app/templates/data-search.html @@ -20,6 +20,7 @@ + @@ -47,6 +48,7 @@ + {% endblock %} diff --git a/app/templates/specimen-detail.html b/app/templates/specimen-detail.html index 35fa43b..89e9845 100644 --- a/app/templates/specimen-detail.html +++ b/app/templates/specimen-detail.html @@ -3,6 +3,7 @@ {% block main %}
+

{{ _('館號') }} {{entity.record.collection.organization.code }}:{{ entity.accession_number }}

學名/中文名: {{ entity.record.proxy_taxon_scientific_name}} / {{ entity.record.proxy_taxon_common_name}}

{{ _('引用網址') }} {{ entity.guid }}

館號 物種