Verified Commit a416a8ad authored by Luc Didry's avatar Luc Didry
Browse files

— Use a DefaultConfig module

parent 2071a84f
Pipeline #219845 passed with stages
in 9 minutes and 59 seconds
......@@ -3,6 +3,7 @@ package Lutim;
use Mojo::Base 'Mojolicious';
use Mojo::IOLoop;
use Lutim::DB::Image;
use Lutim::DefaultConfig qw($default_config);
use vars qw($im_loaded);
BEGIN {
......@@ -28,39 +29,7 @@ sub startup {
$self->plugin('DebugDumperHelper');
my $config = $self->plugin('Config', {
default => {
provisioning => 100,
provis_step => 5,
length => 8,
always_encrypt => 0,
anti_flood_delay => 5,
max_file_size => 10*1024*1024,
https => 0,
proposed_delays => '0,1,7,30,365',
default_delay => 0,
max_delay => 0,
token_length => 24,
crypto_key_length => 8,
thumbnail_size => 100,
theme => 'default',
dbtype => 'sqlite',
db_path => 'lutim.db',
max_files_in_zip => 15,
prefix => '/',
minion => {
enabled => 0,
dbtype => 'sqlite',
db_path => 'minion.db'
},
session_duration => 3600,
cache_max_size => 0,
memcached_servers => [],
quiet_logs => 0,
disable_img_stats => 0,
x_frame_options => 'DENY',
x_content_type_options => 'nosniff',
x_xss_protection => '1; mode=block',
}
default => $default_config
});
if (scalar(@{$config->{memcached_servers}})) {
......
......@@ -3,6 +3,7 @@ package Lutim::Command::cron::cleanbdd;
use Mojo::Base 'Mojolicious::Command';
use Mojo::File;
use Lutim::DB::Image;
use Lutim::DefaultConfig qw($default_config);
use FindBin qw($Bin);
use File::Spec qw(catfile);
......@@ -21,10 +22,7 @@ sub run {
}
my $config = $c->app->plugin('Config', {
file => $cfile,
default => {
keep_ip_during => 365,
dbtype => 'sqlite',
}
default => $default_config
});
my $separation = time() - $config->{keep_ip_during} * 86400;
......
......@@ -3,6 +3,7 @@ package Lutim::Command::cron::cleanfiles;
use Mojo::Base 'Mojolicious::Command';
use Mojo::File;
use Lutim::DB::Image;
use Lutim::DefaultConfig qw($default_config);
use Lutim;
use FindBin qw($Bin);
use File::Spec qw(catfile);
......@@ -22,9 +23,7 @@ sub run {
}
my $config = $c->app->plugin('Config', {
file => $cfile,
default => {
dbtype => 'sqlite',
}
default => $default_config
});
my $l = Lutim->new;
......
......@@ -6,6 +6,7 @@ use Mojo::Util qw(encode);
use Mojo::File;
use Mojo::JSON qw(encode_json);
use Lutim::DB::Image;
use Lutim::DefaultConfig qw($default_config);
use DateTime;
use FindBin qw($Bin);
use File::Spec qw(catfile);
......@@ -26,11 +27,7 @@ sub run {
}
my $config = $c->app->plugin('Config', {
file => $cfile,
default => {
theme => 'default',
stats_day_num => 365,
dbtype => 'sqlite'
}
default => $default_config
});
my $template = 'themes/'.$config->{theme}.'/templates/data.html.ep.template';
......
......@@ -3,6 +3,7 @@ package Lutim::Command::cron::watch;
use Mojo::Base 'Mojolicious::Command';
use Filesys::DiskUsage qw/du/;
use Lutim::DB::Image;
use Lutim::DefaultConfig qw($default_config);
use Lutim;
use Mojo::File;
use Switch;
......@@ -24,10 +25,7 @@ sub run {
}
my $config = $c->app->plugin('Config', {
file => $cfile,
default => {
policy_when_full => 'warn',
dbtype => 'sqlite',
}
default => $default_config
});
if (defined($config->{max_total_size})) {
......
......@@ -4,6 +4,7 @@ use Mojo::Base 'Mojolicious::Command';
use Mojo::Util qw(getopt);
use Mojo::Collection 'c';
use Lutim::DB::Image;
use Lutim::DefaultConfig qw($default_config);
use FindBin qw($Bin);
use File::Spec qw(catfile);
......@@ -25,38 +26,7 @@ sub run {
}
my $config = $c->app->plugin('Config', {
file => $cfile,
default => {
provisioning => 100,
provis_step => 5,
length => 8,
always_encrypt => 0,
anti_flood_delay => 5,
max_file_size => 10*1024*1024,
https => 0,
proposed_delays => '0,1,7,30,365',
default_delay => 0,
max_delay => 0,
token_length => 24,
crypto_key_length => 8,
thumbnail_size => 100,
theme => 'default',
dbtype => 'sqlite',
db_path => 'lutim.db',
max_files_in_zip => 15,
prefix => '/',
minion => {
enabled => 0,
dbtype => 'sqlite',
db_path => 'minion.db'
},
cache_max_size => 0,
memcached_servers => [],
quiet_logs => 0,
disable_img_stats => 0,
x_frame_options => 'DENY',
x_content_type_options => 'nosniff',
x_xss_protection => '1; mode=block',
}
default => $default_config
});
if (scalar(@{$config->{memcached_servers}})) {
......
# vim:set sw=4 ts=4 sts=4 ft=perl expandtab:
package Lutim::DefaultConfig;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw($default_config);
our $default_config = {
provisioning => 100,
provis_step => 5,
length => 8,
always_encrypt => 0,
anti_flood_delay => 5,
max_file_size => 10*1024*1024,
https => 0,
proposed_delays => '0,1,7,30,365',
default_delay => 0,
max_delay => 0,
token_length => 24,
crypto_key_length => 8,
thumbnail_size => 100,
theme => 'default',
dbtype => 'sqlite',
db_path => 'lutim.db',
max_files_in_zip => 15,
prefix => '/',
minion => {
enabled => 0,
dbtype => 'sqlite',
db_path => 'minion.db'
},
session_duration => 3600,
cache_max_size => 0,
memcached_servers => [],
quiet_logs => 0,
disable_img_stats => 0,
x_frame_options => 'DENY',
x_content_type_options => 'nosniff',
x_xss_protection => '1; mode=block',
stats_day_num => 365,
keep_ip_during => 365,
policy_when_full => 'warn',
};
1;
......@@ -4,6 +4,7 @@ use Mojo::Base 'Mojolicious';
use Mojo::File;
use FindBin qw($Bin);
use File::Spec qw(catfile);
use Lutim::DefaultConfig qw($default_config);
# This method will run once at server start
sub startup {
......@@ -18,43 +19,10 @@ sub startup {
$cfile = Mojo::File->new($Bin, '..', $ENV{MOJO_CONFIG});
}
}
my $config = $self->plugin('Config' =>
{
file => $cfile,
default => {
provisioning => 100,
provis_step => 5,
length => 8,
always_encrypt => 0,
anti_flood_delay => 5,
max_file_size => 10*1024*1024,
https => 0,
proposed_delays => '0,1,7,30,365',
default_delay => 0,
max_delay => 0,
token_length => 24,
crypto_key_length => 8,
thumbnail_size => 100,
theme => 'default',
dbtype => 'sqlite',
db_path => 'lutim.db',
max_files_in_zip => 15,
prefix => '/',
minion => {
enabled => 0,
dbtype => 'sqlite',
db_path => 'minion.db'
},
cache_max_size => 0,
memcached_servers => [],
quiet_logs => 0,
disable_img_stats => 0,
x_frame_options => 'DENY',
x_content_type_options => 'nosniff',
x_xss_protection => '1; mode=block',
}
}
);
my $config = $self->plugin('Config', {
file => $cfile,
default => $default_config
});
$config->{prefix} = $config->{url_sub_dir} if (defined($config->{url_sub_dir}) && $config->{prefix} eq '/');
......
......@@ -19,7 +19,7 @@ msgstr ""
#. (30)
#. ($delay)
#. (config('max_delay')
#: lib/Lutim/Command/cron/stats.pm:159 lib/Lutim/Command/cron/stats.pm:160 lib/Lutim/Command/cron/stats.pm:173 lib/Lutim/Command/cron/stats.pm:174 lib/Lutim/Command/cron/stats.pm:190 lib/Lutim/Command/cron/stats.pm:191 themes/default/templates/myfiles.html.ep:24 themes/default/templates/myfiles.html.ep:33 themes/default/templates/myfiles.html.ep:34 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/for_my_delay.html.ep:14 themes/default/templates/partial/for_my_delay.html.ep:4 themes/default/templates/partial/lutim.js.ep:140 themes/default/templates/partial/lutim.js.ep:149 themes/default/templates/partial/lutim.js.ep:150 themes/default/templates/partial/raw.js.ep:23 themes/default/templates/partial/raw.js.ep:24 themes/default/templates/partial/raw.js.ep:6 themes/default/templates/partial/raw.js.ep:7 themes/default/templates/raw.html.ep:8 themes/default/templates/raw.html.ep:9
#: lib/Lutim/Command/cron/stats.pm:156 lib/Lutim/Command/cron/stats.pm:157 lib/Lutim/Command/cron/stats.pm:170 lib/Lutim/Command/cron/stats.pm:171 lib/Lutim/Command/cron/stats.pm:187 lib/Lutim/Command/cron/stats.pm:188 themes/default/templates/myfiles.html.ep:24 themes/default/templates/myfiles.html.ep:33 themes/default/templates/myfiles.html.ep:34 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/for_my_delay.html.ep:14 themes/default/templates/partial/for_my_delay.html.ep:4 themes/default/templates/partial/lutim.js.ep:140 themes/default/templates/partial/lutim.js.ep:149 themes/default/templates/partial/lutim.js.ep:150 themes/default/templates/partial/raw.js.ep:23 themes/default/templates/partial/raw.js.ep:24 themes/default/templates/partial/raw.js.ep:6 themes/default/templates/partial/raw.js.ep:7 themes/default/templates/raw.html.ep:8 themes/default/templates/raw.html.ep:9
msgid "%1 days"
msgstr ""
......@@ -32,11 +32,11 @@ msgstr ""
msgid "-or-"
msgstr ""
#: lib/Lutim.pm:350 lib/Lutim/Command/cron/stats.pm:161 lib/Lutim/Command/cron/stats.pm:175 lib/Lutim/Command/cron/stats.pm:192 themes/default/templates/index.html.ep:5 themes/default/templates/myfiles.html.ep:5 themes/default/templates/partial/raw.js.ep:25 themes/default/templates/partial/raw.js.ep:8 themes/default/templates/raw.html.ep:10
#: lib/Lutim.pm:319 lib/Lutim/Command/cron/stats.pm:158 lib/Lutim/Command/cron/stats.pm:172 lib/Lutim/Command/cron/stats.pm:189 themes/default/templates/index.html.ep:5 themes/default/templates/myfiles.html.ep:5 themes/default/templates/partial/raw.js.ep:25 themes/default/templates/partial/raw.js.ep:8 themes/default/templates/raw.html.ep:10
msgid "1 year"
msgstr ""
#: lib/Lutim.pm:349 lib/Lutim/Command/cron/stats.pm:158 lib/Lutim/Command/cron/stats.pm:172 lib/Lutim/Command/cron/stats.pm:189 themes/default/templates/index.html.ep:4 themes/default/templates/myfiles.html.ep:33 themes/default/templates/myfiles.html.ep:4 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/lutim.js.ep:149 themes/default/templates/partial/raw.js.ep:22 themes/default/templates/partial/raw.js.ep:5 themes/default/templates/raw.html.ep:7
#: lib/Lutim.pm:318 lib/Lutim/Command/cron/stats.pm:155 lib/Lutim/Command/cron/stats.pm:169 lib/Lutim/Command/cron/stats.pm:186 themes/default/templates/index.html.ep:4 themes/default/templates/myfiles.html.ep:33 themes/default/templates/myfiles.html.ep:4 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/lutim.js.ep:149 themes/default/templates/partial/raw.js.ep:22 themes/default/templates/partial/raw.js.ep:5 themes/default/templates/raw.html.ep:7
msgid "24 hours"
msgstr ""
......@@ -48,7 +48,7 @@ msgstr ""
msgid "About"
msgstr ""
#: lib/Lutim/Command/cron/stats.pm:154 themes/default/templates/raw.html.ep:3
#: lib/Lutim/Command/cron/stats.pm:151 themes/default/templates/raw.html.ep:3
msgid "Active images"
msgstr ""
......@@ -108,11 +108,11 @@ msgstr ""
msgid "Delete at first view?"
msgstr ""
#: lib/Lutim/Command/cron/stats.pm:155 themes/default/templates/raw.html.ep:4
#: lib/Lutim/Command/cron/stats.pm:152 themes/default/templates/raw.html.ep:4
msgid "Deleted images"
msgstr ""
#: lib/Lutim/Command/cron/stats.pm:156 themes/default/templates/raw.html.ep:5
#: lib/Lutim/Command/cron/stats.pm:153 themes/default/templates/raw.html.ep:5
msgid "Deleted images in 30 days"
msgstr ""
......@@ -204,7 +204,7 @@ msgstr ""
msgid "Image URL"
msgstr ""
#: lib/Lutim/Command/cron/stats.pm:153 themes/default/templates/raw.html.ep:2
#: lib/Lutim/Command/cron/stats.pm:150 themes/default/templates/raw.html.ep:2
msgid "Image delay"
msgstr ""
......@@ -445,7 +445,7 @@ msgstr ""
msgid "Toggle navigation"
msgstr ""
#: lib/Lutim/Command/cron/stats.pm:162 themes/default/templates/raw.html.ep:11
#: lib/Lutim/Command/cron/stats.pm:159 themes/default/templates/raw.html.ep:11
msgid "Total"
msgstr ""
......@@ -547,7 +547,7 @@ msgstr ""
msgid "core developer"
msgstr ""
#: lib/Lutim.pm:348 lib/Lutim/Command/cron/stats.pm:157 lib/Lutim/Command/cron/stats.pm:171 lib/Lutim/Command/cron/stats.pm:188 themes/default/templates/index.html.ep:3 themes/default/templates/myfiles.html.ep:3 themes/default/templates/partial/raw.js.ep:21 themes/default/templates/partial/raw.js.ep:4 themes/default/templates/raw.html.ep:6
#: lib/Lutim.pm:317 lib/Lutim/Command/cron/stats.pm:154 lib/Lutim/Command/cron/stats.pm:168 lib/Lutim/Command/cron/stats.pm:185 themes/default/templates/index.html.ep:3 themes/default/templates/myfiles.html.ep:3 themes/default/templates/partial/raw.js.ep:21 themes/default/templates/partial/raw.js.ep:4 themes/default/templates/raw.html.ep:6
msgid "no time limit"
msgstr ""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment