Commit 82ac90d0 authored by Juan Corona's avatar Juan Corona

Change the scheme for the document identifying URN that’s derived from DC metadata

“dc.relation.ispartof” is now used instead of “dc.source”
The goal of this is to identify a resource that’s part of another resource, therefore the more specific term fits better.
parent 7b9cbbb7
...@@ -159,21 +159,20 @@ module.exports = class Document extends Plugin ...@@ -159,21 +159,20 @@ module.exports = class Document extends Plugin
if id[0..3] == "doi:" if id[0..3] == "doi:"
@metadata.link.push(href: id) @metadata.link.push(href: id)
# look for a link to identify the resource in dublincore data # look for a link to identify the resource in dublincore metadata
dcMetaConcat = [] dcRelationValues = @metadata.dc['relation.ispartof']
# sort by name for a consistent ordering of the concatenated metadata dcIdentifierValues = @metadata.dc['identifier']
for name in Object.keys(@metadata.dc).sort() if dcRelationValues && dcIdentifierValues
# right now only look for these two terms dcUrnRelationComponent =
if name == 'source' || name == 'identifier' dcRelationValues[dcRelationValues.length - 1]
values = @metadata.dc[name].sort().map (v) -> encodeURIComponent(v) dcUrnIdentifierComponent =
dcMetaConcat.push(name + ':' + values.join(',')) dcIdentifierValues[dcIdentifierValues.length - 1]
dcUrn = 'urn:x-dc:' +
dcMetaUrn = 'urn:x-dc-meta:' + dcMetaConcat.join('/') encodeURIComponent(dcUrnRelationComponent) + '/' +
if dcMetaConcat.length == 2 encodeURIComponent(dcUrnIdentifierComponent)
# only do this if both terms are provided, for now @metadata.link.push(href: dcUrn)
@metadata.link.push(href: dcMetaUrn)
# set this as the documentFingerprint as a hint to include this in search queries # set this as the documentFingerprint as a hint to include this in search queries
@metadata.documentFingerprint = dcMetaUrn @metadata.documentFingerprint = dcUrn
_getFavicon: => _getFavicon: =>
for link in $("link") for link in $("link")
......
...@@ -41,8 +41,8 @@ describe 'Document', -> ...@@ -41,8 +41,8 @@ describe 'Document', ->
head.append('<meta name="citation_title" content="Foo">') head.append('<meta name="citation_title" content="Foo">')
head.append('<meta name="citation_pdf_url" content="foo.pdf">') head.append('<meta name="citation_pdf_url" content="foo.pdf">')
head.append('<meta name="dc.identifier" content="doi:10.1175/JCLI-D-11-00015.1">') head.append('<meta name="dc.identifier" content="doi:10.1175/JCLI-D-11-00015.1">')
head.append('<meta name="dc:identifier" content="isbn:123456789">') head.append('<meta name="dc:identifier" content="foobar-abcxyz">')
head.append('<meta name="dc:source" content="urn:example:abcxyz">') head.append('<meta name="dc.relation.ispartof" content="isbn:123456789">')
head.append('<meta name="DC.type" content="Article">') head.append('<meta name="DC.type" content="Article">')
head.append('<meta property="og:url" content="http://example.com">') head.append('<meta property="og:url" content="http://example.com">')
head.append('<meta name="twitter:site" content="@okfn">') head.append('<meta name="twitter:site" content="@okfn">')
...@@ -85,12 +85,12 @@ describe 'Document', -> ...@@ -85,12 +85,12 @@ describe 'Document', ->
assert.equal(metadata.link[7].type, "application/pdf") assert.equal(metadata.link[7].type, "application/pdf")
assert.equal(metadata.link[8].href, "doi:10.1175/JCLI-D-11-00015.1") assert.equal(metadata.link[8].href, "doi:10.1175/JCLI-D-11-00015.1")
# link derived from dc resource identifiers # Link derived from dc resource identifiers in the form of urn:x-dc:<container>/<identifier>
# should be in the form of `urn:x-dc-meta: identifier: <doi>,<isbn> / source: <example>` # Where <container> is the percent-encoded value of the last dc.relation.ispartof meta element
# it's a comma separated list for when there's multiple identifiers # and <identifier> is the percent-encoded value of the last dc.identifier meta element.
assert.equal( assert.equal(
metadata.link[9].href metadata.link[9].href
"urn:x-dc-meta:identifier:doi%3A10.1175%2FJCLI-D-11-00015.1,isbn%3A123456789/source:urn%3Aexample%3Aabcxyz" "urn:x-dc:isbn%3A123456789/foobar-abcxyz"
) )
it 'should ignore atom and RSS feeds and alternate languages', -> it 'should ignore atom and RSS feeds and alternate languages', ->
...@@ -104,8 +104,8 @@ describe 'Document', -> ...@@ -104,8 +104,8 @@ describe 'Document', ->
it 'should have dublincore metadata', -> it 'should have dublincore metadata', ->
assert.ok(metadata.dc) assert.ok(metadata.dc)
assert.deepEqual(metadata.dc.identifier, ["doi:10.1175/JCLI-D-11-00015.1", "isbn:123456789"]) assert.deepEqual(metadata.dc.identifier, ["doi:10.1175/JCLI-D-11-00015.1", "foobar-abcxyz"])
assert.deepEqual(metadata.dc.source, ["urn:example:abcxyz"]) assert.deepEqual(metadata.dc['relation.ispartof'], ["isbn:123456789"])
assert.deepEqual(metadata.dc.type, ["Article"]) assert.deepEqual(metadata.dc.type, ["Article"])
it 'should have facebook metadata', -> it 'should have facebook metadata', ->
......
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