Skip to content

Commit

Permalink
emove more unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Mar 30, 2024
1 parent 00f65c4 commit b5460c8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 87 deletions.
13 changes: 4 additions & 9 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ WriteMakefile(
'DateTime::Format::ICal' => 0,
'DateTime::Duration' => 0,
'DateTime::Tiny' => 0, #test fails and we should probably stop using it
'Email::Valid' => 1.193,
'File::Find::Rule' => 0.33,
'Hash::Merge::Simple' => 0.051,
'Moo' => 1.006000,
'Path::Tiny' => 0,
Expand All @@ -38,13 +36,10 @@ WriteMakefile(
'JSON' => 2.90,
'Cpanel::JSON::XS' => 3.0115,
'Web::Feed' => 0.07,
'Digest::SHA' => 5.92,
'Data::Structure::Util' => 0,

'Crypt::URandom' => 0, # recommended by Dancer2
'Math::Random::ISAAC::XS' => 0, # recommended by Dancer2
'Scope::Upper' => 0, # recommended by Dancer2
'URL::Encode::XS' => 0, # recommended by Dancer2
'Crypt::URandom' => 0, # recommended by Dancer2
'Math::Random::ISAAC::XS' => 0, # recommended by Dancer2
'Scope::Upper' => 0, # recommended by Dancer2
'URL::Encode::XS' => 0, # recommended by Dancer2

# needed for bin/perl_analyze.pl
'JSON::XS' => 0, # should be replaced!
Expand Down
69 changes: 1 addition & 68 deletions lib/Perl/Maven.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ use Perl::Maven::Debug qw(tmplog);
use Perl::Maven::Config;
use Perl::Maven::Page;
use Perl::Maven::Tools;
use Perl::Maven::WebTools
qw(get_ip mymaven pm_template read_tt pm_show_abstract pm_show_page authors pm_message);
use Perl::Maven::WebTools qw(get_ip mymaven pm_template read_tt pm_show_abstract pm_show_page authors);

require Perl::Maven::Consultants;

Expand Down Expand Up @@ -86,13 +85,6 @@ hook before => sub {
return;
};

# this just takes up disk space
#hook after => sub {
# my ($response) = @_;
# log_request();
# return;
#};

hook before_template => sub {
my $t = shift;
$t->{title} ||= '';
Expand Down Expand Up @@ -1027,65 +1019,6 @@ sub is_bot {

}

sub log_request {

# It seems uri is not set when accessing images on the development server
my $uri = request->uri;
return if not defined $uri;
return if $uri =~ m{^/img/};
return if $uri =~ m{^/download/};

my $time = time;
my $dir = path( config->{appdir}, 'logs' );
mkdir $dir if not -e $dir;
my $file = path( $dir, POSIX::strftime( '%Y-%m-%d-requests.log', gmtime($time) ) );

my $ip = get_ip();
my $page =

my %details = (
sid => setting('sid'),
time => $time,
host => request->host,
page => request->uri,
referrer => scalar( request->referer ),
ip => $ip,
user_agent => scalar( request->user_agent ),
status => response->status,
);

if ( request->query_string ) {
$details{query_string} = request->query_string;
}
if ( $details{page} =~ m{^/autocomplete.json/(.+)} ) {
$details{autocomplete} = $1;
}
if ( $details{page} =~ m{^/search/(.+)} ) {
$details{search} = $1;
}
my $start_time = setting('start_time');

if ($start_time) {
$details{elapsed_time} = Time::HiRes::time - $start_time;
}

return if response->status != 200;
return if $uri =~ m{^/atom};
return if $uri =~ m{^/robots.txt};

return if is_bot();

#return if $SKIP{$uri};

if ( open my $fh, '>>', $file ) {
flock( $fh, LOCK_EX ) or return;
seek( $fh, 0, SEEK_END ) or return;
say $fh to_json \%details, { pretty => 0, canonical => 1 };
close $fh;
}
return;
}

sub _replace_tags {
my ($pages) = @_;

Expand Down
11 changes: 1 addition & 10 deletions lib/Perl/Maven/WebTools.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ our $VERSION = '0.11';
my %all_the_authors;

use Exporter qw(import);
our @EXPORT_OK
= qw(logged_in get_ip mymaven generate_code _registration_form pm_template read_tt pm_show_abstract pm_show_page authors pm_message);
our @EXPORT_OK = qw(logged_in get_ip mymaven generate_code pm_template read_tt pm_show_abstract pm_show_page authors);

sub myhost {
my $host = request->host;
Expand Down Expand Up @@ -68,14 +67,6 @@ sub get_ip {
return $ip;
}

sub pm_message {
return _resources( 'message', 'code', @_ );
}

sub _registration_form {
return _resources( 'registration_form', @_ );
}

sub _resources {
if ( scalar(@_) % 2 == 0 ) {
carp("odd number of elements for hash will follow: _resources(@_)");
Expand Down

0 comments on commit b5460c8

Please sign in to comment.