added error message support for the admin panel
This commit is contained in:
parent
5fec0c10b1
commit
23820508ed
1
Gemfile
1
Gemfile
|
@ -2,6 +2,7 @@ source :rubygems
|
|||
|
||||
gem 'sinatra'
|
||||
gem 'sinatra-support'
|
||||
gem 'rack-flash'
|
||||
gem 'haml'
|
||||
gem 'sass'
|
||||
gem 'compass'
|
||||
|
|
|
@ -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
|
||||
|
|
16
admin.rb
16
admin.rb
|
@ -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
|
||||
|
|
1
libs.rb
1
libs.rb
|
@ -8,6 +8,7 @@ require 'sass'
|
|||
require 'compass'
|
||||
require 'sinatra'
|
||||
require 'sinatra/support'
|
||||
require 'rack-flash'
|
||||
|
||||
# markups
|
||||
require 'redcloth'
|
||||
|
|
|
@ -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')"
|
||||
|
|
Loading…
Reference in New Issue