From 8a3e876e03a096e206005d6eb54e3cb0127c148a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 20 Apr 2020 14:21:18 -0400 Subject: [PATCH] Bug 25222: Add ability to let plugins live in individual subdirectories From Tomas: "We really need to put each plugin in its own subdirectory (to identify them individually) and have a metadata file we can refer to." This would make things much more manageable. Right now, plugins get all mixed together in the plugins directory. For example, installing the kitchen sink plugin results in Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm being created in the plugins directory. Installing CoverFlow will create CoverFlow.pm in the same directory as KitchenSink.pm. There is no reason that plugins cannot be created to install in a subdirectory directly in the kpz file. In that case, the plugins directory would contain something like kitchen-sink/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm, while CoverFlow would live in coverflow/Koha/Plugin/Com/ByWaterSolutions/CoverFlow.pm. Test Plan: 1) Apply this patch 2) Restart all the things! 3) Download the Kitchen Sink plugin 4) Rename it from kzp to zip 5) Unzip the plugin 6) Create a new directory kitchen-sink 7) move the Koha directory from the plugin into kitchen-sink 8) Zip the new kitchen-sink directory, include that directory in the zip file 9) Change the file suffix from zip to kpz 10) Install the plugin in Koha 11) The plugin should load! --- Koha/Plugins.pm | 10 +++++++++- cpanfile | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm index 9dc42c5155..52d0e70d64 100644 --- a/Koha/Plugins.pm +++ b/Koha/Plugins.pm @@ -20,6 +20,7 @@ package Koha::Plugins; use Modern::Perl; use Class::Inspector; +use File::Find::Rule; use List::MoreUtils qw(any); use Module::Load::Conditional qw(can_load); use Module::Load qw(load); @@ -32,7 +33,14 @@ use Koha::Plugins::Methods; BEGIN { my $pluginsdir = C4::Context->config("pluginsdir"); my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir; - push( @INC, @pluginsdir ); + foreach my $dir ( @pluginsdir ) { + my @dirs = File::Find::Rule->new + ->maxdepth(1) + ->directory + ->in($dir); + + push( @INC, @dirs ); + } pop @INC if $INC[-1] eq '.'; } diff --git a/cpanfile b/cpanfile index f7d69c3f84..3067a1d11e 100644 --- a/cpanfile +++ b/cpanfile @@ -39,6 +39,7 @@ requires 'Email::Date', '1.103'; requires 'Email::MessageID', '1.406'; requires 'Email::Valid', '0.190'; requires 'Exception::Class', '1.38'; +requires 'File::Find::Rule', '1.34'; requires 'File::Slurp', '9999.13'; requires 'Font::TTF', '0.45'; requires 'GD', '2.39'; -- 2.24.2 (Apple Git-127)