From 8112dbb0349ee1ebd39e2799482a41cefcdd3b2d Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Sun, 24 Jun 2018 23:38:21 +1000 Subject: [PATCH] * LDV::Filebin : allow hide some files from pulbic list --- conf/schema.mysql.sql | 1 + lib/LDV/Filebin.pm | 4 +++- lib/LDV/I18N/ru.pm | 1 + templates/filebin/create.html.ep | 4 ++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/conf/schema.mysql.sql b/conf/schema.mysql.sql index b6884c9..8c0affb 100644 --- a/conf/schema.mysql.sql +++ b/conf/schema.mysql.sql @@ -11,6 +11,7 @@ CREATE TABLE filebin ( id INTEGER AUTO_INCREMENT, created 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 fname VARCHAR(255) NOT NULL DEFAULT '', -- original filename fext VARCHAR(16) NOT NULL DEFAULT '', -- separate file extension diff --git a/lib/LDV/Filebin.pm b/lib/LDV/Filebin.pm index 4bf8cdf..063856d 100644 --- a/lib/LDV/Filebin.pm +++ b/lib/LDV/Filebin.pm @@ -62,6 +62,7 @@ sub save { if $self->req->is_limit_exceeded; my $expire = $self->req->param('expire') || 7; # days + my $hidden = $self->req->param('hidden') || 0; my $upload = $self->req->upload('file'); die "no file uploaded\n" unless ($upload and $upload->size > 0); die "file too large\n" if ($upload->size > $conf->{file_maxsize}); @@ -75,6 +76,7 @@ sub save { my $file = { created => $time, expire => $time + $expire * 86400, + hidden => $hidden, ftype => 'b', # default -- generic binary fsize => $upload->size, fname => $upload->filename, @@ -134,7 +136,7 @@ sub latest { eval { 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 foreach my $file (@files) { $file->{thumb} = $self->_file_path($file->{created}, $file->{fext}); diff --git a/lib/LDV/I18N/ru.pm b/lib/LDV/I18N/ru.pm index c5e80cd..6dc7924 100644 --- a/lib/LDV/I18N/ru.pm +++ b/lib/LDV/I18N/ru.pm @@ -59,6 +59,7 @@ our %Lexicon = 'Upload' => 'Загрузить', 'Download' => 'Скачать', 'Filename' => 'Имя файла', + 'Hidden' => 'Скрыть', 'Info' => 'Информация', 'Comment' => 'Комментарий', 'Size' => 'Размер', diff --git a/templates/filebin/create.html.ep b/templates/filebin/create.html.ep index 12140e4..696e700 100644 --- a/templates/filebin/create.html.ep +++ b/templates/filebin/create.html.ep @@ -14,6 +14,10 @@ <%= tag 'label' => (for => 'expire') => l('Keep for') %>: <%= select_field 'expire' => \@times %> + + <%= check_box hidden => 0 %> + <%= tag 'label' => (for => 'hidden') => l('Hidden') %> + % if (config->{filebin}->{show_latest}) { <%= link_to l('Latest files') => "/filebin/latest", class => 'btn latest' %> % }