diff --git a/conf/ldv.conf.sample b/conf/ldv.conf.sample index 631b421..7ed837b 100644 --- a/conf/ldv.conf.sample +++ b/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, }, diff --git a/lib/LDV/Zerobin.pm b/lib/LDV/Zerobin.pm index 3696af0..9c7d99c 100644 --- a/lib/LDV/Zerobin.pm +++ b/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; diff --git a/templates/zerobin/create.html.ep b/templates/zerobin/create.html.ep index a43eac0..3345efa 100644 --- a/templates/zerobin/create.html.ep +++ b/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');

Создать запись