]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 374540: Print out the requirements in an HTML table instead of preformatted text
authormkanat%bugzilla.org <>
Wed, 21 Mar 2007 01:39:22 +0000 (01:39 +0000)
committermkanat%bugzilla.org <>
Wed, 21 Mar 2007 01:39:22 +0000 (01:39 +0000)
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=mkanat

Bugzilla/Install/Requirements.pm
Bugzilla/Install/Util.pm
setup.cgi
skins/standard/setup.css [new file with mode: 0644]
template/en/default/setup/strings.html.pl
template/en/default/setup/strings.txt.pl

index c090fe1f4c2fe49917c5ff543030b186e07a5d95..4c62564d7874014cd80968df8ff37d40a012cc48 100644 (file)
@@ -25,7 +25,7 @@ package Bugzilla::Install::Requirements;
 
 use strict;
 
-use Bugzilla::Install::Util qw(vers_cmp);
+use Bugzilla::Install::Util qw(vers_cmp install_string is_web);
 use List::Util qw(max);
 use Safe;
 
@@ -262,11 +262,11 @@ sub _get_extension_requirements {
 sub check_requirements {
     my ($output) = @_;
 
-    print "\nChecking perl modules...\n" if $output;
+    print "\n", install_string('checking_modules'), "\n" if $output;
     my $root = ROOT_USER;
     my %missing = _check_missing(REQUIRED_MODULES, $output);
 
-    print "\nChecking available perl DBD modules...\n" if $output;
+    print "\n", install_string('checking_dbd'), "\n" if $output;
     my $have_one_dbd = 0;
     my $db_modules = DB_MODULE;
     foreach my $db (keys %$db_modules) {
@@ -274,7 +274,7 @@ sub check_requirements {
         $have_one_dbd = 1 if have_vers($dbd, $output);
     }
 
-    print "\nThe following Perl modules are optional:\n" if $output;
+    print "\n", install_string('checking_optional'), "\n" if $output;
     my %missing_optional = _check_missing(OPTIONAL_MODULES, $output);
 
     # If we're running on Windows, reset the input line terminator so that
@@ -476,15 +476,10 @@ sub have_vers {
     }
     my $wanted  = $params->{version};
 
-    my ($msg, $vnum, $vstr);
-    no strict 'refs';
-    printf("Checking for %15s %-9s ", $package, !$wanted?'(any)':"(v$wanted)") 
-        if $output;
-
     eval "require $module;";
 
     # VERSION is provided by UNIVERSAL::
-    $vnum = eval { $module->VERSION } || -1;
+    my $vnum = eval { $module->VERSION } || -1;
 
     # CGI's versioning scheme went 2.75, 2.751, 2.752, 2.753, 2.76
     # That breaks the standard version tests, so we need to manually correct
@@ -493,14 +488,15 @@ sub have_vers {
         $vnum = $1 . "." . $2;
     }
 
+    my $vstr;
     if ($vnum eq "-1") { # string compare just in case it's non-numeric
-        $vstr = "not found";
+        $vstr = install_string('module_not_found');
     }
     elsif (vers_cmp($vnum,"0") > -1) {
-        $vstr = "found v$vnum";
+        $vstr = install_string('module_found', { ver => $vnum });
     }
     else {
-        $vstr = "found unknown version";
+        $vstr = install_string('module_unknown_version');
     }
 
     my $vok = (vers_cmp($vnum,$wanted) > -1);
@@ -510,9 +506,29 @@ sub have_vers {
         $vok = 0 if $blacklisted;
     }
 
-    my $ok = $vok ? "ok:" : "";
-    my $black_string = $blacklisted ? "(blacklisted)" : "";
-    print "$ok $vstr $black_string\n" if $output;
+    if ($output) {
+        my $ok           = $vok ? install_string('module_ok') : '';
+        my $black_string = $blacklisted ? install_string('blacklisted') : '';
+        my $want_string  = $wanted ? "v$wanted" : install_string('any');
+
+        # It's impossible to do the printf formatting in the install_string
+        # system, so we do it manually below.
+        if (is_web()) {
+            print install_string('module_details',
+                { package => $package,
+                  wanted  => $want_string,
+                  found   => $vstr,
+                  ok      => $ok,
+                  blacklisted => $black_string,
+                  row_class => $vok ? 'mod_ok' : 'mod_not_ok' });
+        }
+        else {
+            $ok = "$ok:" if $ok;
+            printf "%s %19s %-9s $ok $vstr $black_string\n",
+                install_string('checking_for'), $package, "($want_string)";
+        }
+    }
+    
     return $vok ? 1 : 0;
 }
 
index bb5a84dfd68c4a9412a38f0d5971fea180b9054f..82edefb3a75eaf11202dd3cefb440629aeacf0e2 100644 (file)
@@ -37,6 +37,7 @@ our @EXPORT_OK = qw(
     get_version_and_os
     indicate_progress
     install_string
+    is_web
     vers_cmp
 );
 
@@ -80,7 +81,7 @@ sub install_string {
         $string_template = _get_string_from_file($string_id, "$base.html.pl")
             if is_web();
         $string_template = _get_string_from_file($string_id, "$base.txt.pl")
-            if !$string_template;
+            if !defined $string_template;
         last if defined $string_template;
     }
     
index 7b4aa4554188f9d8b0cd8db2fb588cf7a78cf8b3..5b3dffd96f83c7661a78488a95c957939de35107 100644 (file)
--- a/setup.cgi
+++ b/setup.cgi
@@ -53,8 +53,10 @@ print install_string('header', get_version_and_os());
 # Check Requirements #
 ######################
 
-print '<pre>';
 my $module_results = check_requirements(1);
+print '</table>';
+
+print '<pre>';
 Bugzilla::Install::Requirements::print_module_instructions($module_results, 1);
 print '</pre>';
 
diff --git a/skins/standard/setup.css b/skins/standard/setup.css
new file mode 100644 (file)
index 0000000..067b340
--- /dev/null
@@ -0,0 +1,39 @@
+/* The contents of this file are subject to the Mozilla Public
+  * License Version 1.1 (the "License"); you may not use this file
+  * except in compliance with the License. You may obtain a copy of
+  * the License at http://www.mozilla.org/MPL/
+  *
+  * Software distributed under the License is distributed on an "AS
+  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+  * implied. See the License for the specific language governing
+  * rights and limitations under the License.
+  *
+  * The Original Code is the Bugzilla Bug Tracking System.
+  *
+  * The Initial Developer of the Original Code is Everything Solved.
+  * Portions created by Everything Solved are Copyright (C) 2007 
+  * Everything Solved. All Rights Reserved.
+  *
+  * Contributor(s): Max Kanat-Alexander <mkanat@bugzilla.org>
+  */
+
+.mod_requirements {
+    border-collapse: collapse;
+    border: none;
+}
+.mod_requirements td, .mod_requirements th {
+    border: 1px solid black;
+    padding: .2em;
+}
+.mod_requirements th.mod_header { border: none; }
+.mod_name {
+    text-align: right;
+}
+
+/* If CSS is working, we don't display the "OK" column. Instead we have
+   colors and we explain them. */
+td.mod_ok, th.mod_ok { display: none; }
+.color_explanation { color: black; background-color: white }
+
+.mod_ok { color: green; }
+.mod_not_ok { color: red; }
\ No newline at end of file
index 583a37abd1e7c8e3a7fecf9c80bd054d26ce85f9..8e687e5088c62c62a8ee8109c1f4269cb9d2aee5 100644 (file)
 # setup.cgi).
 
 %strings = (
+    checking_dbd => '<tr><th colspan="4" class="mod_header">Database Modules</th></tr>',
+    checking_optional => '<tr><th colspan="4" class="mod_header">Optional Modules</th></tr>',
+    checking_modules  => <<END_HTML
+<h2>Perl Modules</h2>
+
+<div style="color: white; background-color: white">
+    <p class="color_explanation">Rows that look <span class="mod_ok">like
+    this</span> mean that you have a good version of that module installed.
+    Rows that look <span class="mod_not_ok">like this</span> mean that you
+    either don't have that module installed, or the version you have
+    installed is too old.</p>
+</div>
+    
+<table class="mod_requirements" border="1">
+<tr>
+    <th class="mod_name">Package</th>
+    <th>Version Required</th> <th>Version Found</th>
+    <th class="mod_ok">OK?</th>
+</tr>
+END_HTML
+,
+
     footer => "</div></body></html>",
 
     # This is very simple. It doesn't support the skinning system.
 <head>
     <title>Installation and Setup for Bugzilla ##bz_ver##</title>
     <link href="skins/standard/global.css" rel="stylesheet" type="text/css" />
+    <link href="skins/standard/setup.css"  rel="stylesheet" type="text/css" />
 </head>
 <body id="bugzilla-installation">
     <h1>Installation and Setup for Bugzilla ##bz_ver##</h1>
     <div id="bugzilla-body">
-    
-        <p><strong>Perl Version</strong>: ##perl_ver##</p>
-        <p><strong>OS</strong>: ##os_name## ##os_ver##</p>
+        <p><strong>Perl Version</strong>: ##perl_ver##
+          <strong>OS</strong>: ##os_name## ##os_ver##</p>
+END_HTML
+,
+    module_details => <<END_HTML
+<tr class="##row_class##">
+    <td class="mod_name">##package##</td>
+    <td class="mod_wanted">##wanted##</td>
+    <td class="mod_found">##found##</td>
+    <td class="mod_ok">##ok##</td>
+</tr>
 END_HTML
 ,
+    module_found => '##ver##',
 );
 
 1;
index b4768771c1be8d3efd8862d8675e1b428e425685..34e4478577081b49a0ca9fd3fa69ff02e7e4ddb3 100644 (file)
 # Please keep the strings in alphabetical order by their name.
 
 %strings = (
+    any  => 'any',
+    blacklisted => '(blacklisted)',
+    checking_for => 'Checking for',
+    checking_dbd      => 'Checking available perl DBD modules...',
+    checking_optional => 'The following Perl modules are optional:',
+    checking_modules  => 'Checking perl modules...',
     header => "* This is Bugzilla ##bz_ver## on perl ##perl_ver##\n"
             . "* Running on ##os_name## ##os_ver##",
+    module_found => "found v##ver##",
+    module_not_found => "not found",
+    module_ok => 'ok',
+    module_unknown_version => "found unknown version",
 );
 
 1;