From afa1f146c116f65c0311a4eac4960836bf8ef452 Mon Sep 17 00:00:00 2001 From: "Alex \"AdUser\" Z" Date: Wed, 29 Oct 2014 17:54:35 +1000 Subject: [PATCH] * fix pages for zerobin --- templates/zerobin/create.html.ep | 30 +++++++++++++++++++----------- templates/zerobin/view.html.ep | 20 +++++--------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/templates/zerobin/create.html.ep b/templates/zerobin/create.html.ep index c755975..69dd1de 100644 --- a/templates/zerobin/create.html.ep +++ b/templates/zerobin/create.html.ep @@ -3,11 +3,14 @@ % my %times = (day => 1, week => 7, month => 30, quarter => 90, year => 395); % my @times = map { [l($_) => $times{$_}] } sort { $times{$a} <=> $times{$b} } keys(%times); % stash 'styles' => 'zerobin'; -% stash 'expire' => 30; +% param 'expire' => 30; +% my $syntax = (stash 'syntax') || []; +% param 'syntax' => ''; +% my %opts = (id => 'paste', name => 'paste', required => 1);

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

-
- <%= form_for "/zerobin2/create" => (method => 'POST') => begin %> + <%= form_for "/zerobin2" => (method => 'POST') => begin %> +
<%= submit_button l('Save') %> @@ -16,13 +19,18 @@ <%= select_field 'expire' => \@times %> - <%= check_box 'syntax' => 0 %> - <%= tag 'label' => (for => 'syntax') => l('Syntax highlight') %> + <%= tag 'label' => (for => 'syntax') => l('Syntax') %>: + <%= select_field 'syntax' => $syntax; %> - <% end %> -
-
-
- <%= tag 'textarea' => (id => "paste", placeholder => l('Paste your text here')) => '' %> -
+
+
+ <%= tag 'textarea' => (placeholder => l('Paste your text here'), %opts) => '' %> +
+ <% end %>
+% my $result = (flash 'result') || ''; +% if ($result) { +
+

<%= l(ucfirst($result)) %>

+
+% } diff --git a/templates/zerobin/view.html.ep b/templates/zerobin/view.html.ep index ec356d4..44b1073 100644 --- a/templates/zerobin/view.html.ep +++ b/templates/zerobin/view.html.ep @@ -6,24 +6,14 @@
- <%= link_to l('Create new') => "/zerobin2/create" %> + <%= link_to l('Create new') => "/zerobin2" %>

+% my $paste = (stash 'paste') || {}; +% my $syntax = $paste->{syntax}; +% my @opts = ($syntax and $syntax ne 'auto') ? (class => $syntax) : ();
-

-package LDV::Zerobin;
-
-use strict;
-use warnings;
-use utf8;
-
-use Mojo::Base 'Mojolicious::Controller';
-
-sub view   { my ($self) = @_; $self->render(); }
-sub create { my ($self) = @_; $self->render(); }
-
-1;
-    
+
<%= tag 'code' => (@opts) => $paste->{data}; %>