diff --git a/app.py b/app.py index 2ffa0d9..9c4022d 100755 --- a/app.py +++ b/app.py @@ -422,7 +422,7 @@ def get_labels(keys, name=None): return {entity['id']: wikibase.get_entity_label(entity) for entity in labels} -def get_other(entity): +def build_other_set(entity): other_items = set() for key in find_more_props.keys(): if key not in entity['claims']: @@ -430,7 +430,10 @@ def get_other(entity): for claim in entity['claims'][key]: if 'datavalue' in claim['mainsnak']: other_items.add(claim['mainsnak']['datavalue']['value']['id']) + return other_items +def get_other(entity): + other_items = build_other_set(entity) return get_labels(other_items) @app.route("/admin/edits") @@ -587,15 +590,20 @@ def catalog_page(): entities = mediawiki.get_entities_with_cache(qids) items = [] + other_items = set() for entity in entities: + other_items.update(build_other_set(entity)) item = { 'label': wikibase.get_entity_label(entity), 'qid': entity['id'], 'item_id': int(entity['id'][1:]), 'image_filename': wikibase.first_datavalue(entity, 'P18'), + 'entity': entity, } items.append(item) + other = get_labels(other_items) + flat = '_'.join(f'{pid}={qid}' for pid, qid in params) thumbwidth = 400 cache_name = f'{flat}_{page}_{page_size}_{thumbwidth}' @@ -605,7 +613,10 @@ def catalog_page(): item['url'] = url_for('item_page', item_id=item['item_id']) item['image'] = detail[item['image_filename']] - return render_template('catalog.html', items=items) + return render_template('catalog.html', + labels=find_more_props, + items=items, + other=other) def get_image_detail_with_cache(items, cache_name, thumbwidth=None): filenames = [cur['image_filename'] for cur in items] diff --git a/templates/catalog.html b/templates/catalog.html index 885a61a..1b35e03 100644 --- a/templates/catalog.html +++ b/templates/catalog.html @@ -16,10 +16,27 @@ td { vertical-align: top; }
{{ item.label }}
- {#{{ item | pprint }}#} + + {% for key, prop_label in labels.items() %} + {% set claims = item.entity['claims'][key] %} + {% if claims %} +