Permalink
Browse files

updates for cpanmail.cgi and linking files

  • Loading branch information...
1 parent 087bedf commit c54c2f0ebc130d498d0e40c96c5e7d03312556d1 @barbie committed Nov 10, 2011
View
@@ -1,5 +1,11 @@
Revision history for CPAN-Testers-WWW-Statistics
+0.95 current
+ - removed NNTP code from cpanmail.cgi.
+ - added cpanmail.ini to cgi templates.
+ - don't overwrite basic files in case they have changed.
+ - added the ability to link basic files.
+
0.94 21/08/2011
- revised banner logo image by Jon 'JJ' Allen.
- update to MANIFEST to include missing layout images.
View
@@ -56,6 +56,7 @@ t/data/missing-in-action.txt
t/expected.zip
templates/archive.html
templates/cgi-bin/cpanmail.cgi
+templates/cgi-bin/cpanmail.ini
templates/cpanmail-response.html
templates/cpanmail.html
templates/css/layout_setup.css
View
@@ -1,6 +1,6 @@
{
"name": "CPAN-Testers-WWW-Statistics",
- "version": "0.94",
+ "version": "0.95",
"abstract": "Scripts to create the CPAN Testers Statistics website",
"author": [
"Barbie (BARBIE) <barbie@cpan.org>"
@@ -30,7 +30,6 @@
"DBI": "0",
"DBD::mysql": "0",
"DBD::SQLite": "1.07",
- "Email::Simple": "0",
"File::Basename": "0",
"File::Copy": "0",
"File::Path": "0",
@@ -59,7 +58,7 @@
},
"recommends": {
"Test::CPAN::Meta": "0.13",
- "Test::JSON::Meta": "0.08",
+ "Test::CPAN::Meta::JSON": "0.10",
"Test::MockObject": "0",
"Test::Pod": "1.00",
"Test::Pod::Coverage": "0.08"
@@ -70,15 +69,15 @@
"provides": {
"CPAN::Testers::WWW::Statistics": {
"file": "lib/CPAN/Testers/WWW/Statistics.pm",
- "version": "0.94"
+ "version": "0.95"
},
"CPAN::Testers::WWW::Statistics::Page": {
"file": "lib/CPAN/Testers/WWW/Statistics/Page.pm",
- "version": "0.94"
+ "version": "0.95"
},
"CPAN::Testers::WWW::Statistics::Graphs": {
"file": "lib/CPAN/Testers/WWW/Statistics/Graphs.pm",
- "version": "0.94"
+ "version": "0.95"
}
},
"no_index": {
View
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: CPAN::Testers::WWW::Statistics
-version: 0.94
+version: 0.95
abstract: Scripts to create the CPAN Testers Statistics website
author:
- Barbie <barbie@cpan.org>
@@ -18,7 +18,6 @@ requires:
DBD::mysql: 0
DBD::SQLite: 0
GD::Graph::lines: 0
- Email::Simple: 0
File::Basename: 0
File::Copy: 0
File::Path: 0
@@ -36,7 +35,7 @@ requires:
Time::Piece: 0
recommends:
Test::CPAN::Meta: 0.13
- Test::JSON::Meta: 0.08
+ Test::CPAN::Meta::JSON: 0.10
Test::More: 0.70
Test::MockObject: 0
Test::Pod: 1.00
@@ -51,13 +50,13 @@ build_requires:
provides:
CPAN::Testers::WWW::Statistics:
file: lib/CPAN/Testers/WWW/Statistics.pm
- version: 0.94
+ version: 0.95
CPAN::Testers::WWW::Statistics::Graphs:
file: lib/CPAN/Testers/WWW/Statistics/Graphs.pm
- version: 0.94
+ version: 0.95
CPAN::Testers::WWW::Statistics::Pages:
file: lib/CPAN/Testers/WWW/Statistics/Pages.pm
- version: 0.94
+ version: 0.95
resources:
repository: http://github.com/barbie/cpan-testers-www-statistics
View
@@ -27,7 +27,6 @@ WriteMakefile(
# for cgimail.pl
CGI => 0,
- Email::Simple => 0,
# for database access
CPAN::Testers::Common::DBUtils => 0.03,
@@ -51,7 +51,10 @@ dbpass=password
[TOCOPY]
LIST=<<HERE
cgi-bin/cpanmail.cgi
+cgi-bin/cpanmail.ini
favicon.ico
+css/layout_setup.css
+css/layout_text.css
css/layout_wide.css
HERE
@@ -71,7 +74,7 @@ LIST=<<HERE
199901-200412
200301-200712
200601-201012
-201001-201107
+201001-201110
HERE
[CPAN_RANGES]
@@ -80,7 +83,7 @@ LIST=<<HERE
199901-200412
200301-200712
200601-201012
-201001-201107
+201001-201110
HERE
@@ -5,7 +5,7 @@ use warnings;
use strict;
use vars qw($VERSION);
-$VERSION = '0.94';
+$VERSION = '0.95';
#----------------------------------------------------------------------------
@@ -122,6 +122,13 @@ sub new {
my @TOCOPY = split("\n", $cfg->val('TOCOPY','LIST'));
$self->tocopy(\@TOCOPY);
+ my %TOLINK;
+ for my $link ($cfg->Params('TOLINK')) {
+ my $file = $cfg->val('TOLINK',$link));
+ $TOLINK{$link} = $file;
+ }
+ $self->tolink(\%TOLINK);
+
$self->mainstore( _defined_or( $hash{mainstore}, $cfg->val('MASTER','mainstore' ) ));
$self->leadstore( _defined_or( $hash{leadstore}, $cfg->val('MASTER','leadstore' ) ));
$self->monthstore(_defined_or( $hash{monthstore}, $cfg->val('MASTER','monthstore'), 'cpanstats-%s.json' ));
@@ -207,7 +214,7 @@ Returns the print form of a recorded OS name.
__PACKAGE__->mk_accessors(
qw( directory mainstore leadstore monthstore templates database address
builder missing mailrc logfile logclean copyright noreports tocopy
- osnames));
+ tolink osnames));
sub make_pages {
my $self = shift;
@@ -348,7 +355,7 @@ http://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Testers-WWW-Statistics
=head1 SEE ALSO
L<CPAN::Testers::Data::Generator>,
-L<CPAN::WWW::Testers>
+L<CPAN::Testers::WWW::Reports>
F<http://www.cpantesters.org/>,
F<http://stats.cpantesters.org/>,
@@ -4,7 +4,7 @@ use warnings;
use strict;
use vars qw($VERSION);
-$VERSION = '0.94';
+$VERSION = '0.95';
#----------------------------------------------------------------------------
@@ -382,7 +382,7 @@ http://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Testers-WWW-Statistics
=head1 SEE ALSO
L<CPAN::Testers::Data::Generator>,
-L<CPAN::WWW::Testers>
+L<CPAN::Testers::WWW::Reports>
F<http://www.cpantesters.org/>,
F<http://stats.cpantesters.org/>,
@@ -4,7 +4,7 @@ use warnings;
use strict;
use vars qw($VERSION);
-$VERSION = '0.94';
+$VERSION = '0.95';
#----------------------------------------------------------------------------
@@ -542,18 +542,35 @@ sub _write_basics {
# copy files
$self->{parent}->_log("copying static files");
my $tocopy = $self->{parent}->tocopy;
- foreach my $filename (@$tocopy) {
- my $src = $templates . "/$filename";
- if(-f $src) {
- my $dest = $directory . "/$filename";
- mkpath( dirname($dest) );
- if(-d dirname($dest)) {
- copy( $src, $dest );
+ for my $filename (@$tocopy) {
+ my $source = $templates . "/$filename";
+ if(-f $source) {
+ my $target = $directory . "/$filename";
+ next if(-f $target);
+
+ mkpath( dirname($target) );
+ if(-d dirname($target)) {
+ copy( $source, $target );
} else {
- warn "Missing directory: $dest\n";
+ warn "Missing directory: $target\n";
}
} else {
- warn "Missing file: $src\n";
+ warn "Missing file: $source\n";
+ }
+ }
+
+ #link files
+ $self->{parent}->_log("linking static files");
+ my $tolink = $self->{parent}->tolink;
+ for my $filename (keys %$tolink) {
+ my $source = $directory . "/$filename";
+ my $target = $directory . '/'.$tolink->{$filename};
+
+ next if(-f $target);
+ if(-f $source) {
+ link($target,$source);
+ } else {
+ warn "Missing file: $source\n";
}
}
}
@@ -1887,7 +1904,7 @@ http://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Testers-WWW-Statistics
=head1 SEE ALSO
L<CPAN::Testers::Data::Generator>,
-L<CPAN::WWW::Testers>
+L<CPAN::Testers::WWW::Reports>
F<http://www.cpantesters.org/>,
F<http://stats.cpantesters.org/>,
@@ -2,7 +2,7 @@
use strict;
$|++;
-my $VERSION = '0.05';
+my $VERSION = '0.06';
#----------------------------------------------------------------------------
@@ -29,9 +29,6 @@ use CGI;
#use CGI::Carp qw(fatalsToBrowser);
use Config::IniFiles;
use CPAN::Testers::Common::DBUtils;
-use CPAN::Testers::Common::Utils qw(nntp_to_guid guid_to_nntp);
-use Email::Simple;
-use Net::NNTP;
use Template;
# -------------------------------------
@@ -46,20 +43,14 @@ my %tvars;
# Program
my $cgi = CGI->new();
-my $nntpid = $cgi->param('nntpid'); # old style
-my $id = $cgi->param('id'); # new style
+my $id = $cgi->param('id'); # new style
-if($nntpid && $nntpid =~ /^(\d+)$/) {
- $tvars{guid} = nntp_to_guid($1);
-} elsif($id && $id =~ /^(\d+)$/) {
+if($id && $id =~ /^(\d+)$/) {
$tvars{id} = $1;
} elsif($id && $id =~ /^([-\w]+)$/) {
$tvars{guid} = $1;
}
-#$tvars{nntpid} = $cgi->param('nntpid');
-#$tvars{nntpid} =~ s/\D+//g if($tvars{nntpid});
-
my $found = 0;
if($tvars{id} || $tvars{guid}) {
if(-f $CONFIG) {
@@ -69,15 +60,7 @@ if($tvars{id} || $tvars{guid}) {
);
}
- # currently fallback is only an NNTP lookup, may want to add
- # a Metabase lookup at some point.
-
- if(!$found && $tvars{guid}) {
- $tvars{nntpid} = guid_to_nntp($tvars{guid});
- $found = retrieve_from_nntp($tvars{nntpid});
- } else {
- $found ||= 5;
- }
+ $found ||= 5;
} else {
$found = 3;
}
@@ -129,34 +112,6 @@ sub retrieve_from_db {
return 1;
}
-=item retrieve_from_nntp
-
-Very simplistic NNTP server look up to parse the required article.
-
-=cut
-
-sub retrieve_from_nntp {
- my $id = shift;
- return 5 unless($id);
-
- my $nntp = Net::NNTP->new("nntp.perl.org")
- || return 9; #die "Cannot connect to nntp.perl.org";
-
- my($num, $first, $last) = $nntp->group("perl.cpan.testers");
- return 4 if($id < $first || $id > $last);
-
- my $article = join "", @{$nntp->article($id) || []};
- return 0 unless($article); # no article for that id!
-
- my $mail = Email::Simple->new($article);
- return 0 unless $mail;
-
- $tvars{from} = $mail->header("From");
- $tvars{subject} = $mail->header("Subject");
-
- return 1;
-}
-
=item write_results
Outputs the results using Template Toolkit
@@ -203,7 +158,7 @@ be forthcoming, please feel free to (politely) remind me.
=head1 SEE ALSO
-L<Net::NNTP>.
+L<CPAN::Testers::WWW::Statistics>.
F<http://stats.cpantesters.org/>
@@ -214,7 +169,7 @@ F<http://stats.cpantesters.org/>
=head1 COPYRIGHT AND LICENSE
- Copyright (C) 2005-2010 Barbie for Miss Barbell Productions.
+ Copyright (C) 2005-2011 Barbie for Miss Barbell Productions.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
@@ -0,0 +1,8 @@
+; CPANSTATS (MySQL version) database configuration
+
+[CPANSTATS]
+driver=mysql
+database=cpanstats
+dbhost=localhost
+dbuser=username
+dbpass=password

0 comments on commit c54c2f0

Please sign in to comment.