Browse Source

* zerobin syntax selector

master
Alex 'AdUser' Z 5 years ago
parent
commit
1a09c6e128
  1. 6
      conf/ldv.conf.sample
  2. 10
      lib/LDV/Zerobin.pm
  3. 2
      templates/zerobin/create.html.ep

6
conf/ldv.conf.sample

@ -49,7 +49,11 @@
zerobin => {
access => 'all',
syntax => ['bash', 'c', 'c++', 'css', 'html', 'perl', 'php', 'python', 'other'],
syntax => [
text => ['plaintext', 'markdown'],
lang => ['bash', 'c', 'c++', 'perl', 'php', 'python'],
markup => ['css', 'html', 'diff']
],
maxsize => 1 * 1024 * 1024,
},

10
lib/LDV/Zerobin.pm

@ -49,10 +49,12 @@ sub create {
$self->access_allowed($self->app->config->{zerobin}->{access})
or return;
my @syntax = ($self->c(text => ['plaintext', 'markdown']));
my $langs = $self->app->config->{zerobin}->{syntax};
push @syntax, $self->c(code => $langs)
if (ref($langs) eq 'ARRAY');
my @syntax = qw(auto);
my $syntax = [ @{ $self->app->config->{zerobin}->{syntax} } ];
while (my ($cat, $list) = splice(@{ $syntax }, 0, 2)) {
next unless $cat and ref($list) and ref($list) eq 'ARRAY';
push @syntax, $self->c($cat => $list);
}
$self->stash({syntax => \@syntax});
$self->render;

2
templates/zerobin/create.html.ep

@ -3,7 +3,7 @@
% my %times = (day => 1, week => 7, month => 30, quarter => 90, year => 395);
% my @times = map { [l($_) => $times{$_}] } sort { $times{$a} <=> $times{$b} } keys(%times);
% param 'expire' => 30;
% my $syntax = (stash 'syntax') || [];
% my $syntax = stash('syntax') || [];
% param 'syntax' => '';
% my %opts = (id => 'paste', name => 'paste');
<h1>Создать запись</h1>

Loading…
Cancel
Save