Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:bricas/cpanhq
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomif committed Jul 20, 2009
2 parents 2b8c93a + 77d4835 commit c5f87d9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
3 changes: 3 additions & 0 deletions cpanhq.conf
Expand Up @@ -3,3 +3,6 @@ name CPANHQ
connect_info dbi:SQLite:dbname=__HOME__/cpanhq.db
connect_info undef
</Model::DB>
<Controller::Distribution>
graph_path __HOME__/root/dist/graph/
</Controller::Distribution>
20 changes: 13 additions & 7 deletions lib/CPANHQ/Controller/Distribution.pm
Expand Up @@ -50,23 +50,29 @@ sub show : Chained(instance) : PathPart('') : Args(0) {
my $latest = $dist->latest_release;
$latest->_process_meta_yml();

my $graph = Graph::Easy->new();
my $graph = Graph::Easy->new();
my $graph_output = File::Spec->catfile(
$c->config->{'Controller::Distribution'}->{graph_path},
$dist->name . '-' . $latest->version . '.png'
);

my $uses = $dist->uses;
my $dist_uses;
while ( my $use = $uses->next ) {
my $name = $use->dist_to->name;
push @$dist_uses, $name;
$graph->add_edge(
$latest->distribution->name,
$name,
);
$graph->add_edge( $latest->distribution->name, $name, );
}

if ( !-f $graph_output ) {
if ( open( my $png, '|-', 'dot -Tpng -o ' . $graph_output ) ) {
print $png $graph->as_graphviz;
close($png);
}
}
my $graph_output = $graph->as_ascii();
$c->stash(
release => $latest,
title => $latest->name,
graph => $graph_output,
uses => $dist_uses,
);
}
Expand Down
7 changes: 1 addition & 6 deletions root/dist/show.tt
Expand Up @@ -31,13 +31,8 @@
[% author = release.author %]
<p>By <a href="[% c.uri_for( '/author', author.cpanid ) %]">[% author.name %]</a>, released on [% release.release_date.ymd %]</p>

[% IF graph %]
<h3 id="graph">Graph</h3>
<pre>
[% graph %]
</pre>

[% END %]
<img src="/dist/graph/[% dist.name %]-[% release.version %].png" />

<h3 id="packages">Packages</h3>
<ul>
Expand Down

0 comments on commit c5f87d9

Please sign in to comment.