changeset 190:d4682cea8e58

Fun with alerts.
author Edho Arief <edho@myconan.net>
date Sat, 23 Feb 2013 14:31:34 +0900
parents b4b7a29b70f6
children 4e409ac7082d
files app/assets/stylesheets/alert.css app/controllers/pastes_controller.rb app/views/pastes/new.html.erb app/views/pastes/show.html.erb config/initializers/session_store.rb
diffstat 5 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/assets/stylesheets/alert.css	Sat Feb 23 14:31:34 2013 +0900
@@ -0,0 +1,5 @@
+.alert {
+  border-radius: 0 0 4px 4px;
+  -webkit-border-radius: 0 0 4px 4px;
+  -moz-border-radius: 0 0 4px 4px;
+}
--- a/app/controllers/pastes_controller.rb	Sat Feb 23 14:01:22 2013 +0900
+++ b/app/controllers/pastes_controller.rb	Sat Feb 23 14:31:34 2013 +0900
@@ -82,6 +82,7 @@
       flash[:notice] = "Paste ##{params[:id]} deleted"
       redirect_to root_path
     else
+      flash[:error] = 'Incorrect deletion key'
       render :action => :show
     end
   end
--- a/app/views/pastes/new.html.erb	Sat Feb 23 14:01:22 2013 +0900
+++ b/app/views/pastes/new.html.erb	Sat Feb 23 14:31:34 2013 +0900
@@ -1,4 +1,11 @@
 <% provide :title, 'New Paste' %>
+
+<% if flash[:notice] %>
+  <div class="alert alert-info">
+    <%= flash[:notice] %>
+  </div>
+<% end %>
+
 <div class="page-header">
   <h1>New Paste</h1>
 </div>
--- a/app/views/pastes/show.html.erb	Sat Feb 23 14:01:22 2013 +0900
+++ b/app/views/pastes/show.html.erb	Sat Feb 23 14:31:34 2013 +0900
@@ -1,4 +1,11 @@
 <% provide :title, "Paste ##{@paste.id}" %>
+
+<% if flash[:error] %>
+  <div class="alert alert-error">
+    <%= flash[:error] %>
+  </div>
+<% end %>
+
 <div class="page-header">
   <h1><%= content_for :title %></h1>
 </div>
@@ -38,7 +45,7 @@
 
 <div class="input-append">
   <%= form_for @paste, :method => :delete do |f| %>
-    <%= f.text_field :key, :value => nil, :placeholder => 'Deletion key' %>
+    <%= f.text_field :key, :value => nil, :placeholder => 'Deletion key', :autofocus => !flash[:error].blank? %>
     <%= f.submit 'Delete this paste', :class => 'btn btn-danger' %>
   <% end %>
 </div>
--- a/config/initializers/session_store.rb	Sat Feb 23 14:01:22 2013 +0900
+++ b/config/initializers/session_store.rb	Sat Feb 23 14:31:34 2013 +0900
@@ -1,6 +1,6 @@
 # Be sure to restart your server when you modify this file.
 
-Zeropaste::Application.config.session_store :disabled
+Zeropaste::Application.config.session_store ActionDispatch::Session::CacheStore
 
 # Use the database for sessions instead of the cookie-based default,
 # which shouldn't be used to store highly confidential information