diff --git a/lib/MetaCPAN/Web/Controller/ContributingDoc.pm b/lib/MetaCPAN/Web/Controller/ContributingDoc.pm
index aed05d54cd..c9a14497a2 100644
--- a/lib/MetaCPAN/Web/Controller/ContributingDoc.pm
+++ b/lib/MetaCPAN/Web/Controller/ContributingDoc.pm
@@ -38,7 +38,7 @@ sub get : Private {
my $file = List::Util::first { $_->{name} =~ /$contributing_re/ } @$files;
- if ( !exists $file->{path} ) {
+ if ( !$file || !exists $file->{path} ) {
my $release_info = $c->model('ReleaseInfo')->get( $author, $release );
$c->stash( $release_info->get );
$c->stash( {
@@ -47,17 +47,11 @@ sub get : Private {
$c->response->status(404);
}
else {
- if ( $file->{pod_lines} && @{ $file->{pod_lines} } ) {
- $c->stash(
- author_name => $author,
- release_name => $release,
- );
- $c->forward( '/view/release', [ $file->{path} ] );
- }
- else {
- $c->forward( '/source/view',
- [ $file->{author}, $file->{release}, $file->{path} ] );
- }
+ $c->stash(
+ author_name => $author,
+ release_name => $release,
+ );
+ $c->forward( '/view/release', [ $file->{path} ] );
}
}
diff --git a/lib/MetaCPAN/Web/Controller/MD.pm b/lib/MetaCPAN/Web/Controller/MD.pm
new file mode 100644
index 0000000000..b998e73e3d
--- /dev/null
+++ b/lib/MetaCPAN/Web/Controller/MD.pm
@@ -0,0 +1,22 @@
+package MetaCPAN::Web::Controller::MD;
+
+use Moose;
+
+use namespace::autoclean;
+
+BEGIN { extends 'MetaCPAN::Web::Controller' }
+
+sub view : Private {
+ my ( $self, $c, $author, $release, @path ) = @_;
+
+ my $source = $c->model('API::File')->source( $author, $release, @path );
+
+ $c->stash( {
+ source => $source->get->{raw},
+ template => 'md.tx',
+ } );
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
diff --git a/lib/MetaCPAN/Web/Controller/Pod.pm b/lib/MetaCPAN/Web/Controller/Pod.pm
index 6d606b8f6b..0f5f60b2ad 100644
--- a/lib/MetaCPAN/Web/Controller/Pod.pm
+++ b/lib/MetaCPAN/Web/Controller/Pod.pm
@@ -29,7 +29,7 @@ sub find : Path : Args(1) {
# TODO: Disambiguate if there's more than one match. #176
- $c->forward( 'view', [@path] );
+ $c->forward( '/view/file', [@path] );
}
sub view : Private {
@@ -70,11 +70,6 @@ sub view : Private {
$c->detach('/not_found')
if ( $pod->{code} || 0 ) > 399;
- # Store at fastly for a year - as we will purge!
- $c->cdn_max_age('1y');
- $c->add_dist_key( $release->{distribution} );
- $c->add_author_key( $release->{author} );
-
if ( $data->{deprecated} ) {
$c->stash->{notification} ||= { type => 'MODULE_DEPRECATED' };
}
diff --git a/lib/MetaCPAN/Web/Controller/View.pm b/lib/MetaCPAN/Web/Controller/View.pm
index 530c58f2ab..75084492f8 100644
--- a/lib/MetaCPAN/Web/Controller/View.pm
+++ b/lib/MetaCPAN/Web/Controller/View.pm
@@ -31,7 +31,7 @@ sub dist : Chained('/dist/root') PathPart('view') Args {
%$release_data, file => $c->model('API::File')->get(@path)->get,
} );
- $c->forward( '/pod/view', [@path] );
+ $c->forward( 'file', [@path] );
}
sub release : Chained('/release/root') PathPart('view') Args {
@@ -52,7 +52,31 @@ sub release : Chained('/release/root') PathPart('view') Args {
permalinks => 1,
} );
- $c->forward( '/pod/view', [ $author, $release, @path ] );
+ $c->forward( 'file', [ $author, $release, @path ] );
+}
+
+sub file : Private {
+ my ( $self, $c, @path ) = @_;
+
+ my $release = $c->stash->{release};
+ my $file = $c->stash->{file};
+
+ $c->cdn_max_age('1y');
+ $c->add_dist_key( $release->{distribution} );
+ $c->add_author_key( $release->{author} );
+
+ if ( $file->{mime} eq 'text/x-script.perl'
+ || $file->{mime} eq 'text/x-script.perl-module'
+ || $file->{mime} eq 'text/x-pod' )
+ {
+ $c->forward( '/pod/view', \@path );
+ }
+ elsif ( $file->{mime} eq 'text/markdown' ) {
+ $c->forward( '/md/view', \@path );
+ }
+ else {
+ $c->forward( '/source/view', \@path );
+ }
}
__PACKAGE__->meta->make_immutable;
diff --git a/lib/MetaCPAN/Web/Model/API.pm b/lib/MetaCPAN/Web/Model/API.pm
index 24fc67197d..debe3a08f7 100644
--- a/lib/MetaCPAN/Web/Model/API.pm
+++ b/lib/MetaCPAN/Web/Model/API.pm
@@ -19,6 +19,17 @@ use Try::Tiny qw( catch try );
use URI ();
use URI::Escape qw( uri_escape );
+use Data::Dump ();
+use Data::Dump::Filtered ();
+
+Data::Dump::Filtered::add_dump_filter( sub {
+ my ( $ctx, $object_ref ) = @_;
+ if ( $ctx->object_isa('IO::Async::Loop') ) {
+ return { dump => "bless({ '...' => '...' }, '" . $ctx->class . "')" };
+ }
+ return undef;
+} );
+
my $loop;
sub loop {
diff --git a/root/base.tx b/root/base.tx
index a60a66599c..d7af8c6c63 100644
--- a/root/base.tx
+++ b/root/base.tx
@@ -132,7 +132,7 @@
%% block breadcrumbs -> { }
-
+
%% block content -> { }