Skip to content

Commit

Permalink
link to MetaCPAN from the documentation browser
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 30, 2017
1 parent 741f9d3 commit 2d457b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

7.50 2017-10-30
- Improved documentation browser with links to MetaCPAN.

7.49 2017-10-28
- Deprecated Mojo::IOLoop::Delay::data and Mojo::IOLoop::Delay::remaining.
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Plugin/PODRenderer.pm
Expand Up @@ -80,10 +80,10 @@ sub _perldoc {

# Find module or redirect to CPAN
my $module = join '::', split('/', $c->param('module'));
$c->stash(cpan => "https://metacpan.org/pod/$module");
my $path
= Pod::Simple::Search->new->find($module, map { $_, "$_/pods" } @INC);
return $c->redirect_to("https://metacpan.org/pod/$module")
unless $path && -r $path;
return $c->redirect_to($c->stash('cpan')) unless $path && -r $path;

my $src = path($path)->slurp;
$c->respond_to(txt => {data => $src}, html => sub { _html($c, $src) });
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/resources/templates/mojo/perldoc.html.ep
Expand Up @@ -104,7 +104,8 @@
% $path .= "/$part";
%= link_to $part => url_for("/perldoc$path")
% }
(<%= link_to 'source' => url_for("/perldoc$path.txt") %>)
(<%= link_to 'source' => url_for("/perldoc$path.txt") %>,
<%= link_to 'CPAN' => $cpan %>)
</div>
<h1><a id="toc">TABLE OF CONTENTS</a></h1>
<ul>
Expand Down

0 comments on commit 2d457b9

Please sign in to comment.