Commit 6f1e5c63 authored by Dan Scott's avatar Dan Scott

Add a fifth CSS selector variable for schema.org typeof

This assumes that the catalogue page expresses schema.org/MusicAlbum as a type using RDFa, but can of course be modified to support local means of detecting that the description of the resource is a music recording. Signed-off-by: 's avatarDan Scott <dscott@laurentian.ca>
parent dfb7690c
......@@ -5,7 +5,7 @@ Copyright: Dan Scott (dan@coffeecode.net), Laurentian University
License: GPL version 2 or later
This is a simple implementation of infocards powered by Wikidata. To adapt this
to your music catalogue, you may be able to simply change the four CSS selector
to your music catalogue, you may be able to simply change the five CSS selector
variables in wikidata_music_card.js to match your catalogue's structure.
The code on which this implementation is based is running in production on an
......@@ -17,8 +17,8 @@ Evergreen library system at Laurentian University at https://laurentian.concat.c
* Currently limited to the domain of music. If you want to use this in a
broader domain, you will need to change the SPARQL query accordingly.
Consider using lookups based on authority IDs--for example, you could
use Wikidata IDs in MARC $0 subfields and look up the data directly, or
use Wikidata IDs in MARC $1 subfields and look up the data directly, or
use existing authority IDs (such as LC) to find matches based on Wikidata's
extensive authority controls.
extensive authority control data.
......@@ -22,6 +22,9 @@
* locations for inserting the clickable note icon and the infocard.
*/
/* Path for the schema.org type declaration */
var type_path = '[typeof~="MusicAlbum"]';
/* List of elements describing contributors */
var contributors_path = 'div[resource^="#schemacontrib"]';
......@@ -40,7 +43,7 @@
var wd;
/* Ensure this is a musical recording, based on http://schema.org/MusicAlbum */
if (document.body.getAttribute('typeof').indexOf('MusicAlbum') > -1) {
if (document.querySelector(type_path)) {
var contributor_nodes = document.querySelectorAll(contributors_path);
for (var node of contributor_nodes) {
/* Insert clickable icon here */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment