Browse Source

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

master
Alex 'AdUser' Z 6 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,
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

4
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});

1
lib/LDV/I18N/ru.pm

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

4
templates/filebin/create.html.ep

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

Loading…
Cancel
Save