On Github leohaskell / yesod-slides
Created by 80910
"Yesod is a Haskell web framework for productive development of type-safe, RESTful, high performance web applications."
- Yesod Web Framework's teamtype-safety
висока производителност
по-малко boilerplate
използваме haskell
stack new my-project yesod-sqlite cd my-project stack setup stack build
/ HomeR GET /login LoginR GET POST /logout LogoutR GET /songs/#UserId SongsR GET /songinfo/#Int SongR GET
/ HomeR GET /login LoginR GET POST /logout LogoutR GET /songs/#UserId SongsR GET /songinfo/#Int SongR GET
getHomeR :: Handler Html getLoginR :: Handler Html postLoginR :: Handler Html getLogoutR :: Handler Html getSongsR :: UserId -> Handler Html getSongR :: Int -> Handler Html
getHomeR :: Handler Html getHomeR = defaultLayout [whamlet| <p>Welcome to my page! |]
интерполация
if..elseif..else
forall
компилират се
нямаме счупени линкове
$doctype <html> <head> <title>Yesod FM <body> <header> <nav> <ul #menu> <li> <a href=@{HomeR}>homepage $if logged <li> <a href=@{LogoutR}>log out(#{uname}) <div>^{content}
#london background-color: #{rainyBlue}
#wife right: 100% margin: 0
$(function() { $('#omni').on('click', function () { alert("42") }) })
data User = User { username :: Text , password :: Text , email :: Maybe Text }
userForm = renderDivs $ User <$> areq textField "username" Nothing <*> areq passwordField "password" Nothing <*> aopt emailField "email" Nothing
PostgreSQL
SQLite
MySQL
MongoDB
Redis
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase| User username Text password Text Username username Song album Text author Text title Text year Int userId UserId Maybe Name author title |]
user <- lookupSession "user" let (logged, uname) = case user of Just u -> (True, u) Nothing -> (False, "")
getLogoutR = do deleteSession "user" defaultLayout [whamlet| <p>You have successfully logged out. We'll miss you! |]
аутентикация
ауторизация