0
0
Fork 0

added error message support for the admin panel

This commit is contained in:
Gibheer 2011-06-27 09:19:28 +02:00
parent 5fec0c10b1
commit 23820508ed
5 changed files with 30 additions and 1 deletions

View File

@ -2,6 +2,7 @@ source :rubygems
gem 'sinatra'
gem 'sinatra-support'
gem 'rack-flash'
gem 'haml'
gem 'sass'
gem 'compass'

View File

@ -59,6 +59,8 @@ GEM
haml (3.1.2)
json (1.4.6)
rack (1.3.0)
rack-flash (0.1.1)
rack
sass (3.1.3)
sinatra (1.2.6)
rack (~> 1.1)
@ -78,6 +80,7 @@ DEPENDENCIES
data_mapper
dm-postgres-adapter
haml
rack-flash
sass
sinatra
sinatra-support

View File

@ -1,9 +1,25 @@
class Admin < Sinatra::Base
set $settings
enable :sessions
use Rack::Flash, :accessorize => [:error, :warning, :notice]
set :haml, :layout => :admin_layout
get '/' do
haml :admin_index
end
post '/login' do
account = Account.authenticate(params['username'], params['password'])
if account.nil?
flash.warning = 'wrong username or password'
redirect '/admin'
else
flash.notice = 'Login successful'
redirect '/admin'
end
end
get '/stylesheet.css' do
scss :admin_stylesheet
end
end

View File

@ -8,6 +8,7 @@ require 'sass'
require 'compass'
require 'sinatra'
require 'sinatra/support'
require 'rack-flash'
# markups
require 'redcloth'

View File

@ -3,9 +3,17 @@
%head
%title="zero-knowledge - Adminpanel"
%link{:rel => 'stylesheet', :href => '/stylesheet.css', :type => 'text/css'}
%link{:rel => 'stylesheet', :href => '/admin/stylesheet.css', :type => 'text/css'}
%script{:src => 'public/head.min.js'}
%body
#menu="Menue"
#content="Bereich oder so"
#messages
-unless flash.error.nil?
%p.error=flash.error
-unless flash.warning.nil?
%p.warning=flash.warning
-unless flash.notice.nil?
%p.notice=flash.notice
#content=yield
%script
="head.js('http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js','/public/admin.js')"