]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 399068: Remove the docs_urlbase parameter. r=LpSolit, a=dkl.
authorGervase Markham <gerv@mozilla.org>
Thu, 18 Dec 2014 16:08:19 +0000 (16:08 +0000)
committerGervase Markham <gerv@gerv.net>
Thu, 18 Dec 2014 16:08:19 +0000 (16:08 +0000)
Bugzilla/Config/Common.pm
Bugzilla/Config/General.pm
Bugzilla/Template.pm
docs/en/rst/administering/parameters.rst
template/en/default/admin/params/general.html.tmpl
template/en/default/global/common-links.html.tmpl
template/en/default/global/docslinks.html.tmpl
template/en/default/index.html.tmpl

index f7e37c6fc5f1d3cb116a0237af7553bfe548a39b..b6e58b3182ddb8347280afc2ec23cebc69b39172 100644 (file)
@@ -22,7 +22,7 @@ use Bugzilla::Status;
 
 use parent qw(Exporter);
 @Bugzilla::Config::Common::EXPORT =
-    qw(check_multi check_numeric check_regexp check_url check_group
+    qw(check_multi check_numeric check_regexp check_group
        check_sslbase check_priority check_severity check_platform
        check_opsys check_shadowdb check_urlbase check_user_verify_class
        check_ip check_mail_delivery_method check_notification check_utf8
@@ -211,15 +211,6 @@ sub check_urlbase {
     return "";
 }
 
-sub check_url {
-    my ($url) = (@_);
-    return '' if $url eq ''; # Allow empty URLs
-    if ($url !~ m:/$:) {
-        return 'must be a legal URL, absolute or relative, ending with a slash.';
-    }
-    return '';
-}
-
 sub check_user_verify_class {
     # doeditparams traverses the list of params, and for each one it checks,
     # then updates. This means that if one param checker wants to look at 
@@ -491,8 +482,6 @@ valid group is provided.
 
 =item check_smtp_auth
 
-=item check_url
-
 =item check_urlbase
 
 =item check_email
index 5efaa6f6c2a9a6571e5279f6e6cf18cabb54a43f..380680590adce7d30a3356e372928cb2516313e9 100644 (file)
@@ -24,13 +24,6 @@ use constant get_param_list => (
    checker => \&check_email
   },
 
-  {
-   name => 'docs_urlbase',
-   type => 't',
-   default => 'docs/%lang%/html/',
-   checker => \&check_url
-  },
-
   {
    name => 'utf8',
    type => 'b',
index 2b068dc2ce16175ada2f5f479cc13eb010222d3d..066f9dc3056146332a04eb970b1065ef32b845b5 100644 (file)
@@ -1028,10 +1028,38 @@ sub create {
             'urlbase' => sub { return Bugzilla::Util::correct_urlbase(); },
 
             # Allow templates to access docs url with users' preferred language
-            'docs_urlbase' => sub { 
-                my $language = Bugzilla->current_language;
-                my $docs_urlbase = Bugzilla->params->{'docs_urlbase'};
-                $docs_urlbase =~ s/\%lang\%/$language/;
+            # We fall back to English if documentation in the preferred
+            # language is not available
+            'docs_urlbase' => sub {
+                my $docs_urlbase;
+                my $lang = Bugzilla->current_language;
+                # Translations currently available on readthedocs.org
+                my @rtd_translations = ('en', 'fr');
+
+                if ($lang ne 'en' && -f "docs/$lang/html/index.html") {
+                    $docs_urlbase = "docs/$lang/html/";
+                }
+                elsif (-f "docs/en/html/index.html") {
+                    $docs_urlbase = "docs/en/html/";
+                }
+                else {
+                    if (!grep { $_ eq $lang } @rtd_translations) {
+                        $lang = "en";
+                    }
+
+                    my $version = BUGZILLA_VERSION;
+                    $version =~ /^(\d+)\.(\d+)/;
+                    if ($2 % 2 == 1) {
+                        # second number is odd; development version
+                        $version = 'latest';
+                    }
+                    else {
+                        $version = "$1.$2";
+                    }
+
+                    $docs_urlbase = "https://bugzilla.readthedocs.org/$lang/$version/";
+                }
+
                 return $docs_urlbase;
             },
 
index ce6a55f6a1a42e5ed8bb551a4109a5c9b5d42314..7302454d304a3d7abbb4c5a0f7354c41703a5639 100644 (file)
@@ -59,9 +59,6 @@ maintainer
     responsible for maintaining this Bugzilla installation.
     The address need not be that of a valid Bugzilla account.
 
-docs_urlbase
-    The URL that is the common initial leading part of all Bugzilla documentation URLs. It may be an absolute URL, or a URL relative to the :param:`urlbase` parameter. Leave this empty to suppress links to the documentation. ``%lang%`` will be replaced by user's preferred language (if documentation is available in that language).
-
 utf8
     Use UTF-8 (Unicode) encoding for all text in Bugzilla. Installations where
     this parameter is set to :paramval:`off` should set it to :paramval:`on` only
index 4c94bc747bb66af370190a0b1e62c204f62d8896..6ebef8ea21a993e5333b38ebfe15a3a4ca6e84a5 100644 (file)
     "The email address of the person who maintains this installation "
     _ " of Bugzilla.",
 
-  docs_urlbase => 
-    "The URL that is the common initial leading part of all"
-    _ " $terms.Bugzilla documentation URLs. It may be an absolute URL,"
-    _ " or a URL relative to the <var>urlbase</var> parameter. Leave this"
-    _ " empty to suppress links to the documentation."
-    _ "'%lang%' will be replaced by user's preferred language (if"
-    _ " documentation is available in that language).",
-
   utf8 => 
     "Use UTF-8 (Unicode) encoding for all text in ${terms.Bugzilla}. New"
     _ " installations should set this to true to avoid character encoding"
index ec23f551ee084ce450a239826c799dbdeb293400..78b4eb80a9205c8a795bd5726d838d0401c70bbb 100644 (file)
 
 [% Hook.process("link-row") %]
 [% BLOCK link_to_documentation %]
-    [% IF doc_section && Param('docs_urlbase') %]
+    [% IF doc_section %]
       <li>
         <span class="separator">| </span>
         <a href="[% docs_urlbase _ doc_section FILTER html %]" target="_blank">Help</a>
index c2cc830fa8268e8f37b6f5fa495dfbbbb8a2ce5f..e33aa3b17a999406049d38c4bf3bd32c35291d1d 100644 (file)
@@ -22,8 +22,7 @@
   #                 members of the admin group.
   #%]
 
-[% IF Param('docs_urlbase') &&
-      docslinks.keys.size || (admindocslinks.keys.size && user.in_group('admin')) %]
+[% IF docslinks.keys.size || (admindocslinks.keys.size && user.in_group('admin')) %]
   <div id="docslinks">
     <h2>Related documentation</h2>
     <ul>
index aa50a60e99bf187450d33328926aa9b574b6de17..84a5b7d5cdda2ffd2ff054af3ac352e5210bd1f9 100644 (file)
             href="?GoAheadAndLogIn=1"><span>Log In</span></a>
           [% END %]
       </li>
-      [% IF Param("docs_urlbase") %]
-        <li>
-          <a id="help" href="[% docs_urlbase FILTER html %]using.html"><span>Documentation</span></a>
-        </li>
-      [% END %]
+      <li>
+        <a id="help" href="[% docs_urlbase FILTER html %]using/index.html"><span>Documentation</span></a>
+      </li>
     </ul>
   </div>