Add mini scaffolding

This commit is contained in:
Michael Snoyman 2014-12-20 21:31:39 +02:00
parent b3754498ec
commit 7faea277cc
5 changed files with 135 additions and 1 deletions

View File

@ -1,3 +1,7 @@
## 1.4.3
Add the minimal scaffolding
## 1.4.2
Scaffolding updates:

View File

@ -35,6 +35,7 @@ data Backend = Sqlite
| Mysql
| MongoDB
| Simple
| Minimal
deriving (Eq, Read, Show, Enum, Bounded)
puts :: LT.Text -> IO ()
@ -50,6 +51,7 @@ showBackend PostgresqlFay = "pf"
showBackend Mysql = "mysql"
showBackend MongoDB = "mongo"
showBackend Simple = "simple"
showBackend Minimal = "mini"
readBackend :: String -> Maybe Backend
readBackend s = lookup s $ map (showBackend &&& id) backends
@ -61,6 +63,7 @@ backendBS PostgresqlFay = $(embedFile "hsfiles/postgres-fay.hsfiles")
backendBS Mysql = $(embedFile "hsfiles/mysql.hsfiles")
backendBS MongoDB = $(embedFile "hsfiles/mongo.hsfiles")
backendBS Simple = $(embedFile "hsfiles/simple.hsfiles")
backendBS Minimal = $(embedFile "hsfiles/minimal.hsfiles")
validPackageName :: String -> Bool
validPackageName s = isJust (simpleParse s :: Maybe PackageName)

View File

@ -0,0 +1,125 @@
{-# START_FILE .dir-locals.el #-}
((haskell-mode . ((haskell-indent-spaces . 4)
(haskell-process-use-ghci . t)))
(hamlet-mode . ((hamlet/basic-offset . 4)
(haskell-process-use-ghci . t))))
{-# START_FILE .ghci #-}
:set -i.:config:dist/build/autogen
:set -DDEVELOPMENT
:set -XCPP -XTemplateHaskell -XQuasiQuotes -XTypeFamilies -XFlexibleContexts -XGADTs -XOverloadedStrings -XMultiParamTypeClasses -XGeneralizedNewtypeDeriving -XEmptyDataDecls -XDeriveDataTypeable
{-# START_FILE .gitignore #-}
dist*
static/tmp/
static/combined/
config/client_session_key.aes
*.hi
*.o
*.sqlite3
.hsenv*
cabal-dev/
yesod-devel/
.cabal-sandbox
cabal.sandbox.config
.DS_Store
*.swp
{-# START_FILE Add.hs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Add where
import Foundation
import Yesod
getAddR :: Int -> Int -> Handler TypedContent
getAddR x y = selectRep $ do
provideRep $ defaultLayout $ do
setTitle "Addition"
[whamlet|#{x} + #{y} = #{z}|]
provideJson $ object ["result" .= z]
where
z = x + y
{-# START_FILE Application.hs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ViewPatterns #-}
module Application where
import Foundation
import Yesod
import Add
import Home
mkYesodDispatch "App" resourcesApp
{-# START_FILE Foundation.hs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
module Foundation where
import Yesod
data App = App
mkYesodData "App" $(parseRoutesFile "routes")
instance Yesod App
{-# START_FILE Home.hs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Home where
import Foundation
import Yesod
getHomeR :: Handler Html
getHomeR = defaultLayout $ do
setTitle "Minimal Multifile"
[whamlet|
<p>
<a href=@{AddR 5 7}>HTML addition
<p>
<a href=@{AddR 5 7}?_accept=application/json>JSON addition
|]
{-# START_FILE Main.hs #-}
import Application () -- for YesodDispatch instance
import Foundation
import Yesod
main :: IO ()
main = warp 3000 App
{-# START_FILE PROJECTNAME.cabal #-}
name: PROJECTNAME
version: 0.0.0
cabal-version: >= 1.8
build-type: Simple
extra-source-files: routes
executable PROJECTNAME
main-is: Main.hs
other-modules: Application
Foundation
Add
Home
ghc-options: -Wall -fwarn-tabs -O2
build-depends: base
, yesod
ghc-options: -threaded -O2 -rtsopts -with-rtsopts=-N
{-# START_FILE routes #-}
/ HomeR GET
/add/#Int/#Int AddR GET

View File

@ -8,6 +8,8 @@ We recommend starting with SQLite: it has no dependencies.
mongo = mongodb
mysql = MySQL
simple = no database, no auth
mini = bare bones, the "Hello World" of multi-file Yesod apps
(Note: not configured to work with yesod devel)
url = Let me specify URL containing a site (advanced)
So, what'll it be?

View File

@ -1,5 +1,5 @@
name: yesod-bin
version: 1.4.2
version: 1.4.3
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>