Add mini scaffolding
This commit is contained in:
parent
b3754498ec
commit
7faea277cc
@ -1,3 +1,7 @@
|
|||||||
|
## 1.4.3
|
||||||
|
|
||||||
|
Add the minimal scaffolding
|
||||||
|
|
||||||
## 1.4.2
|
## 1.4.2
|
||||||
|
|
||||||
Scaffolding updates:
|
Scaffolding updates:
|
||||||
|
|||||||
@ -35,6 +35,7 @@ data Backend = Sqlite
|
|||||||
| Mysql
|
| Mysql
|
||||||
| MongoDB
|
| MongoDB
|
||||||
| Simple
|
| Simple
|
||||||
|
| Minimal
|
||||||
deriving (Eq, Read, Show, Enum, Bounded)
|
deriving (Eq, Read, Show, Enum, Bounded)
|
||||||
|
|
||||||
puts :: LT.Text -> IO ()
|
puts :: LT.Text -> IO ()
|
||||||
@ -50,6 +51,7 @@ showBackend PostgresqlFay = "pf"
|
|||||||
showBackend Mysql = "mysql"
|
showBackend Mysql = "mysql"
|
||||||
showBackend MongoDB = "mongo"
|
showBackend MongoDB = "mongo"
|
||||||
showBackend Simple = "simple"
|
showBackend Simple = "simple"
|
||||||
|
showBackend Minimal = "mini"
|
||||||
|
|
||||||
readBackend :: String -> Maybe Backend
|
readBackend :: String -> Maybe Backend
|
||||||
readBackend s = lookup s $ map (showBackend &&& id) backends
|
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 Mysql = $(embedFile "hsfiles/mysql.hsfiles")
|
||||||
backendBS MongoDB = $(embedFile "hsfiles/mongo.hsfiles")
|
backendBS MongoDB = $(embedFile "hsfiles/mongo.hsfiles")
|
||||||
backendBS Simple = $(embedFile "hsfiles/simple.hsfiles")
|
backendBS Simple = $(embedFile "hsfiles/simple.hsfiles")
|
||||||
|
backendBS Minimal = $(embedFile "hsfiles/minimal.hsfiles")
|
||||||
|
|
||||||
validPackageName :: String -> Bool
|
validPackageName :: String -> Bool
|
||||||
validPackageName s = isJust (simpleParse s :: Maybe PackageName)
|
validPackageName s = isJust (simpleParse s :: Maybe PackageName)
|
||||||
|
|||||||
125
yesod-bin/hsfiles/minimal.hsfiles
Normal file
125
yesod-bin/hsfiles/minimal.hsfiles
Normal 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
|
||||||
|
|
||||||
@ -8,6 +8,8 @@ We recommend starting with SQLite: it has no dependencies.
|
|||||||
mongo = mongodb
|
mongo = mongodb
|
||||||
mysql = MySQL
|
mysql = MySQL
|
||||||
simple = no database, no auth
|
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)
|
url = Let me specify URL containing a site (advanced)
|
||||||
|
|
||||||
So, what'll it be?
|
So, what'll it be?
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-bin
|
name: yesod-bin
|
||||||
version: 1.4.2
|
version: 1.4.3
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user