Skip to content

Instantly share code, notes, and snippets.

@vpeil
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vpeil/ca3ec0b770d171032b94 to your computer and use it in GitHub Desktop.
Save vpeil/ca3ec0b770d171032b94 to your computer and use it in GitHub Desktop.
Set up your own OAI data provider with Catmandu and Dancer

Download this gist and create a symbolic link

$ ln -s catmandu.yml config.yml

This is necessary for the dancer app. In this case Catmandu and Dancer are using the same configuration file.

store:
oai:
package: Elasticsearch
options:
index_name: oai
bags:
publication:
cql_mapping:
default_index: basic
indexes:
_id:
op:
'any': true
'all': true
'=': true
'exact': true
field: '_id'
basic:
op:
'any': true
'all': true
'=': true
'<>': true
field: '_all'
description: "index with common fields..."
datestamp:
op:
'=': true
'<': true
'<=': true
'>=': true
'>': true
'exact': true
field: '_datestamp'
index_mappings:
publication:
properties:
_datestamp: {type: date, format: date_time_no_millis}
plugins:
'Catmandu::OAI':
store: oai
bag: publication
datestamp_field: datestamp
repositoryName: "My OAI DataProvider"
uri_base: "http://oai.service.com/oai"
adminEmail: me@example.com
earliestDatestamp: "1970-01-01T00:00:01Z"
deletedRecord: persistent
repositoryIdentifier: oai.service.com
cql_filter: "datestamp>2014-12-01T00:00:00Z"
limit: 200
delimiter: ":"
sampleIdentifier: "oai:oai.service.com:1585315"
metadata_formats:
-
metadataPrefix: oai_dc
schema: "http://www.openarchives.org/OAI/2.0/oai_dc.xsd"
metadataNamespace: "http://www.openarchives.org/OAI/2.0/oai_dc/"
template: oai_dc.tt
fix:
- nothing()
sets:
-
setSpec: openaccess
setName: Open Access
cql: 'oa=1'
#!/usr/bin/env perl
use Dancer;
use Catmandu;
use Dancer::Plugin::Catmandu::OAI;
Catmandu->load;
Catmandu->config;
oai_provider '/oai';
dance;
<oai_dc:dc xmlns="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
[%- FOREACH var IN ['title' 'creator' 'subject' 'description' 'publisher' 'contributor' 'date' 'type' 'format' 'identifier' 'source' 'language' 'relation' 'coverage' 'rights'] %]
[%- FOREACH val IN $var %]
<dc:[% var %]>[% val | html %]</dc:[% var %]>
[%- END %]
[%- END %]
</oai_dc:dc>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment