Skip to content

Commit 6281ed4

Browse files
committed
notice of development release instead of link to latest doc from dev versions
1 parent f3fd8ce commit 6281ed4

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

perldoc-browser.pl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,26 @@
7979
my $perls_dir = path(app->config->{perls_dir} // app->home->child('perls'));
8080
helper perls_dir => sub ($c) { $perls_dir };
8181

82-
my (@all_versions, @perl_versions, @dev_versions, $latest_version);
82+
my (@all_versions, @perl_versions, @dev_versions, %version_is_dev, $latest_version);
8383
helper warmup_perl_versions => sub ($c) {
8484
@all_versions = -d $c->perls_dir ? $c->perls_dir->list({dir => 1})
8585
->grep(sub { -d && -x path($_)->child('bin', 'perl') })
8686
->map(sub { $_->basename })
8787
->sort(sub { versioncmp($b, $a) })->each : ();
8888

89-
(@perl_versions, @dev_versions) = ();
89+
(@perl_versions, @dev_versions, %version_is_dev) = ();
9090
$latest_version = app->config->{latest_perl_version};
9191
if (@all_versions) {
9292
foreach my $perl_version (@all_versions) {
9393
my $v = app->warmup_version_object($perl_version);
94-
if ($perl_version eq 'blead' or $perl_version =~ m/-RC[0-9]+$/) {
95-
push @dev_versions, $perl_version;
96-
} elsif ($v < version->parse('v5.6.0') and ($v->{version}[2] // 0) >= 500) {
97-
push @dev_versions, $perl_version;
98-
} elsif ($v >= version->parse('v5.6.0') and ($v->{version}[1] // 0) % 2) {
94+
if ($perl_version eq 'blead' or $perl_version =~ m/-RC[0-9]+$/
95+
or ($v < version->parse('v5.6.0') and ($v->{version}[2] // 0) >= 500)
96+
or ($v >= version->parse('v5.6.0') and ($v->{version}[1] // 0) % 2)) {
9997
push @dev_versions, $perl_version;
98+
$version_is_dev{$perl_version} = 1;
10099
} else {
101100
push @perl_versions, $perl_version;
101+
$version_is_dev{$perl_version} = 0;
102102
$latest_version //= $perl_version if defined $v;
103103
}
104104
app->warmup_inc_dirs($perl_version);
@@ -107,7 +107,13 @@
107107
$latest_version //= $all_versions[0];
108108
} else {
109109
my $current_version = $Config{version};
110-
($Config{PERL_VERSION} % 2) ? (push @dev_versions, $current_version) : (push @perl_versions, $current_version);
110+
if ($Config{PERL_VERSION} % 2) {
111+
push @dev_versions, $current_version;
112+
$version_is_dev{$current_version} = 1;
113+
} else {
114+
push @perl_versions, $current_version;
115+
$version_is_dev{$current_version} = 0;
116+
}
111117
@all_versions = $current_version;
112118
$latest_version //= $current_version;
113119
$inc_dirs{$current_version} = [@current_inc, File::Spec->catdir($Config{installprivlib}, 'pods'), $Config{scriptdir}];
@@ -126,6 +132,8 @@
126132

127133
helper latest_perl_version => sub ($c) { $latest_version };
128134

135+
helper perl_version_is_dev => sub ($c, $perl_version) { $version_is_dev{$perl_version} };
136+
129137
app->warmup_perl_versions;
130138

131139
my $csp = join '; ',

templates/perldoc.html.ep

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,12 @@
189189
% }
190190
% if (length $url_perl_version and $module ne 'search') {
191191
<div class="leading-notice">
192-
You are viewing the version of this documentation from Perl <%= $url_perl_version %>. <%= link_to 'View the latest version' => url_with(current_doc_path) %>
192+
You are viewing the version of this documentation from Perl <%= $url_perl_version %>.
193+
% if (perl_version_is_dev($perl_version)) {
194+
This is a development release of Perl.
195+
% } else {
196+
<%= link_to 'View the latest version' => url_with(current_doc_path) %>
197+
% }
193198
</div>
194199
% }
195200
% if (defined(my $alt_type = stash 'alt_page_type')) {

0 commit comments

Comments
 (0)