Bugzilla – Attachment 140414 Details for
Bug 31536
Add UNIMARC framework plugin to fetch PPN from sudoc.fr
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31536: Add UNIMARC framework plugin to fetch PPN from sudoc.fr
Bug-31536-Add-UNIMARC-framework-plugin-to-fetch-PP.patch (text/plain), 6.20 KB, created by
David Nind
on 2022-09-11 21:23:47 UTC
(
hide
)
Description:
Bug 31536: Add UNIMARC framework plugin to fetch PPN from sudoc.fr
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-09-11 21:23:47 UTC
Size:
6.20 KB
patch
obsolete
>From 9effa5a5aa0a16ca0cb4bfa232bfeeac47396bdc Mon Sep 17 00:00:00 2001 >From: jeremy breuillard <jeremy.breuillard@biblibre.com> >Date: Tue, 7 Jun 2022 15:40:09 +0200 >Subject: [PATCH] Bug 31536: Add UNIMARC framework plugin to fetch PPN from > sudoc.fr > >This plugin uses sudoc.fr webservices (isbn2ppn, issn2ppn, ean2ppn) to >search a PPN using ISBN, ISSN or EAN as search criteria. >The plugin expects than ISBN is in 010$a, ISSN is in 011$a and EAN is in >073$a. > >Test plan: >1. Configure the default MARC framework so that 009 uses this plugin > (unimarc_field_009_ppn.pl) >2. Start creating a new bibliographic record >3. In the editor, write "0195141156" in the 010$a input, then move the > focus out of the input (by pressing Tab, or clicking elsewhere on the > page) > The 009 field should be automatically filled with "06735209X" >4. Empty the 010$a input, then empty the 009 input >5. Write "2262-4694" in the 011$a input, then move the focus out of the > input > The 009 field should be automatically filled with "166197947" >6. Empty the 011$a input, then empty the 009 input >7. Write "9782070424597" in the 073$a input, then move the focus out of > the input > The 009 field should be automatically filled with "151662983" >8. Empty only the 009 field, keep the same value for 073$a and save the > bibliographic record. >9. Edit the same record, you should have an empty 009 field and 073$a = > "9782070424597". > Click on the 009 field input, it should be automatically filled with > "151662983" > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../value_builder/unimarc_field_009_ppn.pl | 118 ++++++++++++++++++ > 1 file changed, 118 insertions(+) > create mode 100644 cataloguing/value_builder/unimarc_field_009_ppn.pl > >diff --git a/cataloguing/value_builder/unimarc_field_009_ppn.pl b/cataloguing/value_builder/unimarc_field_009_ppn.pl >new file mode 100644 >index 0000000000..be56184c13 >--- /dev/null >+++ b/cataloguing/value_builder/unimarc_field_009_ppn.pl >@@ -0,0 +1,118 @@ >+#!/usr/bin/perl >+ >+# Converted to new plugin style (Bug 13437) >+ >+# Copyright 2000-2002 Katipo Communications >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use LWP::Simple qw(); >+use LWP::UserAgent; >+use JSON; >+use C4::Auth qw ( get_template_and_user ); >+use C4::Output qw ( output_html_with_http_headers ); >+ >+my $res; >+my $builder = sub { >+ my ( $params ) = @_; >+ my $res= qq| >+ <script> >+ jQuery(document).ready(function () { >+ const input = document.getElementById('$params->{id}'); >+ const isbn_input = jQuery('input[id^="tag_010_subfield_a_"]'); >+ const issn_input = jQuery('input[id^="tag_011_subfield_a_"]'); >+ const ean_input = jQuery('input[id^="tag_073_subfield_a_"]'); >+ >+ isbn_input.on('change', function () { >+ update_ppn('isbn', this.value); >+ }); >+ issn_input.on('change', function () { >+ update_ppn('issn', this.value); >+ }); >+ ean_input.on('change', function () { >+ update_ppn('ean', this.value); >+ }); >+ >+ jQuery(input).on('focus', function () { >+ const isbn = isbn_input.val().trim(); >+ const issn = issn_input.val().trim(); >+ const ean = ean_input.val().trim(); >+ if (isbn !== '') { >+ update_ppn('isbn', isbn); >+ } else if (issn !== '') { >+ update_ppn('issn', issn); >+ } else if (ean !== '') { >+ update_ppn('ean', ean); >+ } >+ }); >+ >+ function update_ppn(search_type, search_text) { >+ if (input.value.trim() === '') { >+ get_ppn(search_type, search_text).then(function (ppn) { >+ input.value = ppn; >+ }); >+ } >+ } >+ >+ function get_ppn(search_type, search_text) { >+ const url = '/cgi-bin/koha/cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_009_ppn.pl&' + search_type + '=' + encodeURIComponent(search_text); >+ >+ return jQuery.get(url); >+ } >+ }); >+ </script> >+ |; >+ return $res; >+}; >+ >+my $launcher = sub { >+ my ( $params ) = @_; >+ my $input = $params->{cgi}; >+ my $isbn = $input->param('isbn'); >+ my $issn = $input->param('issn'); >+ my $ean = $input->param('ean'); >+ >+ my ($template, $loggedinuser, $cookie) = get_template_and_user({ >+ template_name => "cataloguing/value_builder/ajax.tt", >+ query => $input, >+ type => "intranet", >+ flagsrequired => {editcatalogue => '*'}, >+ }); >+ >+ my $url; >+ if ( $isbn ) { >+ $url = "https://www.sudoc.fr/services/isbn2ppn/$isbn&format=text/json"; >+ } elsif ( $issn ) { >+ $url = "https://www.sudoc.fr/services/issn2ppn/$issn&format=text/json"; >+ } elsif ( $ean ) { >+ $url = "https://www.sudoc.fr/services/ean2ppn/$ean&format=text/json"; >+ } >+ >+ if ($url) { >+ my $json = LWP::Simple::get($url); >+ if (defined $json) { >+ my $response = JSON->new->utf8->decode($json); >+ my $result = $response->{sudoc}->{query}->{result}; >+ my $ppn = ref $result eq 'ARRAY' ? $result->[0]->{ppn} : $result->{ppn}; >+ $template->param( return => $ppn ); >+ } >+ } >+ >+ output_html_with_http_headers $input, $cookie, $template->output; >+}; >+ >+return { builder => $builder, launcher => $launcher }; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31536
:
140342
|
140414
|
141291