Browse Source

* LDV::Filebin : allow hide some files from pulbic list

master
Alex 'AdUser' Z 7 years ago
parent
commit
8112dbb034
  1. 1
      conf/schema.mysql.sql
  2. 4
      lib/LDV/Filebin.pm
  3. 1
      lib/LDV/I18N/ru.pm
  4. 4
      templates/filebin/create.html.ep

1
conf/schema.mysql.sql

@ -11,6 +11,7 @@ CREATE TABLE filebin (
id INTEGER AUTO_INCREMENT, id INTEGER AUTO_INCREMENT,
created INT(11) UNSIGNED NOT NULL DEFAULT 0, created INT(11) UNSIGNED NOT NULL DEFAULT 0,
expire INT(11) UNSIGNED NOT NULL DEFAULT 0, expire INT(11) UNSIGNED NOT NULL DEFAULT 0,
hidden TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
ftype CHAR(1) NOT NULL DEFAULT 'b', -- 'b' for generic binary, 't' for text, 'i' for image, 'v' for video, 'a' for audio ftype CHAR(1) NOT NULL DEFAULT 'b', -- 'b' for generic binary, 't' for text, 'i' for image, 'v' for video, 'a' for audio
fname VARCHAR(255) NOT NULL DEFAULT '', -- original filename fname VARCHAR(255) NOT NULL DEFAULT '', -- original filename
fext VARCHAR(16) NOT NULL DEFAULT '', -- separate file extension fext VARCHAR(16) NOT NULL DEFAULT '', -- separate file extension

4
lib/LDV/Filebin.pm

@ -62,6 +62,7 @@ sub save {
if $self->req->is_limit_exceeded; if $self->req->is_limit_exceeded;
my $expire = $self->req->param('expire') || 7; # days my $expire = $self->req->param('expire') || 7; # days
my $hidden = $self->req->param('hidden') || 0;
my $upload = $self->req->upload('file'); my $upload = $self->req->upload('file');
die "no file uploaded\n" unless ($upload and $upload->size > 0); die "no file uploaded\n" unless ($upload and $upload->size > 0);
die "file too large\n" if ($upload->size > $conf->{file_maxsize}); die "file too large\n" if ($upload->size > $conf->{file_maxsize});
@ -75,6 +76,7 @@ sub save {
my $file = { my $file = {
created => $time, expire => $time + $expire * 86400, created => $time, expire => $time + $expire * 86400,
hidden => $hidden,
ftype => 'b', # default -- generic binary ftype => 'b', # default -- generic binary
fsize => $upload->size, fsize => $upload->size,
fname => $upload->filename, fname => $upload->filename,
@ -134,7 +136,7 @@ sub latest {
eval { eval {
my $now = time(); my $now = time();
my @files = $self->app->db->select('filebin', '*', {expire => {'>=' => $now}}, {-desc => 'created'})->hashes; my @files = $self->app->db->select('filebin', '*', {expire => {'>=' => $now}, hidden => 0}, {-desc => 'created'})->hashes;
splice(@files, 15); # first 15 elements splice(@files, 15); # first 15 elements
foreach my $file (@files) { foreach my $file (@files) {
$file->{thumb} = $self->_file_path($file->{created}, $file->{fext}); $file->{thumb} = $self->_file_path($file->{created}, $file->{fext});

1
lib/LDV/I18N/ru.pm

@ -59,6 +59,7 @@ our %Lexicon =
'Upload' => 'Загрузить', 'Upload' => 'Загрузить',
'Download' => 'Скачать', 'Download' => 'Скачать',
'Filename' => 'Имя файла', 'Filename' => 'Имя файла',
'Hidden' => 'Скрыть',
'Info' => 'Информация', 'Info' => 'Информация',
'Comment' => 'Комментарий', 'Comment' => 'Комментарий',
'Size' => 'Размер', 'Size' => 'Размер',

4
templates/filebin/create.html.ep

@ -14,6 +14,10 @@
<%= tag 'label' => (for => 'expire') => l('Keep for') %>: <%= tag 'label' => (for => 'expire') => l('Keep for') %>:
<%= select_field 'expire' => \@times %> <%= select_field 'expire' => \@times %>
</span> </span>
<span class="filebin cblock">
<%= check_box hidden => 0 %>
<%= tag 'label' => (for => 'hidden') => l('Hidden') %>
</span>
% if (config->{filebin}->{show_latest}) { % if (config->{filebin}->{show_latest}) {
<%= link_to l('Latest files') => "/filebin/latest", class => 'btn latest' %> <%= link_to l('Latest files') => "/filebin/latest", class => 'btn latest' %>
% } % }

Loading…
Cancel
Save