Bugzilla – Attachment 184191 Details for
Bug 32333
IdRef system preference revamping
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32333: (follow-up) Tidy
Bug-32333-follow-up-Tidy.patch (text/plain), 10.86 KB, created by
Owen Leonard
on 2025-07-17 11:30:23 UTC
(
hide
)
Description:
Bug 32333: (follow-up) Tidy
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2025-07-17 11:30:23 UTC
Size:
10.86 KB
patch
obsolete
>From 7648464cfd06edd3eb293012a742304d7a7e86d2 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 17 Jul 2025 11:29:10 +0000 >Subject: [PATCH] Bug 32333: (follow-up) Tidy > >--- > koha-tmpl/opac-tmpl/bootstrap/js/idref.js | 102 ++++++++++++++-------- > opac/svc/idref | 49 +++++------ > 2 files changed, 88 insertions(+), 63 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/idref.js b/koha-tmpl/opac-tmpl/bootstrap/js/idref.js >index 80fcb40ac52..2a166b85404 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/js/idref.js >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/idref.js >@@ -1,15 +1,15 @@ >-if (KOHA === undefined || !KOHA) { var KOHA = {}; } >- >+if (KOHA === undefined || !KOHA) { >+ var KOHA = {}; >+} > > /** > * A namespace for idref > */ > KOHA.idref = { >- > /** > * Set a click handler for all anchors <a class="idref-link">. > */ >- init: function() { >+ init: function () { > $("a[class='idref-link']").click(this.click); > }, > >@@ -17,67 +17,93 @@ KOHA.idref = { > * Get the publications from author identified by its ppn, using Koha svc > * webservice. Display the result in a new tab of the holdings table. > */ >- click: function(e) { >+ click: function (e) { > const ppn = $(this).attr("ppn"); >- const url = '/cgi-bin/koha/svc/idref?ppn=' + ppn; >- $.getJSON(url, function(publications) { >+ const url = "/cgi-bin/koha/svc/idref?ppn=" + ppn; >+ $.getJSON(url, function (publications) { > let html; >- if (publications.name === '') { >- html = __('Author not found in IdRef'); >+ if (publications.name === "") { >+ html = __("Author not found in IdRef"); > } else { >- const navig = publications.roles.map(role => '<a href="#idref-role-' + role.code + '" style="font-size: 90%;">' + role.label + ' (' + role.docs.length + ')</a>'); >+ const navig = publications.roles.map( >+ role => >+ '<a href="#idref-role-' + >+ role.code + >+ '" style="font-size: 90%;">' + >+ role.label + >+ " (" + >+ role.docs.length + >+ ")</a>" >+ ); > html = >- "<h2>" + publications.name + " / <small>" + >- "<a href=\"https://www.idref.fr/" + publications.ppn + "\" target=\"_blank\">" + >- publications.ppn + "</a></small></h2>" + >- "<div><div style=\"margin-bottom: 5px;\"> " + navig.join(' ⢠') + "</div>"; >- publications.roles.forEach((role) => { >+ "<h2>" + >+ publications.name + >+ " / <small>" + >+ '<a href="https://www.idref.fr/' + >+ publications.ppn + >+ '" target="_blank">' + >+ publications.ppn + >+ "</a></small></h2>" + >+ '<div><div style="margin-bottom: 5px;"> ' + >+ navig.join(" ⢠") + >+ "</div>"; >+ publications.roles.forEach(role => { > html += >- "<h3 id=\"idref-role-" + role.code + "\">" + role.label + "</h3>" + >- "<table class=\"table table-striped table-hover table-sm\"><tbody>"; >- role.docs.forEach((doc) => { >+ '<h3 id="idref-role-' + >+ role.code + >+ '">' + >+ role.label + >+ "</h3>" + >+ '<table class="table table-striped table-hover table-sm"><tbody>'; >+ role.docs.forEach(doc => { > html += > "<tr><td>" + >- "<a href=\"https://www.sudoc.fr/" + doc.ppn + " target=\"_blank\" rel=\"noreferrer\">" + >- "<img title=\"" + >- __('Publication In Sudoc Catalog') + >- "\" src=\"/opac-tmpl/bootstrap/images/sudoc.png\" />" + >+ '<a href="https://www.sudoc.fr/' + >+ doc.ppn + >+ ' target="_blank" rel="noreferrer">' + >+ '<img title="' + >+ __("Publication In Sudoc Catalog") + >+ '" src="/opac-tmpl/bootstrap/images/sudoc.png" />' + > "</a>"; > if (doc.bib) { > html += >- "<a href=\"/cgi-bin/koha/opac-detail.pl?biblionumber=" + doc.bib + " target=\"_blank\">" + >- "<img title=\"" + >- __('Publication In Local Catalog') + >- "\" src=\"/opac-tmpl/bootstrap/images/favicon.ico\" />" + >+ '<a href="/cgi-bin/koha/opac-detail.pl?biblionumber=' + >+ doc.bib + >+ ' target="_blank">' + >+ '<img title="' + >+ __("Publication In Local Catalog") + >+ '" src="/opac-tmpl/bootstrap/images/favicon.ico" />' + > "</a>"; > } > html += "</td><td>" + doc.citation + "</td></tr>"; > }); >- html += '</tbody></table>'; >+ html += "</tbody></table>"; > }); >- html += '</div>'; >+ html += "</div>"; > } >- const idrefDiv = $('#idref-publications'); >+ const idrefDiv = $("#idref-publications"); > if (idrefDiv.length) { > idrefDiv.html(html); > } else { >- html = "<div id=\"idref-publications\">" + html + "</div>"; >+ html = '<div id="idref-publications">' + html + "</div>"; > const tabMenu = > '<li id="tab_idref_publications" class="nav-item" role="presentation">' + > '<a href="#idref-publications" class="nav-link" id="idref-publications-tab" data-toggle="tab" role="tab" aria-selected="false">' + > '<img src="/opac-tmpl/bootstrap/images/idref.svg" style="height: 20px;"/>' + >- '</a></li>'; >- const tabs = $('#bibliodescriptions'); >+ "</a></li>"; >+ const tabs = $("#bibliodescriptions"); > const ul = tabs.find("ul"); > $(ul).append(tabMenu); >- $('.tab-content').append(html); >+ $(".tab-content").append(html); > showBsTab("bibliodescriptions", "idref-publications"); > } > $('a[href="#idref-publications"]').click(); >- $([document.documentElement, document.body]).animate({ >- scrollTop: $("#idref-publications").offset().top >- }, 2000); >+ $([document.documentElement, document.body]).animate( >+ { >+ scrollTop: $("#idref-publications").offset().top, >+ }, >+ 2000 >+ ); > }); >- } >- >+ }, > }; >diff --git a/opac/svc/idref b/opac/svc/idref >index b29cde474f8..aca99d5c3a9 100755 >--- a/opac/svc/idref >+++ b/opac/svc/idref >@@ -25,22 +25,21 @@ use C4::Context; > use C4::Output qw( output_with_http_headers ); > use Search::Elasticsearch; > >- > my $cgi = CGI->new; > > # See http://documentation.abes.fr/aideidrefdeveloppeur/index.html#MicroWebBiblio >-my $base = 'http://www.idref.fr/services/biblio/'; >+my $base = 'http://www.idref.fr/services/biblio/'; > my $unimarc3 = $cgi->param('ppn'); > > my $publications = { name => '', ppn => $unimarc3, roles => [] }; >-my $send_result = sub { >+my $send_result = sub { > my $json = to_json($publications); > utf8::encode($json); >- output_with_http_headers($cgi, undef, $json, 'json'); >+ output_with_http_headers( $cgi, undef, $json, 'json' ); > exit; > }; > >-my $ua = LWP::UserAgent->new; >+my $ua = LWP::UserAgent->new; > my $request = HTTP::Request->new( > 'GET', > $base . $unimarc3 . ".json", >@@ -49,57 +48,57 @@ $request->protocol('HTTP/1.1'); > my $response = $ua->request($request); > $send_result->() if not $response->is_success; > >-my $content = Encode::decode("utf8", $response->content); >-my $json = from_json($content); >-my $result = $json->{sudoc}->{result}; >+my $content = Encode::decode( "utf8", $response->content ); >+my $json = from_json($content); >+my $result = $json->{sudoc}->{result}; > $send_result->() if $result->{countRoles} == 0; > > $publications->{name} = $result->{name}; >-$result->{role} = [ $result->{role} ] if ref($result->{role}) ne 'ARRAY'; >+$result->{role} = [ $result->{role} ] if ref( $result->{role} ) ne 'ARRAY'; > my $ppn; >-for my $r (@{$result->{role}}) { >+for my $r ( @{ $result->{role} } ) { > my $role = { >- code => $r->{unimarcCode}, >+ code => $r->{unimarcCode}, > label => $r->{roleName}, >- docs => [], >+ docs => [], > }; > $r->{doc} = [ $r->{doc} ] if ref $r->{doc} ne 'ARRAY'; >- for my $doc ( @{$r->{doc}} ) { >- push @{$role->{docs}}, { >- ppn => $doc->{ppn}, >+ for my $doc ( @{ $r->{doc} } ) { >+ push @{ $role->{docs} }, { >+ ppn => $doc->{ppn}, > citation => $doc->{citation}, > }; > push @$ppn, $doc->{ppn}; > } >- push @{$publications->{roles}}, $role; >+ push @{ $publications->{roles} }, $role; > } > >-my $ec = C4::Context->config('elasticsearch'); >-my $e = Search::Elasticsearch->new( nodes => $ec->{server} ); >+my $ec = C4::Context->config('elasticsearch'); >+my $e = Search::Elasticsearch->new( nodes => $ec->{server} ); > my $query = { > index => $ec->{index_name} . '_biblios', >- body => { >+ body => { > _source => ["ppn"], >- size => '10000', >- query => { terms => { ppn => $ppn } } >+ size => '10000', >+ query => { terms => { ppn => $ppn } } > } > }; >-my $res = $e->search($query); >+my $res = $e->search($query); > my $hits = $res->{hits}->{hits}; > my $ppn_to_bib; > for my $hit (@$hits) { > my $ppn = $hit->{_source}->{ppn}->[0]; > $ppn_to_bib->{$ppn} = $hit->{_id}; > } >-for my $role (@{$publications->{roles}}) { >- my @docs = @{$role->{docs}}; >+for my $role ( @{ $publications->{roles} } ) { >+ my @docs = @{ $role->{docs} }; > for my $d (@docs) { > my $bib = $ppn_to_bib->{ $d->{ppn} }; > $d->{bib} = $bib if $bib; > } > my $key = sub { > my $doc = shift; >- ($doc->{bib} ? 'a' : 'b') . $doc->{citation}; >+ ( $doc->{bib} ? 'a' : 'b' ) . $doc->{citation}; > }; > @docs = sort { $key->($a) cmp $key->($b) } @docs; > $role->{docs} = \@docs; >-- >2.39.5
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 32333
:
144199
|
145663
|
147762
|
150675
|
184190
| 184191