From: Gervase Markham Date: Thu, 18 Dec 2014 16:08:19 +0000 (+0000) Subject: Bug 399068: Remove the docs_urlbase parameter. r=LpSolit, a=dkl. X-Git-Tag: release-5.1.1~411 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=323acaaecd742e195c718e696e3206c516ccda32;p=thirdparty%2Fbugzilla.git Bug 399068: Remove the docs_urlbase parameter. r=LpSolit, a=dkl. --- diff --git a/Bugzilla/Config/Common.pm b/Bugzilla/Config/Common.pm index f7e37c6fc5..b6e58b3182 100644 --- a/Bugzilla/Config/Common.pm +++ b/Bugzilla/Config/Common.pm @@ -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 diff --git a/Bugzilla/Config/General.pm b/Bugzilla/Config/General.pm index 5efaa6f6c2..380680590a 100644 --- a/Bugzilla/Config/General.pm +++ b/Bugzilla/Config/General.pm @@ -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', diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 2b068dc2ce..066f9dc305 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -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; }, diff --git a/docs/en/rst/administering/parameters.rst b/docs/en/rst/administering/parameters.rst index ce6a55f6a1..7302454d30 100644 --- a/docs/en/rst/administering/parameters.rst +++ b/docs/en/rst/administering/parameters.rst @@ -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 diff --git a/template/en/default/admin/params/general.html.tmpl b/template/en/default/admin/params/general.html.tmpl index 4c94bc747b..6ebef8ea21 100644 --- a/template/en/default/admin/params/general.html.tmpl +++ b/template/en/default/admin/params/general.html.tmpl @@ -16,14 +16,6 @@ "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 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 ${terms.Bugzilla}. New" _ " installations should set this to true to avoid character encoding" diff --git a/template/en/default/global/common-links.html.tmpl b/template/en/default/global/common-links.html.tmpl index ec23f551ee..78b4eb80a9 100644 --- a/template/en/default/global/common-links.html.tmpl +++ b/template/en/default/global/common-links.html.tmpl @@ -100,7 +100,7 @@ [% Hook.process("link-row") %] [% BLOCK link_to_documentation %] - [% IF doc_section && Param('docs_urlbase') %] + [% IF doc_section %]
  • | Help diff --git a/template/en/default/global/docslinks.html.tmpl b/template/en/default/global/docslinks.html.tmpl index c2cc830fa8..e33aa3b17a 100644 --- a/template/en/default/global/docslinks.html.tmpl +++ b/template/en/default/global/docslinks.html.tmpl @@ -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')) %]