Use flashes

This commit is contained in:
Sam Dodrill 2015-01-08 17:51:20 -08:00
parent 05aaa39e17
commit b5984b43ec
5 changed files with 20 additions and 8 deletions

View File

@ -16,5 +16,5 @@ class App extends lapis.Application
@session.flash = nil
[index: "/"]: =>
@user = @session.user
@name = @session.name
render: true

View File

@ -81,6 +81,7 @@ class User extends lapis.Application
token: encoding.encode_base64 encoding.hmac_sha1(@params.email, os.time!)
}
@session.token = encoding.encode_base64 token.token
@title = "Login successful"
return "Hi " .. user.name

View File

@ -69,5 +69,10 @@ class Layout extends Widget
body ->
@header!
if @flash
div class: "flash", ->
text @flash
@body!
@footer!

View File

@ -1,5 +1,5 @@
body {
padding-top: 50px;
padding-top: 60px;
}
html {
@ -15,3 +15,13 @@ html {
height: 50px;
background-color: #f5f5f5;
}
.flash {
background: #cee5F5;
padding: 0.5em;
border: 1px solid #aacbe2;
}
.error {
background: #f0d6d6;
padding: 0.5em;
}

View File

@ -6,9 +6,5 @@ class Index extends Widget
div class: "body", ->
text "Welcome to my site!"
if @flash
p class: "flash", ->
text @flash
if @user
h2 "I think you are UID #{@user}"
if @name
h2 "I think you are #{@name}"