It would be nice to be able to search and install plugins directly from GitHub ( and GitLab if possible ). This would make it easier to verify the authenticity of plugins and make discovering new plugins easier as well as making installation of plugins simpler.
Test Plan:
1) Apply this patch
2) Add the new block for plugin_repos to your koha-conf.xml
3) Restart all the things!
4) Browse to the plugins home page
5) Try searching for 'patrons' in the new search box
6) Verify you get results!
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
developers use it to catch bugs related to strict SQL modes -->
<dev_install>0</dev_install>
<strict_sql_modes>0</strict_sql_modes>
+ <plugin_repos>
+ <repo>
+ <name>ByWater Solutions</name>
+ <org_name>bywatersolutions</org_name>
+ <service>github</service>
+ </repo>
+ <repo>
+ <name>Theke Solutions</name>
+ <org_name>thekesolutions</org_name>
+ <service>github</service>
+ </repo>
+ </plugin_repos>
</config>
</yazgfs>
developers use it to catch bugs related to strict SQL modes -->
<dev_install>0</dev_install>
<strict_sql_modes>0</strict_sql_modes>
+ <plugin_repos>
+ <repo>
+ <name>ByWater Solutions</name>
+ <org_name>bywatersolutions</org_name>
+ <service>github</service>
+ </repo>
+ <repo>
+ <name>Theke Solutions</name>
+ <org_name>thekesolutions</org_name>
+ <service>github</service>
+ </repo>
+ </plugin_repos>
</config>
</yazgfs>
[% IF ( CAN_user_plugins_manage ) %]
<div class="btn-toolbar" id="toolbar">
<a href="/cgi-bin/koha/plugins/plugins-upload.pl" id="upload_plugin" class="btn btn-default"><i class="fa fa-upload"></i> Upload plugin</a>
+
<div class="btn-group">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-eye"></i> View plugins by class <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="/cgi-bin/koha/plugins/plugins-home.pl?method=intranet_catalog_biblio_enhancements">View intranet catalog biblio enhancement plugins</a></li>
</ul>
</div>
+
+ <div class="btn-group">
+ <form class="form-inline">
+ <div class="form-group">
+ <div class="input-group">
+ <input type="text" class="form-control" name="plugin-search" id="plugin-repo-search" placeholder="Search for plugins" value="[% search_term | html %]"/>
+ <div class="input-group-addon"><i class="fa fa-search"></i></div>
+ </div>
+ </div>
+ </form>
+ </div>
</div>
[% END %]
<h1>Plugins</h1>
+ [% IF search_results %]
+ <h2>Search results</h2>
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Description</th>
+ <th>Organization</th>
+ <th> </th>
+ </tr>
+ </thead>
+
+ [% FOREACH sr IN search_results %]
+ <tr>
+ <td><a href="[% sr.result.html_url | url %]" target="_new">[% sr.result.name %]</a></td>
+ <td>[% sr.result.description %]</td>
+ <td>[% sr.repo.name %]</td>
+ <td><button class="btn btn-install-plugin"><i class="fa fa-download"></i> Install</button></td>
+ </tr>
+ [% END %]
+ </table>
+ [% END %]
+
[% UNLESS ( plugins ) %]
[% UNLESS ( method ) %]
<div class="dialog message">No plugins installed</div>
[% INCLUDE 'calendar.inc' %]
<script>
$(document).ready(function(){
+ $(".btn-install-plugin").on("click", function() { alert("Sorry, this functionality doesn't exist yet!"); });
$(".uninstall_plugin").on("click", function(){
$(".dropdown").removeClass("open");
var plugin_name = $(this).data("plugin-name");
use CGI qw ( -utf8 );
+use JSON qw(from_json);
+use LWP::Simple qw(get);
+
use Koha::Plugins;
use C4::Auth;
use C4::Output;
my $input = new CGI;
my $method = $input->param('method');
+my $plugin_search = $input->param('plugin-search');
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{ template_name => ($plugins_enabled) ? "plugins/plugins-home.tt" : "plugins/plugins-disabled.tt",
$template->param( plugins => \@plugins, );
+ my @results;
+ if ($plugin_search) {
+ my $repos = C4::Context->config('plugin_repos');
+ foreach my $r ( @{ $repos->{repo} } ) {
+ if ( $r->{service} eq 'github' ) {
+ my $url = "https://api.github.com/search/repositories?q=$plugin_search+user:$r->{org_name}+in:name,description";
+ my $response = from_json( get($url) );
+ foreach my $result ( @{ $response->{items} } ) {
+ next unless $result->{name} =~ /^koha-plugin-/;
+ push( @results, { repo => $r, result => $result } );
+ }
+ }
+ }
+
+ $template->param(
+ search_results => \@results,
+ search_term => $plugin_search,
+ );
+ }
}
output_html_with_http_headers( $input, $cookie, $template->output );