VersionPage.pm 6.31 KB
Newer Older
Keith Jolley's avatar
Keith Jolley committed
1
#Written by Keith Jolley
Keith Jolley's avatar
Keith Jolley committed
2
#Copyright (c) 2010-2014, University of Oxford
Keith Jolley's avatar
Keith Jolley committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#E-mail: keith.jolley@zoo.ox.ac.uk
#
#This file is part of Bacterial Isolate Genome Sequence Database (BIGSdb).
#
#BIGSdb is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#BIGSdb is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with BIGSdb.  If not, see <http://www.gnu.org/licenses/>.
package BIGSdb::VersionPage;
use strict;
21
use warnings;
22
use 5.010;
Keith Jolley's avatar
Keith Jolley committed
23
use parent qw(BIGSdb::Page);
Keith Jolley's avatar
Keith Jolley committed
24

25
26
sub set_pref_requirements {
	my ($self) = @_;
27
	$self->{'pref_requirements'} = { general => 0, main_display => 0, isolate_display => 0, analysis => 0, query_field => 0 };
28
29
30
	return;
}

Keith Jolley's avatar
Keith Jolley committed
31
sub print_content {
32
	my ($self) = @_;
Keith Jolley's avatar
Keith Jolley committed
33
34
	print <<"HTML";

35
<h1>Bacterial Isolate Genome Sequence Database (BIGSdb)</h1>
Keith Jolley's avatar
Keith Jolley committed
36
<div class="box" id="resultstable">
37
38
<h2>Version $BIGSdb::main::VERSION</h2>
<p>Written by Keith Jolley<br />
Keith Jolley's avatar
Keith Jolley committed
39
Copyright &copy; University of Oxford, 2010-2014.<br />
Keith Jolley's avatar
Keith Jolley committed
40
<a href="http://www.biomedcentral.com/1471-2105/11/595">Jolley &amp; Maiden <i>BMC Bioinformatics</i> 2010, <b>11:</b>595</a></p>
Keith Jolley's avatar
Keith Jolley committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<p>
BIGSdb is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.</p>

<p>BIGSdb is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.</p>

<p>Full details of the GNU General Public License
can be found at <a href="http://www.gnu.org/licenses/gpl.html">http://www.gnu.org/licenses/gpl.html</a>.</p>

<p>Details of this software and the latest version can be downloaded from 
56
<a href="http://pubmlst.org/software/database/bigsdb/">
Keith Jolley's avatar
Keith Jolley committed
57
58
http://pubmlst.org/software/database/bigsdb/</a>.</p>
HTML
59
	$self->_print_plugins;
60
	$self->_print_software_versions;
61
	say "</div>";
62
	return;
Keith Jolley's avatar
Keith Jolley committed
63
64
65
66
67
68
}

sub get_title {
	return "BIGSdb Version $BIGSdb::main::VERSION";
}

69
70
sub _print_plugins {
	my ($self) = @_;
71
	say "<h2>Installed plugins</h2>";
72
	my $plugins = $self->{'pluginManager'}->get_installed_plugins;
73
74
	if ( !keys %{$plugins} ) {
		say "<p>No plugins installed</p>";
75
76
		return;
	}
77
78
79
	say "<p>Plugins may be disabled by the system administrator for specific databases where either they're not appropriate"
	  . " or if they may take up too many resources on a public database.</p>";
	my ( $enabled_buffer, $disabled_buffer, %disabled_reason );
80
	my $dbtype = $self->{'system'}->{'dbtype'};
81
82
83
	my $etd    = 1;
	my $dtd    = 1;
	foreach ( sort { $a cmp $b } keys %{$plugins} ) {
84
85
86
87
		my $attr = $plugins->{$_};
		if ( $attr->{'requires'} ) {
			$disabled_reason{$_} = 'Chartdirector not installed.'
			  if !$self->{'config'}->{'chartdirector'}
88
			  && $attr->{'requires'} =~ /chartdirector/;
89
			$disabled_reason{$_} = 'Reference database not configured.'
90
			  if !$self->{'config'}->{'ref_db'}
91
			  && $attr->{'requires'} =~ /ref_?db/;
92
93
			$disabled_reason{$_} = 'EMBOSS not installed.'
			  if !$self->{'config'}->{'emboss_path'}
94
			  && $attr->{'requires'} =~ /emboss/;
95
96
			$disabled_reason{$_} = 'MUSCLE not installed.'
			  if !$self->{'config'}->{'muscle_path'}
97
			  && $attr->{'requires'} =~ /muscle/;
98
99
			$disabled_reason{$_} = 'ImageMagick mogrify not installed.'
			  if !$self->{'config'}->{'mogrify_path'}
100
			  && $attr->{'requires'} =~ /mogrify/;
101
102
			$disabled_reason{$_} = 'Offline job manager not running.'
			  if !$self->{'config'}->{'jobs_db'}
103
			  && $attr->{'requires'} =~ /offline_jobs/;
104
105
106
		}
		$disabled_reason{$_} = 'Not specifically enabled for this database.'
		  if (
107
108
			   !( ( $self->{'system'}->{'all_plugins'} // '' ) eq 'yes' )
			&& $attr->{'system_flag'}
109
110
111
			&& (  !$self->{'system'}->{ $attr->{'system_flag'} }
				|| $self->{'system'}->{ $attr->{'system_flag'} } eq 'no' )
		  );
112
113
		$disabled_reason{$_} = 'Only for ' . ( $dbtype eq 'isolates' ? 'seqdef' : 'isolate' ) . ' databases.'
		  if $attr->{'dbtype'} !~ /$dbtype/;
114
		my $comments = '';
115
		if ( defined $attr->{'min'} && defined $attr->{'max'} ) {
116
			$comments .= "Limited to queries with between $attr->{'min'} and $attr->{'max'} results.";
117
		} elsif ( defined $attr->{'min'} ) {
118
			$comments .= "Limited to queries with at least $attr->{'min'} results.";
119
		} elsif ( defined $attr->{'max'} ) {
120
121
			$comments .= "Limited to queries with fewer than $attr->{'max'} results.";
		}
122
		my $author = defined $attr->{'email'}
123
124
		  && $attr->{'email'} ne '' ? "<a href=\"mailto:$attr->{'email'}\">$attr->{'author'}</a>" : $attr->{'author'};
		$author .= " ($attr->{'affiliation'})" if $attr->{'affiliation'};
125
126
		my $name = defined $attr->{'url'} ? "<a href=\"$attr->{'url'}\">$attr->{'name'}</a>" : $attr->{'name'};
		my $row_buffer = "<td>$name</td><td>$author</td><td>$attr->{'description'}</td><td>$attr->{'version'}</td>";
127
		if ( $disabled_reason{$_} ) {
128
129
130
131
132
133
134
			$disabled_buffer .= "<tr class=\"td$dtd\">$row_buffer<td>$disabled_reason{$_}</td></tr>";
			$dtd = $dtd == 1 ? 2 : 1;
		} else {
			$enabled_buffer .= "<tr class=\"td$etd\">$row_buffer<td>$comments</td></tr>";
			$etd = $etd == 1 ? 2 : 1;
		}
	}
135
136
137
138
139
140
	if ( $enabled_buffer || $disabled_buffer ) {
		say "<table class=\"resultstable\">";
		if ($enabled_buffer) {
			say "<tr><th colspan=\"5\">Enabled plugins</th></tr>";
			say "<tr><th>Name</th><th>Author</th><th>Description</th><th>Version</th><th>Comments</th></tr>";
			say $enabled_buffer;
141
		}
142
143
144
145
		if ($disabled_buffer) {
			say "<tr><th colspan=\"5\">Disabled plugins</th></tr>";
			say "<tr><th>Name</th><th>Author</th><th>Description</th><th>Version</th><th>Disabled because</th></tr>";
			say $disabled_buffer;
146
		}
147
148
		say "</table>";
	}
149
150
	return;
}
151
152
153
154
155

sub _print_software_versions {
	my ($self) = @_;
	my $q = $self->{'cgi'};
	say "<h2>Software versions</h2>";
156
	my $pg_version = $self->{'datastore'}->run_query("SELECT version()");
157
158
159
160
161
162
163
164
	say "<ul>";
	say "<li>Perl $]</li>";
	say "<li>$pg_version</li>";
	my $apache = $q->server_software;
	say "<li>$apache</li>";
	say "</ul>";
	return;
}
165
1;