diff --git a/yesod-bin/ChangeLog.md b/yesod-bin/ChangeLog.md index e1b086cb..a48acc60 100644 --- a/yesod-bin/ChangeLog.md +++ b/yesod-bin/ChangeLog.md @@ -1,3 +1,7 @@ +## 1.4.3 + +Add the minimal scaffolding + ## 1.4.2 Scaffolding updates: diff --git a/yesod-bin/Scaffolding/Scaffolder.hs b/yesod-bin/Scaffolding/Scaffolder.hs index 3f12291c..67d054b5 100644 --- a/yesod-bin/Scaffolding/Scaffolder.hs +++ b/yesod-bin/Scaffolding/Scaffolder.hs @@ -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) diff --git a/yesod-bin/hsfiles/minimal.hsfiles b/yesod-bin/hsfiles/minimal.hsfiles new file mode 100644 index 00000000..0b6c61fe --- /dev/null +++ b/yesod-bin/hsfiles/minimal.hsfiles @@ -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| +

+ HTML addition +

+ 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 + diff --git a/yesod-bin/input/database.cg b/yesod-bin/input/database.cg index dcb46169..c572ef8e 100644 --- a/yesod-bin/input/database.cg +++ b/yesod-bin/input/database.cg @@ -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? diff --git a/yesod-bin/yesod-bin.cabal b/yesod-bin/yesod-bin.cabal index 165062f2..b980bbab 100644 --- a/yesod-bin/yesod-bin.cabal +++ b/yesod-bin/yesod-bin.cabal @@ -1,5 +1,5 @@ name: yesod-bin -version: 1.4.2 +version: 1.4.3 license: MIT license-file: LICENSE author: Michael Snoyman