From 7fd63f33afc8dc5177ccc254ddd9de7737c139b8 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Tue, 18 Jun 2019 02:21:34 +0000 Subject: [PATCH] Bug 16349: Scrape currently supported versions Before patch: Koha -> About -> Server Information - Only the currently running version After patch: - Currently supported versions are listed Are you sure you just want it on the web page and not in Koha itself? --- C4/Context.pm | 1 + Koha.pm | 14 ++++++++++++++ about.pl | 1 + koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 9 ++++++++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/C4/Context.pm b/C4/Context.pm index fa612472f7..9b1272e9f2 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -939,6 +939,7 @@ Gets various version info, for core Koha packages, Currently called from carp ha # A little example sub to show more debugging info for CGI::Carp sub get_versions { my %versions; + $versions{supportedVersions} = Koha::current_versions(); $versions{kohaVersion} = Koha::version(); $versions{kohaDbVersion} = C4::Context->preference('version'); $versions{osVersion} = join(" ", POSIX::uname()); diff --git a/Koha.pm b/Koha.pm index 1553fbdb0d..fc449d6a2f 100644 --- a/Koha.pm +++ b/Koha.pm @@ -19,6 +19,7 @@ package Koha; # along with Koha; if not, see . use Modern::Perl; +use WWW::Mechanize; use vars qw{ $VERSION }; @@ -35,6 +36,19 @@ sub version { return $VERSION; } +sub current_versions { + my $mechanical_scrapper = WWW::Mechanize->new(); + my @links; + eval { + $mechanical_scrapper->get('http://download.koha-community.org/'); + @links = $mechanical_scrapper->links(); + }; + my @urls_only = map { $_->url } @links; + my @versions = grep { if ($_ =~ /(koha-)([.0-9]*)(.tar.gz)$/) { $_ = $2; } } @urls_only; + my @sorted_versions = sort { $b cmp $a } @versions; + return \@sorted_versions; +} + 1; =head1 NAME diff --git a/about.pl b/about.pl index dacd39db2d..188ffbe19f 100755 --- a/about.pl +++ b/about.pl @@ -447,6 +447,7 @@ $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs; my %versions = C4::Context::get_versions(); $template->param( + supportedVersions => $versions{'supportedVersions'}, kohaVersion => $versions{'kohaVersion'}, osVersion => $versions{'osVersion'}, perlPath => $perl_path, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index 60ce4ac21d..8031236da5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -34,7 +34,14 @@ - + -- 2.11.0
Server information
Koha version: [% kohaVersion | html %]
Koha version: [% kohaVersion | html %]
+
+ Currently Supported Versions
+ [% FOREACH supportedVersion IN supportedVersions %] + [% supportedVersion | html %]
+ [% END %] + [% IF supportedVersions.size < 1 %]Unknown[% END %] +
OS version ('uname -a'): [% osVersion | html %]
Perl interpreter: [% perlPath | html %]
Perl version: [% perlVersion | html %]