Permalink
Browse files

More Plackification of cpanratings

  • Loading branch information...
1 parent d7564c5 commit 2b8f811cfe5c19fb2d743c52c5e9649c4d5ff5ba @abh abh committed Jun 11, 2011
@@ -1,12 +0,0 @@
-use strict;
-use CPANRatings::Control::Rate;
-use CPANRatings::Control::Search;
-use CPANRatings::Control::Basic;
-use CPANRatings::Control::Show;
-use CPANRatings::Control::ShowAll;
-use CPANRatings::Control::Logout;
-use CPANRatings::Control::RecentRSS;
-use CPANRatings::Control::API;
-
-
-1;
@@ -1,6 +1,4 @@
- PerlRequire [% root %]/apache/conf/sites/cpanratings.pl
-
<VirtualHost *:[% config.port %]>
ServerName [% config.site.$site.servername %]
[% expandServerAliases( config.site.$site.aliases ) %]
@@ -26,11 +24,16 @@
PerlHandler CPANRatings::Control::Search->super
</Location>
- <LocationMatch ^/([da]|dist|user)/>
+ [% show_locations = [ 'd', 'a', 'dist', 'user' ];
+ FOR loc = show_locations %]
+
+ <Location /[% loc %]/>
SetHandler perl-script
PerlHandler CPANRatings::Control::Show->super
</LocationMatch>
+ [% END %]
+
<Location /csv/all_ratings.csv>
SetHandler perl-script
PerlHandler CPANRatings::Control::ShowAll->super
View
@@ -12,3 +12,11 @@ Class::DBI::mysql = 0
Class::DBI::Plugin::AbstractCount = 0
XML::RSS = 0
Template::Plugin::XML::RSS = 0
+
+
+File::Slurp = 0
+
+; to be removed
+Yahoo::Search = 0
+
+
@@ -8,9 +8,7 @@ use Combust::Constant qw(OK NOT_FOUND);
sub render {
my $self = shift;
- my $r = $self->r;
-
- my ($mode, $id, $format) = ($r->uri =~ m!^/([ad]|user|dist)/([^/]+?)(?:\.(html|rss))?$!);
+ my ($mode, $id, $format) = ($self->request->path =~ m!^/([ad]|user|dist)/([^/]+?)(?:\.(html|rss))?$!);
return 404 unless $mode and $id;
$format = $self->req_param('format') || $format || 'html';
@@ -3,8 +3,8 @@ use strict;
use base qw(CPANRatings::Control);
use Combust::DB qw(db_open);
-sub handler ($$) {
- my ($self, $r) = @_;
+sub render {
+ my $self = shift;
my $dbh = db_open;
@@ -13,13 +13,15 @@ sub handler ($$) {
$sth->execute;
- print qq["distribution","rating","review_count"\n\n];
+ my @data;
+
+ push @data, qq["distribution","rating","review_count"\n\n];
while (my $a = $sth->fetchrow_arrayref) {
- print join(",", map { qq["$_"] } @$a), "\n";
+ push @data, join(",", map { qq["$_"] } @$a), "\n";
}
- return 200;
+ return 200, join("", @data), 'text/plain';
}
1;

0 comments on commit 2b8f811

Please sign in to comment.