Permalink
Browse files

parse abstract from dist, display it on release page, dist page and r…

…ecent feed.
  • Loading branch information...
1 parent 6aaf18a commit 2836af18bf36d70e4330efc24f20ef0417c6240f @bricas committed Nov 5, 2011
Showing with 22 additions and 2 deletions.
  1. +1 −0 Makefile.PL
  2. +8 −2 bin/indexer.pl
  3. +6 −0 lib/CPAN/Changes/Web.pm
  4. +5 −0 lib/CPAN/Changes/Web/Schema/Result/Release.pm
  5. +1 −0 views/dist/dist.tt
  6. +1 −0 views/dist/release.tt
View
@@ -16,6 +16,7 @@ WriteMakefile(
'YAML' => 0,
'Dancer' => 1.3020, # required for ':script'
# App requirements
+ 'CPAN::Meta' => 0,
'Dancer::Plugin::DBIC' => 0,
'DBIx::Class' => 0,
'Template' => 0,
View
@@ -15,6 +15,7 @@
use CPAN::Mini::Visit;
use CPAN::DistnameInfo;
use Getopt::Long;
+use CPAN::Meta;
GetOptions(
'resume|r' => \my $resume,
@@ -40,7 +41,7 @@
CPAN::Mini::Visit->new(
minicpan => $minicpan || undef,
- callback => \&parse_changelogs,
+ callback => \&parse_dist,
ignore => [ \&skip_existing ],
prefer_bin => 1,
%visitopts,
@@ -71,9 +72,14 @@ sub skip_existing {
return ( !$exists || $force ) ? 0 : 1;
}
-sub parse_changelogs {
+sub parse_dist {
my $job = shift;
+ my ( $metafile ) = glob( 'META.*' );
+ if( $metafile && ( my $meta = eval { CPAN::Meta->load_file( $metafile ) } ) ) {
+ $release->abstract( $meta->abstract );
+ }
+
if ( !-f 'Changes' ) {
$release->update( { failure => 'No "Changes" file found.' } );
return;
View
@@ -370,6 +370,7 @@ sub _releases_to_entries {
while ( my $release = $releases->next ) {
my( $tmpl, @args );
+
if( $release->failure ) {
$tmpl = '<pre style="color:red">ERROR: %s</pre><p>Diff from previous:</p><pre>%s</pre>';
@args = ( $release->failure, $release->text_diff_from() );
@@ -380,6 +381,11 @@ sub _releases_to_entries {
}
my $content = sprintf( $tmpl, map { HTML::Entities::encode_entities $_ } @args );
+
+ if( my $abstract = $release->abstract ) {
+ $content = sprintf( '<p>%s</p>', HTML::Entities::encode_entities $abstract ) . $content;
+ }
+
my $link = uri_for(
'/'
. join(
@@ -35,6 +35,11 @@ __PACKAGE__->add_columns(
data_type => 'datetime',
is_nullable => 0,
},
+ abstract => {
+ data_type => 'varchar',
+ size => 1024,
+ is_nullable => 1,
+ },
changes_fulltext => {
data_type => 'text',
is_nullable => 1,
View
@@ -1,4 +1,5 @@
<h2><% params.dist %> (<a href="<% request.base %>dist/<% params.dist %>/feed">feed</a>)</h2>
+<p><strong>Abstract:</strong> <% releases.single.abstract | html %></p>
<p><strong>Links:</strong> <a href="http://metacpan.org/release/<% params.dist %>">metacpan</a>, <a href="http://search.cpan.org/dist/<% params.dist %>">search.cpan</a></p>
<p><strong>Show:</strong> <a href="#" id=showall>All</a>, <a href="#" id=showpass>Passes</a>, <a href="#" id=showfail>Fails</a>
<div id=status>
View
@@ -1,4 +1,5 @@
<h2><a href="<% dist_uri %>/<% params.dist %>"><% params.dist %></a> <% params.version %> (<a href="<% author_uri %>/<% release.author %>"><% release.author %></a>)</h2>
+<p><strong>Abstract:</strong> <% release.abstract | html %></p>
<p><strong>Links:</strong> <a href="http://metacpan.org/release/<% release.author %>/<% params.dist %>-<% params.version %>">metacpan</a>, <a href="http://search.cpan.org/dist/<% params.dist %>-<% params.version %>">search.cpan</a></p>
<% IF release.failure %>
<p class=error>ERROR: <% release.failure %></p>

0 comments on commit 2836af1

Please sign in to comment.