diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 36ff2fc..0ad21a3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: ci:test on: push: branches: - - add-meta-tags + - meta-tag paths-ignore: - "docs/**" - "**.md" diff --git a/templates/semantic-ui/invenio_app_rdm/records/details/meta.html b/templates/semantic-ui/invenio_app_rdm/records/details/meta.html index 1c3ac3a..2afa7f1 100644 --- a/templates/semantic-ui/invenio_app_rdm/records/details/meta.html +++ b/templates/semantic-ui/invenio_app_rdm/records/details/meta.html @@ -10,14 +10,23 @@ {%- from "invenio_formatter/macros/meta.html" import meta_twittercard, meta_opengraph, meta_highwire -%} + {%- set meta_title = record.metadata.title|striptags -%} {%- set meta_description = record.metadata.description|striptags -%} -{%- set meta_authors = record.metadata.creators|map(attribute='name') -%} +{%- set meta_authors = record.metadata.creators|map(attribute='person_or_org.name') -%} +{%- set contributors = record.metadata.contributors| rejectattr('role.id', 'equalto', 'editor') | map(attribute='person_or_org.name') -%} + + {%- set meta_publisher = record.metadata.publisher %} {%- set files = record.files %} + {{- meta_highwire(meta_title,meta_description,authors=meta_authors,publisher=meta_publisher,publication_date=record.metadata.publication_date|from_isodate,doi=record.pids.get("doi", {}).get("identifier"),keywords=record.metadata.subjects | map(attribute="subject"),url=record.links.self_html) }} +{%- for c in contributors %} + +{%- endfor %} + {{- meta_opengraph(meta_title, meta_description, url=record.links.self_html) }} {{- meta_twittercard(meta_title, meta_description) }} diff --git a/tests/ui/test_meta_tags.py b/tests/ui/test_meta_tags.py index 24361b8..b39eddc 100644 --- a/tests/ui/test_meta_tags.py +++ b/tests/ui/test_meta_tags.py @@ -7,12 +7,11 @@ # # ultraviolet is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. -"""View tests of the front page.""" +"""Tests for meta.html.""" from invenio_rdm_records.proxies import current_rdm_records_service from invenio_access.permissions import system_identity -from io import BytesIO from flask import url_for from invenio_accounts.testutils import login_user_via_session @@ -38,11 +37,13 @@ def test_meta_tags(full_record, services, client, app, db, admin_user): response = client.get(record_url) html_content = response.data.decode() - assert '' in html_content, "Missing citation_title tag" + assert '' in html_content, "Missing description tag" + assert '' in html_content, "Missing author tag" + assert '' in html_content, "Missing citation_publication_date tag" + assert '' in html_content, "Missing citation_publisher tag" + assert '' in html_content, "Missing citation_doi tag" + assert '' in html_content, "Missing citation_keywords tag" + assert '' in html_content, "Missing contirbutor tag" +