Skip to content

Commit

Permalink
Bug 399068: Remove the docs_urlbase parameter. r=LpSolit, a=glob.
Browse files Browse the repository at this point in the history
  • Loading branch information
gerv authored and Gervase Markham committed Dec 22, 2014
1 parent 5d0b206 commit 1d1bb36
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 30 deletions.
7 changes: 0 additions & 7 deletions Bugzilla/Config/General.pm
Expand Up @@ -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',
Expand Down
36 changes: 32 additions & 4 deletions Bugzilla/Template.pm
Expand Up @@ -1037,10 +1037,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;
},

Expand Down
3 changes: 0 additions & 3 deletions docs/en/rst/administering/parameters.rst
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions template/en/default/admin/params/general.html.tmpl
Expand Up @@ -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 <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"
Expand Down
2 changes: 1 addition & 1 deletion template/en/default/global/common-links.html.tmpl
Expand Up @@ -100,7 +100,7 @@

[% 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>
Expand Down
3 changes: 1 addition & 2 deletions template/en/default/global/docslinks.html.tmpl
Expand Up @@ -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>
Expand Down
8 changes: 3 additions & 5 deletions template/en/default/index.html.tmpl
Expand Up @@ -83,11 +83,9 @@
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>

Expand Down

0 comments on commit 1d1bb36

Please sign in to comment.