Bug 29787: Add plugin version to plugin search results
This patch adds a new column to plugins search results: 'Latest version'. It takes the tag_name in both GitHub and GitLab cases and passes it to the template. To test: 1. Have this on your koha-conf.xml file: <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>gitlab</service> </repo> <repo> <name>PTFS Europe</name> <org_name>ptfs-europe</org_name> <service>github</service> </repo> </plugin_repos> 2. Restart all services: $ restart_all 3. Search for the term 'barclaycard' => SUCCESS: You get results from PTFS Europe (Github) => FAIL: They don't include plugin version 4. Search for the term 'innreach' => SUCCESS: You get results from Theke (Gitlab) => FAIL: They don't include plugin version 5. Apply this patch 6. Repeat 2-4 => SUCCESS: Results show up => SUCCESS: Results include the plugin version 7. Sign off :-D Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
b025a79345
commit
726c8605fc
2 changed files with 14 additions and 7 deletions
|
@ -77,6 +77,7 @@
|
|||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
<th>Organization</th>
|
||||
<th>Latest version</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -86,6 +87,7 @@
|
|||
<td><a href="[% sr.result.html_url | url %]" target="_new">[% sr.result.name | html %]</a></td>
|
||||
<td>[% sr.result.description | html %]</td>
|
||||
<td>[% sr.repo.name | html %]</td>
|
||||
<td>[% sr.result.tag_name | html %]</td>
|
||||
<td><a class="btn btn-default btn-sm btn-install-plugin" href="/cgi-bin/koha/plugins/plugins-upload.pl?op=Upload&uploadfile=[% sr.result.install_name | uri %]&uploadlocation=[% sr.result.install_url | uri %]"><i class="fa fa-download"></i> Install</a></td>
|
||||
</tr>
|
||||
[% END %]
|
||||
|
|
|
@ -77,11 +77,13 @@ if ($plugins_enabled) {
|
|||
foreach my $result ( @{ $response->{items} } ) {
|
||||
next unless $result->{name} =~ /^koha-plugin-/;
|
||||
my $releases = $result->{url} . "/releases/latest";
|
||||
my $release = from_json( get($releases) );
|
||||
my $release = from_json( get($releases) );
|
||||
my $tag_name = $release->{tag_name};
|
||||
for my $asset ( @{$release->{assets}} ) {
|
||||
if ($asset->{browser_download_url} =~ m/\.kpz$/) {
|
||||
$result->{install_name} = $asset->{name};
|
||||
$result->{install_url} = $asset->{browser_download_url};
|
||||
$result->{install_url} = $asset->{browser_download_url};
|
||||
$result->{tag_name} = $tag_name;
|
||||
}
|
||||
}
|
||||
push( @results, { repo => $r, result => $result } );
|
||||
|
@ -100,12 +102,14 @@ if ($plugins_enabled) {
|
|||
my @releases = @{ from_json( get($releases_url) ) };
|
||||
|
||||
if ( scalar @releases > 0 ) {
|
||||
|
||||
# Pick the first one, the latest release
|
||||
my $latest = $releases[0];
|
||||
my $name = $latest->{name};
|
||||
my @links = @{$latest->{assets}->{links}};
|
||||
my $url = $links[0]->{direct_asset_url};
|
||||
my @parts = split( '/', $url);
|
||||
my $latest = $releases[0];
|
||||
my $name = $latest->{name};
|
||||
my $tag_name = $latest->{tag_name};
|
||||
my @links = @{ $latest->{assets}->{links} };
|
||||
my $url = $links[0]->{direct_asset_url};
|
||||
my @parts = split( '/', $url );
|
||||
my $filename = $parts[-1];
|
||||
next unless $url =~ m/\.kpz$/;
|
||||
my $result = {
|
||||
|
@ -114,6 +118,7 @@ if ($plugins_enabled) {
|
|||
install_url => $url,
|
||||
html_url => $web_url,
|
||||
name => $name,
|
||||
tag_name => $tag_name,
|
||||
};
|
||||
push @results, { repo => $r, result => $result };
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue