Dancer-Plugin-Catmandu-SRU

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


0.0503  2018-11-27 12:06:54 CET
  - fix setting content type
  - new content_type setting

0.0502  2018-02-27 12:10:52 CET
  - host and port are derived by Dancer (better support for reverse proxy)
  - maximumRecords can be 0 (handy to check number of records)

0.0501  2017-08-18 13:22:45 CEST
  - bump required version of Catmandu::Exporter::Template

0.05  2017-08-18 11:25:12 CEST
  - new template_options setting

0.0403  2016-05-26 15:07:17 CEST
  - more pod and a demo application
  - bugfixes

0.0402  2016-02-09 16:33:08 CET
  - support for default search parameters

META.json  view on Meta::CPAN

      },
      "develop" : {
         "requires" : {
            "Dist::Milla" : "v1.0.20",
            "Test::Pod" : "1.41"
         }
      },
      "runtime" : {
         "requires" : {
            "Catmandu" : "0.8014",
            "Catmandu::Exporter::Template" : "0.11",
            "Dancer" : "1.3123",
            "SRU" : "1.01",
            "perl" : "v5.10.1"
         }
      },
      "test" : {
         "requires" : {
            "Dancer::Test" : "1.3123",
            "Test::More" : "0.88",
            "YAML" : "0"

META.yml  view on Meta::CPAN

no_index:
  directory:
    - eg
    - examples
    - inc
    - share
    - t
    - xt
requires:
  Catmandu: '0.8014'
  Catmandu::Exporter::Template: '0.11'
  Dancer: '1.3123'
  SRU: '1.01'
  perl: v5.10.1
resources:
  bugtracker: https://github.com/LibreCat/Dancer-Plugin-Catmandu-SRU/issues
  homepage: https://github.com/LibreCat/Dancer-Plugin-Catmandu-SRU
  repository: https://github.com/LibreCat/Dancer-Plugin-Catmandu-SRU.git
version: '0.0504'
x_contributors:
  - 'Dan Michael O. Heggø <danmichaelo@gmail.com>'

README  view on Meta::CPAN

        * bag   - In which Catmandu::Bag are the records of this 'store' (use: 'data' as default)
        * cql_filter -  A CQL query to find all records in the database that should be made available to SRU
        * default_record_schema - The metadataSchema to present records in 
        * limit - The maximum number of records to be returned in each SRU request
        * maximum_limit - The maximum number of search results to return
        * record_schemas - An array of all supported record schemas
            * identifier - The SRU identifier for the schema (see L<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 L<Catmandu::Exporter::Template> or L<Template>
        * content_type - Set a custom content type header, the default is 'text/xml'.

    Below is a sample minimal configuration for the 'sample.yml' demo
    above:

        charset: "UTF-8"
        plugins:
            'Catmandu::SRU':
                store: sru
                bag: data

cpanfile  view on Meta::CPAN

requires 'perl', 'v5.10.1';

on test => sub {
    requires 'Test::More', '0.88';
    requires 'Dancer::Test', '1.3123';
    requires 'YAML';
};

requires 'Dancer', '1.3123';
requires 'Catmandu', '>=0.8014';
requires 'Catmandu::Exporter::Template', '0.11';
requires 'SRU', '1.01';

lib/Dancer/Plugin/Catmandu/SRU.pm  view on Meta::CPAN


Dancer::Plugin::Catmandu::SRU - SRU server backed by a searchable Catmandu::Store

=cut

our $VERSION = '0.0504';

use Catmandu::Sane;
use Catmandu;
use Catmandu::Fix;
use Catmandu::Exporter::Template;
use Catmandu::Util qw(hash_merge);
use SRU::Request;
use SRU::Response;
use Dancer qw(:syntax);
use Dancer::Plugin;

sub sru_provider {
    my ($path, %opts) = @_;

    my $setting = hash_merge(plugin_setting, \%opts);

lib/Dancer/Plugin/Catmandu/SRU.pm  view on Meta::CPAN

                if ($e =~ /^cql error/) {
                    $response->addDiagnostic(SRU::Response::Diagnostic->newFromCode(10));
                    return $response->asXML;
                }
                die $e;
            };

            $hits->each(sub {
                my $data = $_[0];
                my $metadata = "";
                my $exporter = Catmandu::Exporter::Template->new(
                    %$template_options,
                    template => $template,
                    file     => \$metadata
                );
                $exporter->add($fix ? $fix->fix($data) : $data);
                $exporter->commit;
                $response->addRecord(SRU::Response::Record->new(
                    recordSchema => $identifier,
                    recordData   => $metadata,
                ));

lib/Dancer/Plugin/Catmandu/SRU.pm  view on Meta::CPAN

    * bag   - In which Catmandu::Bag are the records of this 'store' (use: 'data' as default)
    * cql_filter -  A CQL query to find all records in the database that should be made available to SRU
    * default_record_schema - The metadataSchema to present records in 
    * limit - The maximum number of records to be returned in each SRU request
    * maximum_limit - The maximum number of search results to return
    * record_schemas - An array of all supported record schemas
        * identifier - The SRU identifier for the schema (see L<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 L<Catmandu::Exporter::Template> or L<Template>
    * content_type - Set a custom content type header, the default is 'text/xml'.

Below is a sample minimal configuration for the 'sample.yml' demo above:

    charset: "UTF-8"
    plugins:
        'Catmandu::SRU':
            store: sru
            bag: data
            default_record_schema: dc



( run in 0.348 second using v1.01-cache-2.11-cpan-0f795438458 )