diff --git a/cpanfile b/cpanfile
index aaed1fa..bbe371a 100644
--- a/cpanfile
+++ b/cpanfile
@@ -2,6 +2,7 @@ requires 'Mojolicious';
requires 'IO::Socket::SSL';
requires 'Data::Validate::URI';
requires 'Mojolicious::Plugin::I18N';
+requires 'Mojolicious::Plugin::ConfigHashMerge';
requires 'ORLite';
requires 'File::Type';
requires 'Text::Unidecode';
diff --git a/cpanfile.snapshot b/cpanfile.snapshot
index 559167b..09365c1 100644
--- a/cpanfile.snapshot
+++ b/cpanfile.snapshot
@@ -1,5 +1,34 @@
# carton snapshot format: version 1.0
DISTRIBUTIONS
+ Algorithm-Diff-1.1902
+ pathname: T/TY/TYEMQ/Algorithm-Diff-1.1902.tar.gz
+ provides:
+ Algorithm::Diff 1.1902
+ Algorithm::Diff::_impl 1.1902
+ Algorithm::DiffOld 1.1
+ requirements:
+ ExtUtils::MakeMaker 0
+ Carp-1.3301
+ pathname: Z/ZE/ZEFRAM/Carp-1.3301.tar.gz
+ provides:
+ Carp 1.3301
+ Carp::Heavy 1.3301
+ requirements:
+ Config 0
+ Exporter 0
+ ExtUtils::MakeMaker 0
+ IPC::Open3 1.0103
+ Test::More 0
+ overload 0
+ parent 0
+ strict 0
+ warnings 0
+ Class-Data-Inheritable-0.08
+ pathname: T/TM/TMTM/Class-Data-Inheritable-0.08.tar.gz
+ provides:
+ Class::Data::Inheritable 0.08
+ requirements:
+ ExtUtils::MakeMaker 0
Class-Load-0.21
pathname: E/ET/ETHER/Class-Load-0.21.tar.gz
provides:
@@ -26,6 +55,13 @@ DISTRIBUTIONS
Class::Singleton 1.4
requirements:
ExtUtils::MakeMaker 0
+ Clone-0.36
+ pathname: G/GA/GARU/Clone-0.36.tar.gz
+ provides:
+ Clone 0.36
+ requirements:
+ ExtUtils::MakeMaker 0
+ Test::More 0
Crypt-Blowfish-2.14
pathname: D/DP/DPARIS/Crypt-Blowfish-2.14.tar.gz
provides:
@@ -188,16 +224,16 @@ DISTRIBUTIONS
Data::Validate::Domain 0
Data::Validate::IP 0
ExtUtils::MakeMaker 0
- DateTime-1.07
- pathname: D/DR/DROLSKY/DateTime-1.07.tar.gz
+ DateTime-1.08
+ pathname: D/DR/DROLSKY/DateTime-1.08.tar.gz
provides:
- DateTime 1.07
- DateTime::Duration 1.07
- DateTime::Helpers 1.07
- DateTime::Infinite 1.07
- DateTime::Infinite::Future 1.07
- DateTime::Infinite::Past 1.07
- DateTime::LeapSecond 1.07
+ DateTime 1.08
+ DateTime::Duration 1.08
+ DateTime::Helpers 1.08
+ DateTime::Infinite 1.08
+ DateTime::Infinite::Future 1.08
+ DateTime::Infinite::Past 1.08
+ DateTime::LeapSecond 1.08
inc::MyModuleBuild undef
requirements:
Carp 0
@@ -208,6 +244,9 @@ DISTRIBUTIONS
POSIX 0
Params::Validate 0.76
Scalar::Util 0
+ Storable 0
+ Test::Fatal 0
+ Test::More 0.88
Try::Tiny 0
XSLoader 0
base 0
@@ -216,6 +255,7 @@ DISTRIBUTIONS
overload 0
perl 5.008001
strict 0
+ utf8 0
vars 0
warnings 0
DateTime-Locale-0.45
@@ -692,7 +732,7 @@ DISTRIBUTIONS
DateTime::Locale::zu_ZA undef
requirements:
List::MoreUtils 0
- Module::Build 0
+ Module::Build 0.36
Params::Validate 0.91
perl 5.006
DateTime-TimeZone-1.64
@@ -1122,6 +1162,18 @@ DISTRIBUTIONS
strict 0
vars 0
warnings 0
+ Devel-StackTrace-1.31
+ pathname: D/DR/DROLSKY/Devel-StackTrace-1.31.tar.gz
+ provides:
+ Devel::StackTrace 1.31
+ Devel::StackTrace::Frame 1.31
+ requirements:
+ ExtUtils::MakeMaker 6.30
+ File::Spec 0
+ Scalar::Util 0
+ overload 0
+ strict 0
+ warnings 0
Dist-CheckConflicts-0.10
pathname: D/DO/DOY/Dist-CheckConflicts-0.10.tar.gz
provides:
@@ -1135,6 +1187,23 @@ DISTRIBUTIONS
base 0
strict 0
warnings 0
+ Exception-Class-1.37
+ pathname: D/DR/DROLSKY/Exception-Class-1.37.tar.gz
+ provides:
+ Exception::Class 1.37
+ Exception::Class::Base 1.37
+ requirements:
+ Class::Data::Inheritable 0.02
+ Devel::StackTrace 1.20
+ ExtUtils::MakeMaker 6.30
+ File::Spec 0
+ Scalar::Util 0
+ Test::More 0.88
+ base 0
+ overload 0
+ strict 0
+ vars 0
+ warnings 0
ExtUtils-Config-0.007
pathname: L/LE/LEONT/ExtUtils-Config-0.007.tar.gz
provides:
@@ -1178,40 +1247,40 @@ DISTRIBUTIONS
File::Spec 0
strict 0
warnings 0
- ExtUtils-MakeMaker-6.88
- pathname: B/BI/BINGOS/ExtUtils-MakeMaker-6.88.tar.gz
+ ExtUtils-MakeMaker-6.96
+ pathname: B/BI/BINGOS/ExtUtils-MakeMaker-6.96.tar.gz
provides:
- DynaLoader 6.88
- ExtUtils::Command::MM 6.88
- ExtUtils::Liblist 6.88
- ExtUtils::Liblist::Kid 6.88
- ExtUtils::MM 6.88
- ExtUtils::MM_AIX 6.88
- ExtUtils::MM_Any 6.88
- ExtUtils::MM_BeOS 6.88
- ExtUtils::MM_Cygwin 6.88
- ExtUtils::MM_DOS 6.88
- ExtUtils::MM_Darwin 6.88
- ExtUtils::MM_MacOS 6.88
- ExtUtils::MM_NW5 6.88
- ExtUtils::MM_OS2 6.88
- ExtUtils::MM_QNX 6.88
- ExtUtils::MM_UWIN 6.88
- ExtUtils::MM_Unix 6.88
- ExtUtils::MM_VMS 6.88
- ExtUtils::MM_VOS 6.88
- ExtUtils::MM_Win32 6.88
- ExtUtils::MM_Win95 6.88
- ExtUtils::MY 6.88
- ExtUtils::MakeMaker 6.88
- ExtUtils::MakeMaker::Config 6.88
- ExtUtils::MakeMaker::_version 6.88
- ExtUtils::Mkbootstrap 6.88
- ExtUtils::Mksymlists 6.88
- ExtUtils::testlib 6.88
- MM 6.88
- MY 6.88
- in 6.88
+ DynaLoader 6.96
+ ExtUtils::Command::MM 6.96
+ ExtUtils::Liblist 6.96
+ ExtUtils::Liblist::Kid 6.96
+ ExtUtils::MM 6.96
+ ExtUtils::MM_AIX 6.96
+ ExtUtils::MM_Any 6.96
+ ExtUtils::MM_BeOS 6.96
+ ExtUtils::MM_Cygwin 6.96
+ ExtUtils::MM_DOS 6.96
+ ExtUtils::MM_Darwin 6.96
+ ExtUtils::MM_MacOS 6.96
+ ExtUtils::MM_NW5 6.96
+ ExtUtils::MM_OS2 6.96
+ ExtUtils::MM_QNX 6.96
+ ExtUtils::MM_UWIN 6.96
+ ExtUtils::MM_Unix 6.96
+ ExtUtils::MM_VMS 6.96
+ ExtUtils::MM_VOS 6.96
+ ExtUtils::MM_Win32 6.96
+ ExtUtils::MM_Win95 6.96
+ ExtUtils::MY 6.96
+ ExtUtils::MakeMaker 6.96
+ ExtUtils::MakeMaker::Config 6.96
+ ExtUtils::MakeMaker::_version 6.96
+ ExtUtils::Mkbootstrap 6.96
+ ExtUtils::Mksymlists 6.96
+ ExtUtils::testlib 6.96
+ MM 6.96
+ MY 6.96
+ in 6.96
requirements:
Data::Dumper 0
DirHandle 0
@@ -1245,6 +1314,29 @@ DISTRIBUTIONS
ExtUtils::MakeMaker 0
File::Basename 0
Test::More 0
+ Hash-Merge-Simple-0.051
+ pathname: R/RO/ROKR/Hash-Merge-Simple-0.051.tar.gz
+ provides:
+ Hash::Merge::Simple 0.051
+ requirements:
+ Clone 0
+ ExtUtils::MakeMaker 6.31
+ Storable 0
+ Test::Most 0
+ IO-Socket-SSL-1.982
+ pathname: S/SU/SULLR/IO-Socket-SSL-1.982.tar.gz
+ provides:
+ IO::Socket::SSL 1.982
+ IO::Socket::SSL::Intercept 1.93
+ IO::Socket::SSL::PublicSuffix undef
+ IO::Socket::SSL::SSL_Context 1.982
+ IO::Socket::SSL::SSL_HANDLE 1.982
+ IO::Socket::SSL::Session_Cache 1.982
+ IO::Socket::SSL::Utils 0.02
+ requirements:
+ ExtUtils::MakeMaker 0
+ Net::SSLeay 1.46
+ Scalar::Util 0
IPC-Run3-0.046
pathname: R/RJ/RJBS/IPC-Run3-0.046.tar.gz
provides:
@@ -1262,16 +1354,6 @@ DISTRIBUTIONS
ExtUtils::MakeMaker 6.52
Test::More 0.82
perl 5.00503
- MIME-Types-2.04
- pathname: M/MA/MARKOV/MIME-Types-2.04.tar.gz
- provides:
- MIME::Type 2.04
- MIME::Types 2.04
- requirements:
- ExtUtils::MakeMaker 0
- File::Basename 0
- File::Spec 0
- Test::More 0.47
Module-Build-0.4205
pathname: L/LE/LEONT/Module-Build-0.4205.tar.gz
provides:
@@ -1377,8 +1459,8 @@ DISTRIBUTIONS
perl 5.006
strict 0
warnings 0
- Mojolicious-4.87
- pathname: S/SR/SRI/Mojolicious-4.87.tar.gz
+ Mojolicious-4.97
+ pathname: S/SR/SRI/Mojolicious-4.97.tar.gz
provides:
Mojo undef
Mojo::Asset undef
@@ -1441,7 +1523,7 @@ DISTRIBUTIONS
Mojo::UserAgent::Server undef
Mojo::UserAgent::Transactor undef
Mojo::Util undef
- Mojolicious 4.87
+ Mojolicious 4.97
Mojolicious::Command undef
Mojolicious::Command::cgi undef
Mojolicious::Command::cpanify undef
@@ -1490,6 +1572,14 @@ DISTRIBUTIONS
requirements:
ExtUtils::MakeMaker 0
perl 5.010001
+ Mojolicious-Plugin-ConfigHashMerge-0.01
+ pathname: D/DO/DOTAN/Mojolicious-Plugin-ConfigHashMerge-0.01.tar.gz
+ provides:
+ Mojolicious::Plugin::ConfigHashMerge 0.01
+ requirements:
+ ExtUtils::MakeMaker 0
+ Hash::Merge::Simple 0.051
+ Mojolicious 4.85
Mojolicious-Plugin-I18N-1.21
pathname: S/SH/SHARIFULN/Mojolicious-Plugin-I18N-1.21.tar.gz
provides:
@@ -1508,6 +1598,16 @@ DISTRIBUTIONS
Carp 0
ExtUtils::MakeMaker 0
Storable 0
+ Net-SSLeay-1.58
+ pathname: M/MI/MIKEM/Net-SSLeay-1.58.tar.gz
+ provides:
+ Net::SSLeay 1.58
+ Net::SSLeay::Handle 0.61
+ requirements:
+ ExtUtils::MakeMaker 6.36
+ MIME::Base64 0
+ Test::More 0.60_01
+ perl 5.005
NetAddr-IP-4.072
pathname: M/MI/MIKER/NetAddr-IP-4.072.tar.gz
provides:
@@ -1610,13 +1710,22 @@ DISTRIBUTIONS
requirements:
Attribute::Handlers 0.79
Carp 0
+ Devel::Peek 0
Exporter 0
ExtUtils::CBuilder 0
+ File::Spec 0
+ File::Temp 0
Module::Build 0.3601
Module::Implementation 0
Scalar::Util 1.10
+ Test::Fatal 0
+ Test::More 0.88
+ Tie::Array 0
+ Tie::Hash 0
XSLoader 0
attributes 0
+ base 0
+ overload 0
perl 5.008001
strict 0
vars 0
@@ -1641,14 +1750,110 @@ DISTRIBUTIONS
Scalar::Util 0
strict 0
warnings 0
- Switch-2.16
- pathname: R/RG/RGARCIA/Switch-2.16.tar.gz
+ Sub-Uplevel-0.24
+ pathname: D/DA/DAGOLDEN/Sub-Uplevel-0.24.tar.gz
provides:
- Switch 2.16
+ Sub::Uplevel 0.24
+ requirements:
+ Carp 0
+ Exporter 0
+ ExtUtils::MakeMaker 6.30
+ File::Find 0
+ File::Temp 0
+ Test::More 0
+ constant 0
+ strict 0
+ warnings 0
+ Switch-2.17
+ pathname: C/CH/CHORNY/Switch-2.17.tar.gz
+ provides:
+ Switch 2.17
requirements:
ExtUtils::MakeMaker 0
Filter::Util::Call 0
- Text::Balanced 0
+ Text::Balanced 2
+ if 0
+ perl 5.005
+ Test-Deep-0.112
+ pathname: R/RJ/RJBS/Test-Deep-0.112.tar.gz
+ provides:
+ Test::Deep 0.112
+ Test::Deep::All undef
+ Test::Deep::Any undef
+ Test::Deep::Array undef
+ Test::Deep::ArrayEach undef
+ Test::Deep::ArrayElementsOnly undef
+ Test::Deep::ArrayLength undef
+ Test::Deep::ArrayLengthOnly undef
+ Test::Deep::Blessed undef
+ Test::Deep::Boolean undef
+ Test::Deep::Cache undef
+ Test::Deep::Cache::Simple undef
+ Test::Deep::Class undef
+ Test::Deep::Cmp undef
+ Test::Deep::Code undef
+ Test::Deep::Hash undef
+ Test::Deep::HashEach undef
+ Test::Deep::HashElements undef
+ Test::Deep::HashKeys undef
+ Test::Deep::HashKeysOnly undef
+ Test::Deep::Ignore undef
+ Test::Deep::Isa undef
+ Test::Deep::ListMethods undef
+ Test::Deep::MM undef
+ Test::Deep::Methods undef
+ Test::Deep::NoTest undef
+ Test::Deep::Number undef
+ Test::Deep::Obj undef
+ Test::Deep::Ref undef
+ Test::Deep::RefType undef
+ Test::Deep::Regexp undef
+ Test::Deep::RegexpMatches undef
+ Test::Deep::RegexpRef undef
+ Test::Deep::RegexpRefOnly undef
+ Test::Deep::RegexpVersion undef
+ Test::Deep::ScalarRef undef
+ Test::Deep::ScalarRefOnly undef
+ Test::Deep::Set undef
+ Test::Deep::Shallow undef
+ Test::Deep::Stack undef
+ Test::Deep::String undef
+ Test::Deep::SubHash undef
+ Test::Deep::SubHashElements undef
+ Test::Deep::SubHashKeys undef
+ Test::Deep::SubHashKeysOnly undef
+ Test::Deep::SuperHash undef
+ Test::Deep::SuperHashElements undef
+ Test::Deep::SuperHashKeys undef
+ Test::Deep::SuperHashKeysOnly undef
+ requirements:
+ ExtUtils::MakeMaker 0
+ List::Util 1.09
+ Scalar::Util 1.09
+ Test::More 0
+ Test::NoWarnings 0.02
+ Test::Tester 0.04
+ Test-Differences-0.61
+ pathname: O/OV/OVID/Test-Differences-0.61.tar.gz
+ provides:
+ Test::Differences 0.61
+ requirements:
+ Data::Dumper 2.126
+ Module::Build 0.36
+ Test::More 0
+ Text::Diff 0.35
+ Test-Exception-0.32
+ pathname: A/AD/ADIE/Test-Exception-0.32.tar.gz
+ provides:
+ Test::Exception 0.32
+ requirements:
+ Module::Build 0.38
+ Sub::Uplevel 0.18
+ Test::Builder 0.7
+ Test::Builder::Tester 1.07
+ Test::Harness 2.03
+ Test::More 0.7
+ Test::Simple 0.7
Test-Fatal-0.013
pathname: R/RJ/RJBS/Test-Fatal-0.013.tar.gz
provides:
@@ -1714,6 +1919,31 @@ DISTRIBUTIONS
Test::Harness 3.30
requirements:
ExtUtils::MakeMaker 0
+ Test-Most-0.33
+ pathname: O/OV/OVID/Test-Most-0.33.tar.gz
+ provides:
+ Test::Most 0.33
+ Test::Most::Exception 0.33
+ requirements:
+ Exception::Class 1.14
+ ExtUtils::MakeMaker 0
+ Test::Deep 0.106
+ Test::Differences 0.61
+ Test::Exception 0.31
+ Test::Harness 3.21
+ Test::More 0.88
+ Test::Warn 0.23
+ Test-NoWarnings-1.04
+ pathname: A/AD/ADAMK/Test-NoWarnings-1.04.tar.gz
+ provides:
+ Test::NoWarnings 1.04
+ Test::NoWarnings::Warning 1.04
+ requirements:
+ ExtUtils::MakeMaker 0
+ Test::Builder 0.86
+ Test::More 0.47
+ Test::Tester 0.107
+ perl 5.006
Test-Requires-0.07
pathname: T/TO/TOKUHIROM/Test-Requires-0.07.tar.gz
provides:
@@ -1739,6 +1969,41 @@ DISTRIBUTIONS
Test::Builder::Tester 1.02
Test::More 0.62
blib 0
+ Test-Tester-0.109
+ pathname: F/FD/FDALY/Test-Tester-0.109.tar.gz
+ provides:
+ Test::Tester 0.109
+ Test::Tester::Capture undef
+ Test::Tester::CaptureRunner undef
+ Test::Tester::Delegate undef
+ requirements:
+ ExtUtils::MakeMaker 0
+ Test::Builder 0
+ Test-Warn-0.30
+ pathname: C/CH/CHORNY/Test-Warn-0.30.tar.gz
+ provides:
+ Test::Warn 0.30
+ Test::Warn::Categorization 0.30
+ requirements:
+ Carp 1.22
+ ExtUtils::MakeMaker 0
+ File::Spec 0
+ Sub::Uplevel 0.12
+ Test::Builder 0.13
+ Test::Builder::Tester 1.02
+ Test::More 0
+ perl 5.006
+ Text-Diff-1.41
+ pathname: O/OV/OVID/Text-Diff-1.41.tar.gz
+ provides:
+ Text::Diff 1.41
+ Text::Diff::Base 1.41
+ Text::Diff::Config 1.41
+ Text::Diff::Table 1.41
+ requirements:
+ Algorithm::Diff 1.19
+ Exporter 0
+ ExtUtils::MakeMaker 0
Text-Unidecode-0.04
pathname: S/SB/SBURKE/Text-Unidecode-0.04.tar.gz
provides:
diff --git a/lib/Lutim.pm b/lib/Lutim.pm
index 093c852..5845de3 100644
--- a/lib/Lutim.pm
+++ b/lib/Lutim.pm
@@ -14,19 +14,27 @@ sub startup {
$self->plugin('I18N');
- my $config = $self->plugin('Config');
+ my $config = $self->plugin('ConfigHashMerge', {
+ default => {
+ provisioning => 100,
+ provis_step => 5,
+ length => 8,
+ always_encrypt => 0,
+ anti_flood_delay => 5,
+ tweet_card_via => '@framasky',
+ max_file_size => 10*1024*1024,
+ https => 0,
+ default_delay => 0,
+ max_delay => 0,
+ }
+ });
# Default values
- $config->{provisioning} = 100 unless (defined($config->{provisionning}));
- $config->{provisioning} = 100 unless (defined($config->{provisioning}));
- $config->{provis_step} = 5 unless (defined($config->{provis_step}));
- $config->{length} = 8 unless (defined($config->{length}));
- $config->{always_encrypt} = 0 unless (defined($config->{always_encrypt}));
- $config->{anti_flood_delay} = 5 unless (defined($config->{anti_flood_delay}));
+ $config->{provisioning} = $config->{provisionning} if (defined($config->{provisionning}));
die "You need to provide a contact information in lutim.conf !" unless (defined($config->{contact}));
- $ENV{MOJO_MAX_MESSAGE_SIZE} = $config->{max_file_size} if (defined($config->{max_file_size}));
+ $ENV{MOJO_MAX_MESSAGE_SIZE} = $config->{max_file_size};
$self->secrets($config->{secrets});
@@ -149,14 +157,9 @@ sub startup {
max_delay => sub {
my $c = shift;
- if (defined($c->config->{max_delay})) {
- my $delay = $c->config->{max_delay};
- if ($delay >= 0) {
- return $delay;
- } else {
- warn "max_delay set to a negative value. Default to 0."
- }
- }
+ return $c->config->{max_delay} if ($c->config->{max_delay} >= 0);
+
+ warn "max_delay set to a negative value. Default to 0.";
return 0;
}
);
@@ -165,14 +168,9 @@ sub startup {
default_delay => sub {
my $c = shift;
- if (defined($c->config->{default_delay})) {
- my $delay = $c->config->{default_delay};
- if ($delay >= 0) {
- return $delay;
- } else {
- warn "default_delay set to a negative value. Default to 0."
- }
- }
+ return $c->config->{default_delay} if ($c->config->{default_delay} >= 0);
+
+ warn "default_delay set to a negative value. Default to 0.";
return 0;
}
);
@@ -264,7 +262,7 @@ sub startup {
}
# Scheme detection
- if ((defined($c->req->headers->header('X-Forwarded-Proto')) && $c->req->headers->header('X-Forwarded-Proto') eq 'https') || (defined($c->config->{https}) && $c->config->{https})) {
+ if ((defined($c->req->headers->header('X-Forwarded-Proto')) && $c->req->headers->header('X-Forwarded-Proto') eq 'https') || $c->config->{https}) {
$c->req->url->base->scheme('https');
}
}
diff --git a/lib/Mojolicious/Command/cron/cleanbdd.pm b/lib/Mojolicious/Command/cron/cleanbdd.pm
index 4532110..90ecd92 100644
--- a/lib/Mojolicious/Command/cron/cleanbdd.pm
+++ b/lib/Mojolicious/Command/cron/cleanbdd.pm
@@ -2,7 +2,6 @@ package Mojolicious::Command::cron::cleanbdd;
use Mojo::Base 'Mojolicious::Command';
use LutimModel;
use Mojo::Util qw(slurp decode);
-use Mojolicious::Plugin::Config;
has description => 'Delete IP addresses from database after configured delay.';
has usage => sub { shift->extract_usage };
@@ -10,9 +9,11 @@ has usage => sub { shift->extract_usage };
sub run {
my $c = shift;
- my $config = Mojolicious::Plugin::Config->parse(decode('UTF-8', slurp 'lutim.conf'), 'lutim.conf');
-
- $config->{keep_ip_during} = (defined($config->{keep_ip_during})) ? $config->{keep_ip_during} : 365;
+ my $config = $c->app->plugin('ConfigHashMerge', {
+ default => {
+ keep_ip_during => 365,
+ }
+ });
my $separation = time() - $config->{keep_ip_during} * 86400;
diff --git a/lib/Mojolicious/Command/cron/cleanfiles.pm b/lib/Mojolicious/Command/cron/cleanfiles.pm
index 9cbc424..5e092d8 100644
--- a/lib/Mojolicious/Command/cron/cleanfiles.pm
+++ b/lib/Mojolicious/Command/cron/cleanfiles.pm
@@ -2,7 +2,6 @@ package Mojolicious::Command::cron::cleanfiles;
use Mojo::Base 'Mojolicious::Command';
use LutimModel;
use Mojo::Util qw(slurp decode);
-use Mojolicious::Plugin::Config;
has description => 'Delete expired files.';
has usage => sub { shift->extract_usage };
@@ -10,8 +9,6 @@ has usage => sub { shift->extract_usage };
sub run {
my $c = shift;
- my $config = Mojolicious::Plugin::Config->parse(decode('UTF-8', slurp 'lutim.conf'), 'lutim.conf');
-
my $time = time();
my @images = LutimModel::Lutim->select('WHERE enabled = 1 AND (delete_at_day * 86400) < (? - created_at) AND delete_at_day != 0', $time);
diff --git a/lib/Mojolicious/Command/cron/stats.pm b/lib/Mojolicious/Command/cron/stats.pm
index 2a44fa6..d793f05 100644
--- a/lib/Mojolicious/Command/cron/stats.pm
+++ b/lib/Mojolicious/Command/cron/stats.pm
@@ -4,7 +4,6 @@ use LutimModel;
use Mojo::DOM;
use Mojo::Util qw(slurp spurt decode);
use DateTime;
-use Mojolicious::Plugin::Config;
has description => 'Generate statistics about LUTIm.';
has usage => sub { shift->extract_usage };
@@ -12,8 +11,11 @@ has usage => sub { shift->extract_usage };
sub run {
my $c = shift;
- my $config = Mojolicious::Plugin::Config->parse(decode('UTF-8', slurp 'lutim.conf'), 'lutim.conf');
- $config->{stats_day_num} = (defined($config->{stats_day_num})) ? $config->{stats_day_num} : 365;
+ my $config = $c->app->plugin('ConfigHashMerge', {
+ default => {
+ stats_day_num => 365
+ }
+ });
my $text = slurp('templates/data.html.ep.template');
my $dom = Mojo::DOM->new($text);
diff --git a/lib/Mojolicious/Command/cron/watch.pm b/lib/Mojolicious/Command/cron/watch.pm
index 5fee5f8..be02153 100644
--- a/lib/Mojolicious/Command/cron/watch.pm
+++ b/lib/Mojolicious/Command/cron/watch.pm
@@ -1,7 +1,6 @@
package Mojolicious::Command::cron::watch;
use Mojo::Base 'Mojolicious::Command';
use Mojo::Util qw(slurp decode);
-use Mojolicious::Plugin::Config;
use Filesys::DiskUsage qw/du/;
use LutimModel;
use Switch;
@@ -12,38 +11,38 @@ has usage => sub { shift->extract_usage };
sub run {
my $c = shift;
- my $config = Mojolicious::Plugin::Config->parse(decode('UTF-8', slurp 'lutim.conf'), 'lutim.conf');
+ my $config = $c->app->plugin('ConfigHashMerge', {
+ default => {
+ policy_when_full => 'warn'
+ }
+ });
if (defined($config->{max_total_size})) {
my $total = du(qw/files/);
if ($total > $config->{max_total_size}) {
- if (defined($config->{policy_when_full})) {
- say "[LUTIm cron job watch] Files directory is over quota ($total > ".$config->{max_total_size}.")";
- switch ($config->{policy_when_full}) {
- case 'warn' {
- say "[LUTIm cron job watch] Please, delete some files or increase quota (".$config->{max_total_size}.")";
- }
- case 'stop-upload' {
- open (my $fh, '>', 'stop-upload') or die ("Couldn't open stop-upload: $!");
- close($fh);
- say '[LUTIm cron job watch] Uploads are stopped. Delete some images and the stop-upload file to reallow uploads.';
- }
- case 'delete' {
- say '[LUTIm cron job watch] Older files are being deleted';
- do {
- for my $img (LutimModel::Lutim->select('WHERE path IS NOT NULL AND enabled = 1 ORDER BY created_at ASC LIMIT 50')) {
- unlink $img->path() or warn "Could not unlink ".$img->path.": $!";
- $img->update(enabled => 0);
- }
- } while (du(qw/files/) > $config->{max_total_size});
- }
- else {
- say '[LUTIm cron job watch] Unrecognized policy_when_full option: '.$config->{policy_when_full}.'. Aborting.';
- }
+ say "[LUTIm cron job watch] Files directory is over quota ($total > ".$config->{max_total_size}.")";
+ switch ($config->{policy_when_full}) {
+ case 'warn' {
+ say "[LUTIm cron job watch] Please, delete some files or increase quota (".$config->{max_total_size}.")";
+ }
+ case 'stop-upload' {
+ open (my $fh, '>', 'stop-upload') or die ("Couldn't open stop-upload: $!");
+ close($fh);
+ say '[LUTIm cron job watch] Uploads are stopped. Delete some images and the stop-upload file to reallow uploads.';
+ }
+ case 'delete' {
+ say '[LUTIm cron job watch] Older files are being deleted';
+ do {
+ for my $img (LutimModel::Lutim->select('WHERE path IS NOT NULL AND enabled = 1 ORDER BY created_at ASC LIMIT 50')) {
+ unlink $img->path() or warn "Could not unlink ".$img->path.": $!";
+ $img->update(enabled => 0);
+ }
+ } while (du(qw/files/) > $config->{max_total_size});
+ }
+ else {
+ say '[LUTIm cron job watch] Unrecognized policy_when_full option: '.$config->{policy_when_full}.'. Aborting.';
}
- } else {
- say "[LUTIm cron job watch] Files directory over quota ($total > ".$config->{max_total_size}.") but no configured policy_when_full option!" ;
}
} else {
unlink 'stop-upload' if (-f 'stop-upload');
diff --git a/lutim.conf.template b/lutim.conf.template
index 2e9f919..6d6ad28 100644
--- a/lutim.conf.template
+++ b/lutim.conf.template
@@ -36,6 +36,9 @@
#provis_step => 5,
# max number of URLs to be provisioned
+ # WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
+ # in the first version, this option was provisionning with two 'n'. While the option with the typo is still valid, it is deprecated.
+ # in the next version (0.4), only provisioning with ine 'n' will be accepted
# optional, default is 100
#provisioning => 100,
@@ -114,5 +117,6 @@
# default action when files directory is over max_total_size (used with script/lutim cron watch)
# valid values are 'warn', 'stop-upload' and 'delete'
# please, see readme
+ # optional, default is 'warn'
#policy_when_full => 'warn',
};
diff --git a/templates/twitter.html.ep b/templates/twitter.html.ep
index 0c188ba..9652cb8 100644
--- a/templates/twitter.html.ep
+++ b/templates/twitter.html.ep
@@ -7,9 +7,7 @@
-% if (defined(config('tweet_card_via'))) {
-% }