From 4a9b26b21976b1fded3bf5e69c9064b28c28c193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20M=C3=A9nager?= <herve.menager@pasteur.fr> Date: Tue, 22 Dec 2020 18:09:18 +0100 Subject: [PATCH] multiple fixes to schema.org compound markup - avoid displaying values for non-defined properties - correct hardcoded image URL - escape SMILES for javascript literal - correct inChIKey FIX #267 FIX #268 --- ippisite/ippidb/templates/compound_card.html | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ippisite/ippidb/templates/compound_card.html b/ippisite/ippidb/templates/compound_card.html index f2a4df83..9b1c5e0f 100644 --- a/ippisite/ippidb/templates/compound_card.html +++ b/ippisite/ippidb/templates/compound_card.html @@ -561,17 +561,31 @@ { "url": "{{ request.build_absolute_uri }}", +{% if compound.inchi %} "inChI": "{{ compound.inchi }}", +{% endif %} +{% if compound.iupac_name %} "name": "{{ compound.iupac_name }}", +{% endif %} +{% if compound.iupac_name %} "iupacName": "{{ compound.iupac_name }}", +{% endif %} +{% if compound.molecular_weight %} "molecularWeight": {{ compound.molecular_weight }}, +{% endif %} "identifier": "{{ compound.id }}", -"inChIKey": "{{ compound.inchi }}", +{% if compound.inchikey %} +"inChIKey": "{{ compound.inchikey }}", +{% endif %} "@type": "MolecularEntity", -"image": "https://www.ebi.ac.uk/chembl/api/data/image/CHEMBL3623057.svg", +{% if compound.chembl_id %} +"image": "https://www.ebi.ac.uk/chembl/api/data/image/{{chembl_id}}.svg", +{% endif %} +{% if compound.canonical_smile %} "smiles": [ - "{{ compound.canonical_smile }}" + "{{ compound.canonical_smile|escapejs }}" ], +{% endif %} {% if compound.sameas_urls %} "sameAs": {{ compound.sameas_urls|safe }}, {% endif %} -- GitLab