mirror of
https://framagit.org/fiat-tux/hat-softwares/lutim.git
synced 2026-03-28 17:42:54 +01:00
Fix #81 Allow to install only needed deps
This commit is dedicated to Agnès Maillard, who is supporting me with Ğ1. Many thanks :-)
This commit is contained in:
26
cpanfile
26
cpanfile
@@ -3,20 +3,14 @@ requires 'EV';
|
||||
requires 'IO::Socket::SSL';
|
||||
requires 'Net::SSLeay', '>= 1.81';
|
||||
requires 'Data::Validate::URI';
|
||||
requires 'Net::Domain::TLD', '>= 1.73'; # Must have the last version to handle (at least) .xyz and .link
|
||||
requires 'Mojo::Pg';
|
||||
requires 'Mojo::SQLite';
|
||||
requires 'Net::Domain::TLD', '>= 1.75'; # Must have the last version to handle (at least) .xyz and .link
|
||||
requires 'Mojolicious::Plugin::I18N';
|
||||
requires 'Mojolicious::Plugin::DebugDumperHelper';
|
||||
requires 'Mojolicious::Plugin::PgURLHelper';
|
||||
requires 'Mojolicious::Plugin::StaticCache';
|
||||
requires "Minion", "== 4.06";
|
||||
requires 'Minion::Backend::SQLite', "== 0.009";
|
||||
requires 'Text::Unidecode';
|
||||
requires 'DateTime';
|
||||
requires 'Filesys::DiskUsage';
|
||||
requires 'Switch';
|
||||
requires 'Data::Validate::URI';
|
||||
requires 'Crypt::CBC';
|
||||
requires 'Crypt::Blowfish';
|
||||
requires 'Locale::Maketext';
|
||||
@@ -27,5 +21,19 @@ requires 'Image::ExifTool';
|
||||
requires 'Data::Entropy';
|
||||
requires 'List::MoreUtils', '> 0.33';
|
||||
requires 'Archive::Zip';
|
||||
requires 'CHI';
|
||||
requires 'Data::Serializer';
|
||||
|
||||
feature 'postgresql', 'PostgreSQL support' => sub {
|
||||
requires 'Mojo::Pg';
|
||||
requires 'Mojolicious::Plugin::PgURLHelper';
|
||||
};
|
||||
feature 'sqlite', 'SQLite support' => sub {
|
||||
requires 'Mojo::SQLite', '>= 3.000';
|
||||
requires 'Minion::Backend::SQLite', '>= 4.001';
|
||||
};
|
||||
feature 'minion', 'Minion support' => sub {
|
||||
requires 'Minion';
|
||||
};
|
||||
feature 'cache', 'Cache system' => sub {
|
||||
requires 'CHI';
|
||||
requires 'Data::Serializer';
|
||||
};
|
||||
|
||||
@@ -1466,10 +1466,13 @@ DISTRIBUTIONS
|
||||
requirements:
|
||||
ExtUtils::MakeMaker 0
|
||||
perl 5.006
|
||||
Minion-4.06
|
||||
pathname: S/SR/SRI/Minion-4.06.tar.gz
|
||||
Minion-9.03
|
||||
pathname: S/SR/SRI/Minion-9.03.tar.gz
|
||||
provides:
|
||||
Minion 4.06
|
||||
LinkCheck undef
|
||||
LinkCheck::Controller::Links undef
|
||||
LinkCheck::Task::CheckLinks undef
|
||||
Minion 9.03
|
||||
Minion::Backend undef
|
||||
Minion::Backend::Pg undef
|
||||
Minion::Command::minion undef
|
||||
@@ -1477,20 +1480,23 @@ DISTRIBUTIONS
|
||||
Minion::Command::minion::worker undef
|
||||
Minion::Job undef
|
||||
Minion::Worker undef
|
||||
Minion::_Guard 9.03
|
||||
Mojolicious::Plugin::Minion undef
|
||||
Mojolicious::Plugin::Minion::Admin undef
|
||||
requirements:
|
||||
ExtUtils::MakeMaker 0
|
||||
Mojolicious 6.0
|
||||
Mojolicious 7.56
|
||||
perl 5.010001
|
||||
Minion-Backend-SQLite-0.009
|
||||
pathname: D/DB/DBOOK/Minion-Backend-SQLite-0.009.tar.gz
|
||||
Minion-Backend-SQLite-4.001
|
||||
pathname: D/DB/DBOOK/Minion-Backend-SQLite-4.001.tar.gz
|
||||
provides:
|
||||
Minion::Backend::SQLite 0.009
|
||||
Minion::Backend::SQLite 4.001
|
||||
requirements:
|
||||
Minion 4.0
|
||||
List::Util 0
|
||||
Minion 9.0
|
||||
Module::Build::Tiny 0.034
|
||||
Mojo::SQLite 1.002
|
||||
Mojolicious 6.0
|
||||
Mojo::SQLite 3.000
|
||||
Mojolicious 7.29
|
||||
Sys::Hostname 0
|
||||
Time::HiRes 0
|
||||
perl 5.010001
|
||||
|
||||
20
lib/Lutim.pm
20
lib/Lutim.pm
@@ -3,7 +3,6 @@ package Lutim;
|
||||
use Mojo::Base 'Mojolicious';
|
||||
use Mojo::IOLoop;
|
||||
use Lutim::DB::Image;
|
||||
use CHI;
|
||||
|
||||
use vars qw($im_loaded);
|
||||
BEGIN {
|
||||
@@ -59,14 +58,17 @@ sub startup {
|
||||
}
|
||||
});
|
||||
|
||||
my $cache_max_size = ($config->{cache_max_size} > 0) ? 8 * 1024 * 1024 * $config->{cache_max_size} : 1;
|
||||
$self->{images_cache} = CHI->new(
|
||||
driver => 'Memory',
|
||||
global => 1,
|
||||
is_size_aware => 1,
|
||||
max_size => $cache_max_size,
|
||||
expires_in => '1 day'
|
||||
);
|
||||
if ($config->{cache_max_size} != 0) {
|
||||
require CHI;
|
||||
my $cache_max_size = 8 * 1024 * 1024 * $config->{cache_max_size};
|
||||
$self->{images_cache} = CHI->new(
|
||||
driver => 'Memory',
|
||||
global => 1,
|
||||
is_size_aware => 1,
|
||||
max_size => $cache_max_size,
|
||||
expires_in => '1 day'
|
||||
);
|
||||
}
|
||||
|
||||
die "You need to provide a contact information in lutim.conf !" unless (defined($config->{contact}));
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ sub register {
|
||||
$app->plugin('PgURLHelper');
|
||||
|
||||
if ($app->config('dbtype') eq 'postgresql') {
|
||||
use Mojo::Pg;
|
||||
require Mojo::Pg;
|
||||
$app->helper(pg => \&_pg);
|
||||
|
||||
# Database migration
|
||||
@@ -25,7 +25,7 @@ sub register {
|
||||
}
|
||||
} elsif ($app->config('dbtype') eq 'sqlite') {
|
||||
# SQLite database migration if needed
|
||||
use Mojo::SQLite;
|
||||
require Mojo::SQLite;
|
||||
$app->helper(sqlite => \&_sqlite);
|
||||
|
||||
my $sql = Mojo::SQLite->new('sqlite:'.$app->config('db_path'));
|
||||
@@ -98,28 +98,42 @@ sub _render_file {
|
||||
$headers->add('Content-Disposition' => $dl.';filename='.$filename);
|
||||
$c->res->content->headers($headers);
|
||||
|
||||
my $cache = $c->app->{images_cache}->compute($img->short, undef, sub {
|
||||
my $cache;
|
||||
if ($c->config('cache_max_size') != 0) {
|
||||
$cache = $c->app->{images_cache}->compute($img->short, undef, sub {
|
||||
if ($key) {
|
||||
return {
|
||||
asset => $c->decrypt($key, $path, $iv),
|
||||
key => $key
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
asset => Mojo::File->new($path)->slurp,
|
||||
};
|
||||
}
|
||||
});
|
||||
if ($key && $key ne $cache->{key}) {
|
||||
my $tmp = $c->decrypt($key, $path, $iv);
|
||||
$cache->{asset} = $tmp;
|
||||
$c->app->{images_cache}->replace(
|
||||
$img->short,
|
||||
{
|
||||
asset => $tmp,
|
||||
key => $key
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if ($key) {
|
||||
return {
|
||||
$cache = {
|
||||
asset => $c->decrypt($key, $path, $iv),
|
||||
key => $key
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
$cache = {
|
||||
asset => Mojo::File->new($path)->slurp,
|
||||
};
|
||||
}
|
||||
});
|
||||
if ($key && $key ne $cache->{key}) {
|
||||
my $tmp = $c->decrypt($key, $path, $iv);
|
||||
$cache->{asset} = $tmp;
|
||||
$c->app->{images_cache}->replace(
|
||||
$img->short,
|
||||
{
|
||||
asset => $tmp,
|
||||
key => $key
|
||||
},
|
||||
);
|
||||
}
|
||||
# Extend expiration time
|
||||
my $asset = Mojo::Asset::Memory->new;
|
||||
@@ -293,7 +307,7 @@ sub _decrypt {
|
||||
sub _delete_image {
|
||||
my $c = shift;
|
||||
my $img = shift;
|
||||
if ($c->app->{images_cache}) {
|
||||
if ($c->config('cache_max_size') != 0 && $c->app->{images_cache}) {
|
||||
$c->app->{images_cache}->remove($img->short);
|
||||
}
|
||||
unlink $img->path or warn "Could not unlink ".$img->path.": $!";
|
||||
|
||||
2
t/test.t
2
t/test.t
@@ -51,6 +51,8 @@ BEGIN {
|
||||
db_path => 'minion.db'
|
||||
},
|
||||
cache_max_size => 0,
|
||||
quiet_logs => 0,
|
||||
disable_img_stats => 0,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -32,11 +32,11 @@ msgstr ""
|
||||
msgid "-or-"
|
||||
msgstr ""
|
||||
|
||||
#: lib/Lutim.pm:201 lib/Lutim/Command/cron/stats.pm:151 lib/Lutim/Command/cron/stats.pm:162 lib/Lutim/Command/cron/stats.pm:179 themes/default/templates/index.html.ep:5 themes/default/templates/raw.html.ep:10 themes/default/templates/raw.html.ep:21 themes/default/templates/raw.html.ep:38
|
||||
#: lib/Lutim.pm:203 lib/Lutim/Command/cron/stats.pm:151 lib/Lutim/Command/cron/stats.pm:162 lib/Lutim/Command/cron/stats.pm:179 themes/default/templates/index.html.ep:5 themes/default/templates/raw.html.ep:10 themes/default/templates/raw.html.ep:21 themes/default/templates/raw.html.ep:38
|
||||
msgid "1 year"
|
||||
msgstr ""
|
||||
|
||||
#: lib/Lutim.pm:200 lib/Lutim/Command/cron/stats.pm:148 lib/Lutim/Command/cron/stats.pm:159 lib/Lutim/Command/cron/stats.pm:176 themes/default/templates/index.html.ep:4 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/lutim.js.ep:151 themes/default/templates/raw.html.ep:18 themes/default/templates/raw.html.ep:35 themes/default/templates/raw.html.ep:7
|
||||
#: lib/Lutim.pm:202 lib/Lutim/Command/cron/stats.pm:148 lib/Lutim/Command/cron/stats.pm:159 lib/Lutim/Command/cron/stats.pm:176 themes/default/templates/index.html.ep:4 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/lutim.js.ep:151 themes/default/templates/raw.html.ep:18 themes/default/templates/raw.html.ep:35 themes/default/templates/raw.html.ep:7
|
||||
msgid "24 hours"
|
||||
msgstr ""
|
||||
|
||||
@@ -443,7 +443,7 @@ msgid "Uploaded files by days"
|
||||
msgstr ""
|
||||
|
||||
#. ($c->app->config('contact')
|
||||
#: lib/Lutim/Plugin/Helpers.pm:202
|
||||
#: lib/Lutim/Plugin/Helpers.pm:216
|
||||
msgid "Uploading is currently disabled, please try later or contact the administrator (%1)."
|
||||
msgstr ""
|
||||
|
||||
@@ -495,7 +495,7 @@ msgstr ""
|
||||
msgid "core developer"
|
||||
msgstr ""
|
||||
|
||||
#: lib/Lutim.pm:199 lib/Lutim/Command/cron/stats.pm:147 lib/Lutim/Command/cron/stats.pm:158 lib/Lutim/Command/cron/stats.pm:175 themes/default/templates/index.html.ep:3 themes/default/templates/raw.html.ep:17 themes/default/templates/raw.html.ep:34 themes/default/templates/raw.html.ep:6
|
||||
#: lib/Lutim.pm:201 lib/Lutim/Command/cron/stats.pm:147 lib/Lutim/Command/cron/stats.pm:158 lib/Lutim/Command/cron/stats.pm:175 themes/default/templates/index.html.ep:3 themes/default/templates/raw.html.ep:17 themes/default/templates/raw.html.ep:34 themes/default/templates/raw.html.ep:6
|
||||
msgid "no time limit"
|
||||
msgstr ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user