Skip to content

Commit

Permalink
add vocabulary description metadata from config.ttl to vocab-home page
Browse files Browse the repository at this point in the history
  • Loading branch information
osma committed Aug 21, 2024
1 parent fb1cab9 commit 8a5658a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/model/VocabularyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ public function getTitle($lang = null)
return $this->getLiteral('dc:title', false, $lang);
}

/**
* Returns the human readable vocabulary description.
* @return string the description of the vocabulary
*/
public function getDescription($lang = null)
{
return $this->getLiteral('dc:description', false, $lang);
}

/**
* Returns the sorting strategy for notation codes set in the config.ttl
* config: either "lexical", "natural", or null if sorting by notations is
Expand Down
1 change: 1 addition & 0 deletions src/view/vocab-home.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% set pageType = 'vocab-home' %}
{% extends "base-template.twig" %}
{% block title %}{{ vocab.title(request.contentLang) }} - {{ GlobalConfig.serviceName }}{% endblock %}
{% block description %}{{ vocab.config.description(request.contentLang) }}{% endblock %}


{% block content %}
Expand Down
9 changes: 9 additions & 0 deletions tests/VocabularyConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,15 @@ public function testGetTitle()
$this->assertEquals('Test ontology', $vocab->getConfig()->getTitle('en'));
}

/**
* @covers VocabularyConfig::getDescription
*/
public function testGetDesctiption()
{
$vocab = $this->model->getVocabulary('test');
$this->assertEquals('Description of Test ontology', $vocab->getConfig()->getDescription('en'));
}

/**
* @covers VocabularyConfig::getShowDeprecatedChanges
* @covers VocabularyConfig::getBoolean
Expand Down
9 changes: 9 additions & 0 deletions tests/cypress/template/vocab-home.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ describe('Vocabulary home page', () => {
cy.get('head meta[name="title"]').should('have.attr', 'content', expectedTitle);
cy.get('head meta[property="og:title"]').should('have.attr', 'content', expectedTitle);
})
it('Contains description metadata', () => {
cy.visit('/test/en') // go to the "Test ontology" home page

const expectedDescription = 'Description of Test ontology'

// check that the page has description metadata
cy.get('head meta[name="description"]').should('have.attr', 'content', expectedDescription);
cy.get('head meta[property="og:description"]').should('have.attr', 'content', expectedDescription);
})
it('contains vocabulary title', () => {
cy.visit('/test/en') // go to the "Test ontology" home page

Expand Down
1 change: 1 addition & 0 deletions tests/testconfig.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

:test a skosmos:Vocabulary, void:Dataset ;
dc:title "Test ontology"@en ;
dc:description "Description of Test ontology"@en ;
dc:subject :cat_science ;
dc:type mdrtype:ONTOLOGY ;
void:dataDump <http://skosmos.skos/dump/test/> ;
Expand Down

0 comments on commit 8a5658a

Please sign in to comment.