-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
642d803
commit 245ecb4
Showing
4 changed files
with
243 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: test | ||
on: [push, pull_request] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
perl: | ||
[ | ||
"5.38", | ||
"5.36", | ||
"5.34", | ||
"5.32", | ||
"5.30", | ||
"5.22", | ||
] | ||
name: Perl ${{ matrix.perl }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup perl | ||
uses: shogo82148/actions-setup-perl@v1 | ||
with: | ||
perl-version: ${{ matrix.perl }} | ||
- name: Install dependencies | ||
run: cpanm -nq --installdeps --with-develop --with-recommends . | ||
- name: Run test | ||
run: prove -lr t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
# This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v6.031. | ||
use strict; | ||
use warnings; | ||
|
||
use Module::Build 0.28; | ||
|
||
|
||
my %module_build_args = ( | ||
"build_requires" => { | ||
"Module::Build" => "0.28" | ||
}, | ||
"configure_requires" => { | ||
"Module::Build" => "0.28" | ||
}, | ||
"dist_abstract" => "drop in replacement for Dancer::Plugin::Catmandu::SRU", | ||
"dist_author" => [ | ||
"=over 4" | ||
], | ||
"dist_name" => "Plack-App-Catmandu-SRU", | ||
"dist_version" => "0.01", | ||
"license" => "perl", | ||
"module_name" => "Plack::App::Catmandu::SRU", | ||
"recursive_test_files" => 1, | ||
"requires" => { | ||
"Catmandu" => "1.20", | ||
"Catmandu::Exporter::Template" => "0.11", | ||
"Plack" => 0, | ||
"SRU" => "1.01", | ||
"Type::Tiny" => 0, | ||
"namespace::clean" => 0, | ||
"perl" => "v5.20.0" | ||
}, | ||
"test_requires" => { | ||
"Test::More" => "0.88" | ||
} | ||
); | ||
|
||
|
||
my %fallback_build_requires = ( | ||
"Module::Build" => "0.28", | ||
"Test::More" => "0.88" | ||
); | ||
|
||
|
||
unless ( eval { Module::Build->VERSION(0.4004) } ) { | ||
delete $module_build_args{test_requires}; | ||
$module_build_args{build_requires} = \%fallback_build_requires; | ||
} | ||
|
||
my $build = Module::Build->new(%module_build_args); | ||
|
||
|
||
$build->create_build_script; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
# NAME | ||
|
||
Plack::App::Catmandu::SRU - drop in replacement for Dancer::Plugin::Catmandu::SRU | ||
|
||
# SYNOPSIS | ||
|
||
use Plack::Builder; | ||
Plack::App::Catmandu::SRU; | ||
|
||
builder { | ||
enable 'ReverseProxy'; | ||
enable '+Dancer::Middleware::Rebase', base => Catmandu->config->{uri_base}, strip => 1; | ||
mount "/sru" => Plack::App::Catmandu::SRU->new( | ||
store => 'search', | ||
bag => 'publication', | ||
cql_filter => 'type = dataset', | ||
limit => 100, | ||
maximum_limit => 500, | ||
record_schemas => [ | ||
{ | ||
identifier => "info:srw/schema/1/mods-v3.6", | ||
title => "MODS", | ||
name => "mods_36", | ||
template => "views/export/mods_36.tt", | ||
fix => 'fixes/pub.fix' | ||
}, | ||
], | ||
)->to_app; | ||
}; | ||
|
||
# CONSTRUCTOR ARGUMENTS | ||
|
||
- store | ||
|
||
Name of Catmandu store in your catmandu store configuration | ||
|
||
Default: `default` | ||
|
||
- bag | ||
|
||
Name of Catmandu bag in your catmandu store configuration | ||
|
||
Default: `data` | ||
|
||
This must be a bag that implements [Catmandu::CQLSearchable](https://metacpan.org/pod/Catmandu%3A%3ACQLSearchable), and that configures a `cql_mapping` | ||
|
||
- cql\_filter | ||
|
||
A CQL query to find all records in the database that should be made available to SRU | ||
|
||
- default\_record\_schema | ||
|
||
default metadata schema all records are shown in, when SRU parameter `recordSchema` is not gi en . Should be one listed in `record_schemas` | ||
|
||
- limit | ||
|
||
The default number of records to be returned in each SRU request, when SRU parameter `maximumRecords` is not given during a searchRetrieve request. | ||
|
||
When not provided in the constructor, it is derived from the default limit of your catmandu bag (see [Catmandu::Searchable#default\_limit](https://metacpan.org/pod/Catmandu%3A%3ASearchable%23default_limit)) | ||
|
||
- maximum\_limit | ||
|
||
The maximum value allowed for request parameter `maximumRecords`. | ||
|
||
When not provided in the constructor, it is derived from the maximum limit of your catmandu bag (see [Catmandu::Searchable#maximum\_limit](https://metacpan.org/pod/Catmandu%3A%3ASearchable%23maximum_limit)) | ||
|
||
- record\_schemas | ||
|
||
An array of all supported record schemas. Each item in the array is an object with attributes: | ||
|
||
\* identifier - The SRU identifier for the schema (see [http://www.loc.gov/standards/sru/recordSchemas/](http://www.loc.gov/standards/sru/recordSchemas/)) | ||
|
||
\* name - A short descriptive name for the schema | ||
|
||
\* fix - Optionally an array of fixes to apply to the records before they are transformed into XML | ||
|
||
\* template - The path to a Template Toolkit file to transform your records into this format | ||
|
||
- template\_options | ||
|
||
An optional hash of configuration options that will be passed to [Catmandu::Exporter::Template](https://metacpan.org/pod/Catmandu%3A%3AExporter%3A%3ATemplate) or [Template](https://metacpan.org/pod/Template) | ||
|
||
- content\_type | ||
|
||
Set a custom content type header, the default is `text/xml`. | ||
|
||
- title | ||
|
||
Title shown in databaseInfo | ||
|
||
- description | ||
|
||
Description shown in databaseInfo | ||
|
||
- default\_search\_params | ||
|
||
Extra search parameters added during search in your catmandu bag: | ||
|
||
$bag->search( | ||
%{$self->default_search_params}, | ||
cql_query => $cql, | ||
sru_sortkeys => $request->sortKeys, | ||
limit => $limit, | ||
start => $first - 1, | ||
); | ||
|
||
Must be a hash reference | ||
|
||
Note that search parameter `cql_query`, `sru_sortkeys`, `limit` and `start` are overwritten | ||
|
||
As this is meant as a drop in replacement for [Dancer::Plugin::Catmandu::SRU](https://metacpan.org/pod/Dancer%3A%3APlugin%3A%3ACatmandu%3A%3ASRU) all arguments should be the same. | ||
|
||
So all arguments can be taken from your previous dancer plugin configuration, if necessary: | ||
|
||
use Dancer; | ||
use Catmandu; | ||
use Plack::Builder; | ||
use Plack::App::Catmandu::SRU; | ||
|
||
my $dancer_app = sub { | ||
Dancer->dance(Dancer::Request->new(env => $_[0])); | ||
}; | ||
|
||
builder { | ||
enable 'ReverseProxy'; | ||
enable '+Dancer::Middleware::Rebase', base => Catmandu->config->{uri_base}, strip => 1; | ||
|
||
mount "/sru" => Plack::App::Catmandu::SRU->new( | ||
%{config->{plugins}->{'Catmandu::SRU'}} | ||
)->to_app; | ||
|
||
mount "/" => builder { | ||
# only create session cookies for dancer application | ||
enable "Session"; | ||
mount '/' => $dancer_app; | ||
}; | ||
}; | ||
|
||
# METHODS | ||
|
||
- to\_app | ||
|
||
returns Plack application that can be mounted. Path rebasements are taken into account | ||
|
||
# AUTHOR | ||
|
||
- Nicolas Franck, `<nicolas.franck at ugent.be>` | ||
|
||
# IMPORTANT | ||
|
||
This module is still a work in progress, and needs further testing before using it in a production system | ||
|
||
# LICENSE AND COPYRIGHT | ||
|
||
This program is free software; you can redistribute it and/or modify it | ||
under the terms of either: the GNU General Public License as published | ||
by the Free Software Foundation; or the Artistic License. | ||
|
||
See http://dev.perl.org/licenses/ for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
requires 'perl', 'v5.10.1'; | ||
requires 'perl', 'v5.20.0'; | ||
|
||
on test => sub { | ||
requires 'Test::More', '0.88'; | ||
}; | ||
|
||
requires 'Plack'; | ||
requires 'Catmandu', '>=0.8014'; | ||
requires 'Catmandu', '>=1.20'; | ||
requires 'Catmandu::Exporter::Template', '0.11'; | ||
requires 'SRU', '1.01'; | ||
requires 'Type::Tiny'; | ||
requires 'namespace::clean'; |