Skip to content

Commit

Permalink
Merge pull request #1733 from CPAN-API/topic/permalinks
Browse files Browse the repository at this point in the history
Improved links and better distinction non-latest pages
  • Loading branch information
oalders committed Jun 20, 2016
2 parents dc8684a + e48aa49 commit 959fdea
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
16 changes: 12 additions & 4 deletions lib/MetaCPAN/Web/Controller/Pod.pm
Expand Up @@ -35,7 +35,8 @@ sub release : Local : Args {
$c->detach();
}

$c->stash->{pod_file} = $c->model('API::Module')->get(@path)->recv;
$c->stash->{pod_file} = $c->model('API::Module')->get(@path)->recv;
$c->stash->{permalinks} = 1;
$c->forward( 'view', [@path] );
}

Expand Down Expand Up @@ -65,7 +66,8 @@ sub distribution : Local : Args {
sub view : Private {
my ( $self, $c, @path ) = @_;

my $data = $c->stash->{pod_file};
my $data = $c->stash->{pod_file};
my $permalinks = $c->stash->{permalinks};

if ( $data->{directory} ) {
$c->res->redirect( '/source/' . join( q{/}, @path ), 301 );
Expand All @@ -89,8 +91,14 @@ sub view : Private {
my $reqs = $self->api_requests(
$c,
{
pod => $c->model('API')
->request( $pod_path, undef, { show_errors => 1 } ),
pod => $c->model('API')->request(
$pod_path,
undef,
{
show_errors => 1,
( $permalinks ? ( permalinks => 1 ) : () )
}
),
release => $c->model('API::Release')
->get( @{$data}{qw(author release)} ),
},
Expand Down
1 change: 1 addition & 0 deletions lib/MetaCPAN/Web/Controller/Release.pm
Expand Up @@ -55,6 +55,7 @@ sub by_author_and_release : Chained('root') PathPart('') Args(2) {
$c->detach();
}

$c->stash->{permalinks} = 1;
$c->stash->{data} = $model->get( $author, $release );
$c->forward('view');
}
Expand Down
4 changes: 2 additions & 2 deletions root/inc/breadcrumbs.html
Expand Up @@ -37,13 +37,13 @@
<span class="dropdown"><b class="caret"></b></span>
<select class="<% module ? "" : "extend" %>" onchange="document.location.href=this.value"><% PROCESS version_dropdown %></select>
<% IF module %>
<a data-keyboard-shortcut="g d" class="release-name" href="/release/<% IF release.status == 'latest'; release.distribution; ELSE; [module.author, module.release].join('/'); END %>"><% release.name %></a>
<a data-keyboard-shortcut="g d" class="release-name" href="/release/<% IF permalinks; [module.author, module.release].join('/'); ELSE; release.distribution; END %>"><% release.name %></a>
<% ELSE %>
<span class="release-name"><% release.name %></span>
<% END %>
<% IF mark_unauthorized_releases && NOT release.authorized %><em class="warning">UNAUTHORIZED RELEASE</em><% END %>
</div>
<%- IF release.status != 'latest';
<%- IF permalinks;
FOREACH v IN versions; IF v.status == 'latest'; have_released = 1; END; END;
IF have_released; %>
<a class="latest" href="<% IF module %>/pod/<% module.documentation %><% ELSE %>/release/<% release.distribution; END %>" title="<%- IF release.maturity == 'developer'; 'dev release, '; END %>go to latest"><span class="fa fa-step-forward"></span></a>
Expand Down
2 changes: 1 addition & 1 deletion root/inc/release-info.html
@@ -1,5 +1,5 @@
<li>
<a data-keyboard-shortcut="g c" href="/changes/<% IF release.status == 'latest'; 'distribution/'; release.distribution; ELSE; ['release', release.author, release.name].join('/'); END %>"><i class="fa fa-fw fa-cogs black"></i>Changes</a>
<a data-keyboard-shortcut="g c" href="/changes/<% IF permalinks; ['release', release.author, release.name].join('/'); ELSE; ['distribution', release.distribution].join('/'); END %>"><i class="fa fa-fw fa-cogs black"></i>Changes</a>
</li>
<% IF is_url(release.resources.homepage) %>
<li>
Expand Down
2 changes: 1 addition & 1 deletion root/preprocess.html
Expand Up @@ -62,7 +62,7 @@
title = file.documentation || file.path;
# If there is pod for this file...
IF file.documentation || file.pod_lines.size || file.module.grep(->(module){ module.associated_pod }).size;
IF file.status == "latest";
IF !permalinks;
# If it's a PAUSE-indexed module (02packages)...
IF file.documentation
&& file.authorized
Expand Down

0 comments on commit 959fdea

Please sign in to comment.