Skip to content

Commit

Permalink
add images(default ppi)
Browse files Browse the repository at this point in the history
  • Loading branch information
moogoo78 committed Jul 10, 2024
1 parent 464b1b2 commit 1fc121e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/blueprints/frontpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def index(lang_code):
@frontpage.route('/news', defaults={'lang_code': DEFAULT_LANG_CODE})
@frontpage.route('/<lang_code>/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)
Expand Down
20 changes: 12 additions & 8 deletions app/static/js/data-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
});
Expand Down
2 changes: 2 additions & 0 deletions app/templates/data-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<table>
<thead>
<tr>
<th></th>
<th></th>
<th>館號</th>
<th>物種</th>
Expand Down Expand Up @@ -47,6 +48,7 @@
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</template>
{% endblock %}
1 change: 1 addition & 0 deletions app/templates/specimen-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% block main %}
<section id="section-1">
<header>
<img src="https://naturedb.s3.ap-northeast-1.amazonaws.com/ppi/{{ entity.accession_number }}-x.jpg">
<h2>{{ _('館號') }} {{entity.record.collection.organization.code }}:{{ entity.accession_number }}</h2>
<h4>學名/中文名: <mark>{{ entity.record.proxy_taxon_scientific_name}} / {{ entity.record.proxy_taxon_common_name}}</mark></h4>
<p>{{ _('引用網址') }} <code>{{ entity.guid }}</code></p>
Expand Down

0 comments on commit 1fc121e

Please sign in to comment.