Created attachment 11511 [details] [review] Add an URL validation plugin for authority and biblio frameworks. This patch adds a new validation plugin that can be used in biblio and authority frameworks. The plugin uses a regex to validate that a field contains a valid url. For example, this plugin could be used for field 856$u of MARC21 biblio and authority frameworks.
Patch sponsored by the CCSR ( http://www.ccsr.qc.ca )
Sorry, forgot "Needs signoff". Better late than never...
Sounds like a good idea Frédérick! Can you provide a test plan, so I know what to expect before and after for testing?
Two thoughts: - I think using Regexp::Common::URI to get the regular expressions would be easier to maintain. - What about having the plugin also actively verify that the link is good?
Applying: Add an URL validation plugin for authority and biblio frameworks. Using index info to reconstruct a base tree... M koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt M koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt M koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt M koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt Falling back to patching base and 3-way merge... Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt Patch failed at 0001 Add an URL validation plugin for authority and biblio frameworks. The copy of the patch that failed is found in: /home/christopher/git/koha/.git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
Created attachment 26464 [details] [review] New version of the patch, rebase on master and using Common::Regex::URI. Here is a new version of the patch, rebased on current master and using Common::Regex::URI
Created attachment 31279 [details] [review] Add an URL validation plugin for authority and biblio frameworks.
Created attachment 31282 [details] [review] Bug 8609 - Add an URL validation plugin for authority and biblio frameworks This patch adds a new validation plugin to validate that a field/subfield contains a valid url. This plugin that can be used in biblio and authority frameworks. Changes: C4/Installer/PerlDependencies.pm - Regexp::Common::URI dependence added cataloguing/value_builder/url.pl - new file koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt - new function called in url.pl koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt - new function called in url.pl koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt - new function called in url.pl koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt - new function called in url.pl Testing: I) Before applying: 0) Go to the Cataloging module: menu->More->Cataloging; 1) Click <<New record -> default framework>> bouton; 2) Click tab << 8 >>; 3) Insert a text (for example "test") in the 856->u input field; 4) Click out of the input field; 5) Validate no message; II) After Applying: i) field/subfield plugin attach 0) In Koha adminstration, click << MARC bibliographic framework >>; 1) In Default framework, click << MARC structure >>; 2) Search field 856 and click << Subfields >>; 3) Click << u >>; 4) In Other options -> Plugin, choose url.pl ii) Insert a text in the 856->u input field 0) Go to the Cataloging module: menu->More->Cataloging; 1) Click <<New record -> default framework>> bouton; 2) Click tab << 8 >>; 3) Insert a text (for example "test") in the 856->u input field; 4) Click out of the input field; 5) Validate message: << The field 856$u must contain a valid URL! ex : http://www.google.com >>
Created attachment 38961 [details] [review] Bug 8609 - Add an URL validation plugin for authority and biblio frameworks This patch adds a new validation plugin to validate that a field/subfield contains a valid url. This plugin that can be used in biblio and authority frameworks. Changes: C4/Installer/PerlDependencies.pm - Regexp::Common::URI dependence added cataloguing/value_builder/url.pl - new file koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt - new function called in url.pl koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt - new function called in url.pl koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt - new function called in url.pl koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt - new function called in url.pl Testing: I) Before applying: 0) Go to the Cataloging module: menu->More->Cataloging; 1) Click <<New record -> default framework>> bouton; 2) Click tab << 8 >>; 3) Insert a text (for example "test") in the 856->u input field; 4) Click out of the input field; 5) Validate no message; II) After Applying: i) field/subfield plugin attach 0) In Koha adminstration, click << MARC bibliographic framework >>; 1) In Default framework, click << MARC structure >>; 2) Search field 856 and click << Subfields >>; 3) Click << u >>; 4) In Other options -> Plugin, choose url.pl ii) Insert a text in the 856->u input field 0) Go to the Cataloging module: menu->More->Cataloging; 1) Click <<New record -> default framework>> bouton; 2) Click tab << 8 >>; 3) Insert a text (for example "test") in the 856->u input field; 4) Click out of the input field; 5) Validate message: << The field 856$u must contain a valid URL! ex : http://www.google.com >> REBASED
"Patterns for the following URIs are supported: fax, file, FTP, gopher, HTTP, news, NTTP, pop, prospero, tel, telnet, tv and WAIS." It does not include https. Kind of important.
I removed the conflicts so it can be applied properly. I then followed the test plan and everything worked properly, including HTTPS URIs.
Created attachment 41231 [details] [review] Bug 8609 - Add an URL validation plugin for authority and biblio frameworks This patch adds a new validation plugin to validate that a field/subfield contains a valid url. This plugin that can be used in biblio and authority frameworks. Changes: C4/Installer/PerlDependencies.pm - Regexp::Common::URI dependence added cataloguing/value_builder/url.pl - new file koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt - new function called in url.pl koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt - new function called in url.pl koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt - new function called in url.pl koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt - new function called in url.pl Testing: I) Before applying: 0) Go to the Cataloging module: menu->More->Cataloging; 1) Click <<New record -> default framework>> bouton; 2) Click tab << 8 >>; 3) Insert a text (for example "test") in the 856->u input field; 4) Click out of the input field; 5) Validate no message; II) After Applying: i) field/subfield plugin attach 0) In Koha adminstration, click << MARC bibliographic framework >>; 1) In Default framework, click << MARC structure >>; 2) Search field 856 and click << Subfields >>; 3) Click << u >>; 4) In Other options -> Plugin, choose url.pl ii) Insert a text in the 856->u input field 0) Go to the Cataloging module: menu->More->Cataloging; 1) Click <<New record -> default framework>> bouton; 2) Click tab << 8 >>; 3) Insert a text (for example "test") in the 856->u input field; 4) Click out of the input field; 5) Validate message: << The field 856$u must contain a valid URL! ex : http://www.google.com >>
Please check EXAMPLE.pl in the plugin directory. You do not need plugin_parameters etc. anymore.
Created attachment 41232 [details] [review] Bug8609 - Removed useless plugin_parameters sub
Hi Rémi This patch doesn't apply anymore: Conflict merge: CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt CONFLICT (content): Merge conflict in C4/Installer/PerlDependencies.pm Please resolve the problem. Please squash the two patches. Could be great if you include changes in SQL frameworks for fresh installations and update database <http://wiki.koha-community.org/wiki/Database_updates> for frameworks already installed. Note: For debian this package is needed libregexp-common-perl in debian/control Regards
Comment on attachment 41231 [details] [review] Bug 8609 - Add an URL validation plugin for authority and biblio frameworks Review of attachment 41231 [details] [review]: ----------------------------------------------------------------- ::: cataloguing/value_builder/url.pl @@ +57,5 @@ > + my $regex = $RE{URI}; > + $regex =~ s/\//\\\//g; > + > + my $res = <<END_OF_JS; > +<script typei="text/javascript"> "typei" is a typo.
Created attachment 48080 [details] [review] Bug 8609 - Add an URL validation plugin for authority and biblio frameworks This patch adds a new validation plugin to validate that a field/subfield contains a valid url. This plugin that can be used in biblio and authority frameworks. Testing: I) Before applying: 0) Go to the Cataloging module: menu->More->Cataloging; 1) Click <<New record -> default framework>> bouton; 2) Click tab << 8 >>; 3) Insert a text (for example "test") in the 856->u input field; 4) Click out of the input field; 5) Validate no message; II) After Applying: i) field/subfield plugin attach 0) In Koha adminstration, click << MARC bibliographic framework >>; 1) In Default framework, click << MARC structure >>; 2) Search field 856 and click << Subfields >>; 3) Click << u >>; 4) In Other options -> Plugin, choose url.pl ii) Insert a text in the 856->u input field 0) Go to the Cataloging module: menu->More->Cataloging; 1) Click <<New record -> default framework>> bouton; 2) Click tab << 8 >>; 3) Insert a text (for example "test") in the 856->u input field; 4) Click out of the input field; 5) Validate message: << The field 856$u must contain a valid URL! ex : http://www.google.com >> Squashed all previous commits into one as asked by comment #15. I did not see any changes made to the database so I didn't change anything related to that. Bug8609 - Removed useless plugin_parameters sub bug8609 fixes for comment #15 and #16
Hi Rémi I think IMHO QA will not approve this cataloguing/value_builder/url.pl >+use strict; >+use warnings; >+no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings >+ This according with <https://wiki.koha-community.org/wiki/Coding_Guidelines#PERL2:_Modern::Perl>
Created attachment 48125 [details] [review] Bug 8609 - Add an URL validation plugin for authority and biblio frameworks This patch adds a new validation plugin to validate that a field/subfield contains a valid url. This plugin that can be used in biblio and authority frameworks. Testing: I) Before applying: 0) Go to the Cataloging module: menu->More->Cataloging; 1) Click <<New record -> default framework>> bouton; 2) Click tab << 8 >>; 3) Insert a text (for example "test") in the 856->u input field; 4) Click out of the input field; 5) Validate no message; II) After Applying: i) field/subfield plugin attach 0) In Koha adminstration, click << MARC bibliographic framework >>; 1) In Default framework, click << MARC structure >>; 2) Search field 856 and click << Subfields >>; 3) Click << u >>; 4) In Other options -> Plugin, choose url.pl ii) Insert a text in the 856->u input field 0) Go to the Cataloging module: menu->More->Cataloging; 1) Click <<New record -> default framework>> bouton; 2) Click tab << 8 >>; 3) Insert a text (for example "test") in the 856->u input field; 4) Click out of the input field; 5) Validate message: << The field 856$u must contain a valid URL! ex : http://www.google.com >> Squashed all previous commits into one as asked by comment #15. I did not see any changes made to the database so I didn't change anything related to that. Bug8609 - Removed useless plugin_parameters sub bug8609 fixes for comment #15 and #16 bug8609 Use Modern::Perl instead of strict and warnings
Why not use the new style for plugins? See EXAMPLE.pl
In C4/Installer/PerlDependencies.pm, Regexp::Common::URI is not marked as required. Should it be marekd as required?
(In reply to Rémi Mayrand-Provencher from comment #19) Hi Rémi and others I applied the patch and works as expected. You're right about my previous comment 15: > > Could be great if you include changes in SQL frameworks for fresh > installations and update database > <http://wiki.koha-community.org/wiki/Database_updates> for frameworks > already installed. > 856$u in marc_subfield_structure can share this plugin and upload.pl plugin (bug 6874) But also we can leave one of them by default, changing this: installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.sql > ('856', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 1, 0, 'biblioitems.url', 8, '', '', 'url.pl', 1, 0, '', '', '', NULL), AND installer/data/mysql/atomicupdate/bug_8609_mychange.sql >-- add url.pl to value_builder for marc_subfield_structure in 856$u >UPDATE marc_subfield_structure SET value_builder='url.pl' WHERE tagfield='856' and tagsubfield='u'; Please give me a positive feedback Regads
Created attachment 58205 [details] [review] Bug 8609 - Add an URL validation plugin for authority and biblio frameworks This patch adds a new validation plugin to validate that a field/subfield contains a valid url. This plugin that can be used in biblio and authority frameworks. Testing: I) Before applying: 0) Go to the Cataloging module: menu->More->Cataloging; 1) Click <<New record -> default framework>> bouton; 2) Click tab << 8 >>; 3) Insert a text (for example "test") in the 856->u input field; 4) Click out of the input field; 5) Validate no message; II) After Applying: i) field/subfield plugin attach 0) In Koha adminstration, click << MARC bibliographic framework >>; 1) In Default framework, click << MARC structure >>; 2) Search field 856 and click << Subfields >>; 3) Click << u >>; 4) In Other options -> Plugin, choose url.pl ii) Insert a text in the 856->u input field 0) Go to the Cataloging module: menu->More->Cataloging; 1) Click <<New record -> default framework>> bouton; 2) Click tab << 8 >>; 3) Insert a text (for example "test") in the 856->u input field; 4) Click out of the input field; 5) Validate message: << The field 856$u must contain a valid URL! ex : http://www.google.com >> ---- This patch is a simple rebase to ease future developments. Comments #20, #21 and #22 will be addressed in a another commit.
I think this functionality could be achieved just using the URI module without adding a new dependency...
Our customer abandonned the rebasing of this patch five years ago. This could be closed (if there was a close button :)
(In reply to Blou from comment #25) > Our customer abandonned the rebasing of this patch five years ago. This > could be closed (if there was a close button :) Hi Blou, you can use: RESOLVED WONTFIX in such cases.