This commit is contained in:
Luc Didry
2014-02-24 21:57:50 +01:00
parent 9c896f1a59
commit 37feb11430
6 changed files with 44 additions and 5 deletions

View File

@@ -57,7 +57,8 @@ vi lutim.conf
* keep\_ip\_during: when you delete IP addresses of image's senders with `script/lutim cron cleanbdd`, the IP addresses of images older than `keep_ip_during` days will be deleted (default is 365) ;
* broadcast\_message: put some string (not HTML) here and this message will be displayed on all LUTIm pages (not in JSON responses) ;
* allowed\_domains: array of authorized domains for API calls. Example: `['http://1.example.com', 'http://2.example.com']`. If you want to authorize everyone to use the API: `['*']` ;
* default\_delay: what is the default time limit for files? Valid values are 0, 1, 7, 30 and 365.
* default\_delay: what is the default time limit for files? Valid values are 0, 1, 7, 30 and 365 ;
* max\_delay: if defined, the images will be deleted after that delay (in days), even if they were uploaded with "no delay" (or value superior to max\_delay) option and a warning message will be displayed on homepage.
##Usage
```

View File

@@ -126,14 +126,44 @@ sub startup {
}
);
$self->helper(
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 0;
}
);
$self->helper(
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 0;
}
);
$self->helper(
is_selected => sub {
my $c = shift;
my $num = shift;
$c->config->{default_delay} = 0 unless (defined($c->config->{default_delay}));
return ($num == $c->config->{default_delay}) ? 'selected="selected"' : '';
return ($num == $c->default_delay) ? 'selected="selected"' : '';
}
);
@@ -306,7 +336,7 @@ sub startup {
mediatype => $mediatype,
footprint => digest_file_hex($path, 'SHA-512'),
enabled => 1,
delete_at_day => ($c->param('delete-day')) ? $c->param('delete-day') : 0,
delete_at_day => ($c->param('delete-day')) ? $c->param('delete-day') : $c->max_delay,
delete_at_first_view => ($c->param('first-view')) ? 1 : 0,
created_at => time(),
created_by => $ip

View File

@@ -64,6 +64,7 @@ our %Lexicon = (
'delay_7' => '7 days',
'delay_30' => '30 days',
'delay_365' => '1 year',
'max_delay' => 'Warning! The maximum time limit for an image is [_1] day(s), even if you choose "no time limit".',
);
1;

View File

@@ -64,6 +64,7 @@ our %Lexicon = (
'delay_7' => '7 jours',
'delay_30' => '30 jours',
'delay_365' => '1 an',
'max_delay' => 'Attention ! Le délai maximal de rétention d\'une image est de [_1] jour(s), même si vous choisissez « pas de limitation de durée ».',
);
1;

View File

@@ -23,4 +23,5 @@
#broadcast_message => 'Maintenance', #optional, the broadcast_message is displayed on all pages of LUTIm (but no in json response)
#allowed_domains => ['http://1.example.com', 'http://2.example.com'], #optional, array of authorized domains for API calls. If you want to authorize everyone to use the API: ['*']
#default_delay => 0, #optional: what is the default time limit for files? Valid values are 0, 1, 7, 30 and 365.
#max_delay => 0, #optional, if defined, the images will be deleted after that delay (in days), even if they were uploaded with "no delay" (or value superior to max\_delay) option and a warning message will be displayed on homepage.
};

View File

@@ -1,6 +1,11 @@
% # vim:set sw=4 ts=4 sts=4 ft=html.epl expandtab:
% my $scheme = (defined(config('https')) && config('https')) ? 'https' : 'http';
<div class="messages">
% if (max_delay != 0) {
<div class="alert alert-warning text-center">
<strong><%=l('max_delay', max_delay) %></strong>
</div>
% }
% if (defined(flash('short'))) {
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>