Scaffolding: unified templates folder

This commit is contained in:
Michael Snoyman 2011-10-14 09:44:56 +02:00
parent 3bd46b509b
commit 7e37608df9
17 changed files with 38 additions and 39 deletions

View File

@ -58,18 +58,18 @@ globFile kind x = kind ++ "/" ++ x ++ "." ++ kind
widgetFileProduction :: FilePath -> Q Exp widgetFileProduction :: FilePath -> Q Exp
widgetFileProduction x = do widgetFileProduction x = do
let h = whenExists x "hamlet" whamletFile let h = whenExists x "templates" whamletFile
let c = whenExists x "cassius" cassiusFile let c = whenExists x "templates" cassiusFile
let j = whenExists x "julius" juliusFile let j = whenExists x "templates" juliusFile
let l = whenExists x "lucius" luciusFile let l = whenExists x "templates" luciusFile
[|$h >> addCassius $c >> addJulius $j >> addLucius $l|] [|$h >> addCassius $c >> addJulius $j >> addLucius $l|]
widgetFileDebug :: FilePath -> Q Exp widgetFileDebug :: FilePath -> Q Exp
widgetFileDebug x = do widgetFileDebug x = do
let h = whenExists x "hamlet" whamletFile let h = whenExists x "templates" whamletFile
let c = whenExists x "cassius" cassiusFileDebug let c = whenExists x "templates" cassiusFileDebug
let j = whenExists x "julius" juliusFileDebug let j = whenExists x "templates" juliusFileDebug
let l = whenExists x "lucius" luciusFileDebug let l = whenExists x "templates" luciusFileDebug
[|$h >> addCassius $c >> addJulius $j >> addLucius $l|] [|$h >> addCassius $c >> addJulius $j >> addLucius $l|]
whenExists :: String -> String -> (FilePath -> Q Exp) -> Q Exp whenExists :: String -> String -> (FilePath -> Q Exp) -> Q Exp

View File

@ -1,5 +1,5 @@
name: yesod-default name: yesod-default
version: 0.3.1 version: 0.4.0
license: BSD3 license: BSD3
license-file: LICENSE license-file: LICENSE
author: Patrick Brisbin author: Patrick Brisbin

View File

@ -128,10 +128,7 @@ scaffold = do
mkDir fp = createDirectoryIfMissing True $ dir ++ '/' : fp mkDir fp = createDirectoryIfMissing True $ dir ++ '/' : fp
mkDir "Handler" mkDir "Handler"
mkDir "hamlet" mkDir "templates"
mkDir "cassius"
mkDir "lucius"
mkDir "julius"
mkDir "static" mkDir "static"
mkDir "static/css" mkDir "static/css"
mkDir "static/js" mkDir "static/js"
@ -163,20 +160,23 @@ scaffold = do
unless isTiny $ writeFile' "Model.hs" $(codegen "Model.hs") unless isTiny $ writeFile' "Model.hs" $(codegen "Model.hs")
writeFile' "Settings.hs" $ ifTiny $(codegen "tiny/Settings.hs") $(codegen "Settings.hs") writeFile' "Settings.hs" $ ifTiny $(codegen "tiny/Settings.hs") $(codegen "Settings.hs")
writeFile' "Settings/StaticFiles.hs" $(codegen "Settings/StaticFiles.hs") writeFile' "Settings/StaticFiles.hs" $(codegen "Settings/StaticFiles.hs")
writeFile' "lucius/default-layout.lucius" writeFile' "templates/default-layout.lucius"
$(codegen "lucius/default-layout.lucius") $(codegen "templates/default-layout.lucius")
writeFile' "hamlet/default-layout.hamlet" writeFile' "templates/default-layout.hamlet"
$(codegen "hamlet/default-layout.hamlet") $(codegen "templates/default-layout.hamlet")
writeFile' "hamlet/default-layout-wrapper.hamlet" writeFile' "templates/default-layout-wrapper.hamlet"
$(codegen "hamlet/default-layout-wrapper.hamlet") $(codegen "templates/default-layout-wrapper.hamlet")
writeFile' "hamlet/boilerplate-layout.hamlet" writeFile' "templates/boilerplate-layout.hamlet"
$(codegen "hamlet/boilerplate-layout.hamlet") $(codegen "templates/boilerplate-layout.hamlet")
writeFile' "lucius/normalize.lucius" writeFile' "templates/normalize.lucius"
$(codegen "lucius/normalize.lucius") $(codegen "templates/normalize.lucius")
writeFile' "hamlet/homepage.hamlet" $(codegen "hamlet/homepage.hamlet") writeFile' "templates/homepage.hamlet"
$(codegen "templates/homepage.hamlet")
writeFile' "config/routes" $ ifTiny $(codegen "tiny/config/routes") $(codegen "config/routes") writeFile' "config/routes" $ ifTiny $(codegen "tiny/config/routes") $(codegen "config/routes")
writeFile' "lucius/homepage.lucius" $(codegen "lucius/homepage.lucius") writeFile' "templates/homepage.lucius"
writeFile' "julius/homepage.julius" $(codegen "julius/homepage.julius") $(codegen "templates/homepage.lucius")
writeFile' "templates/homepage.julius"
$(codegen "templates/homepage.julius")
unless isTiny $ writeFile' "config/models" $(codegen "config/models") unless isTiny $ writeFile' "config/models" $(codegen "config/models")
writeFile' "messages/en.msg" $(codegen "messages/en.msg") writeFile' "messages/en.msg" $(codegen "messages/en.msg")

View File

@ -95,7 +95,7 @@ instance Yesod ~sitearg~ where
pc <- widgetToPageContent $ do pc <- widgetToPageContent $ do
$(widgetFile "normalize") $(widgetFile "normalize")
$(widgetFile "default-layout") $(widgetFile "default-layout")
hamletToRepHtml $(hamletFile "hamlet/default-layout-wrapper.hamlet") hamletToRepHtml $(hamletFile "templates/default-layout-wrapper.hamlet")
-- This is done to provide an optimization for serving static files from -- This is done to provide an optimization for serving static files from
-- a separate domain. Please see the staticRoot setting in Settings.hs -- a separate domain. Please see the staticRoot setting in Settings.hs

View File

@ -52,7 +52,7 @@ executable ~project~
, yesod-core >= 0.9.3 && < 0.10 , yesod-core >= 0.9.3 && < 0.10
, yesod-auth >= 0.7.3 && < 0.8 , yesod-auth >= 0.7.3 && < 0.8
, yesod-static >= 0.3.1 && < 0.4 , yesod-static >= 0.3.1 && < 0.4
, yesod-default >= 0.3.1 && < 0.4 , yesod-default >= 0.4 && < 0.5
, yesod-form >= 0.3.3 && < 0.4 , yesod-form >= 0.3.3 && < 0.4
, mime-mail >= 0.3.0.3 && < 0.4 , mime-mail >= 0.3.0.3 && < 0.4
, clientsession >= 0.7.3 && < 0.8 , clientsession >= 0.7.3 && < 0.8

View File

@ -14,7 +14,6 @@ import Yesod.Default.Config
import Yesod.Default.Main (defaultDevelApp, defaultRunner) import Yesod.Default.Main (defaultDevelApp, defaultRunner)
import Yesod.Default.Handlers (getFaviconR, getRobotsR) import Yesod.Default.Handlers (getFaviconR, getRobotsR)
import Yesod.Logger (Logger) import Yesod.Logger (Logger)
import Data.ByteString (ByteString)
import Network.Wai (Application) import Network.Wai (Application)
import Data.Dynamic (Dynamic, toDyn) import Data.Dynamic (Dynamic, toDyn)

View File

@ -81,7 +81,7 @@ instance Yesod ~sitearg~ where
pc <- widgetToPageContent $ do pc <- widgetToPageContent $ do
$(widgetFile "normalize") $(widgetFile "normalize")
$(widgetFile "default-layout") $(widgetFile "default-layout")
hamletToRepHtml $(hamletFile "hamlet/default-layout-wrapper.hamlet") hamletToRepHtml $(hamletFile "templates/default-layout-wrapper.hamlet")
-- This is done to provide an optimization for serving static files from -- This is done to provide an optimization for serving static files from
-- a separate domain. Please see the staticroot setting in Settings.hs -- a separate domain. Please see the staticroot setting in Settings.hs

View File

@ -48,7 +48,7 @@ executable ~project~
build-depends: base >= 4 && < 5 build-depends: base >= 4 && < 5
, yesod-core >= 0.9.3 && < 0.10 , yesod-core >= 0.9.3 && < 0.10
, yesod-static >= 0.3.1 && < 0.4 , yesod-static >= 0.3.1 && < 0.4
, yesod-default >= 0.3.1 && < 0.4 , yesod-default >= 0.4 && < 0.5
, clientsession >= 0.7.3 && < 0.8 , clientsession >= 0.7.3 && < 0.8
, bytestring >= 0.9 && < 0.10 , bytestring >= 0.9 && < 0.10
, text >= 0.11 && < 0.12 , text >= 0.11 && < 0.12

View File

@ -17,8 +17,8 @@ homepage: http://www.yesodweb.com/
extra-source-files: extra-source-files:
input/*.cg input/*.cg
scaffold/lucius/default-layout.lucius.cg scaffold/templates/default-layout.lucius.cg
scaffold/lucius/homepage.lucius.cg scaffold/templates/homepage.lucius.cg
scaffold/Model.hs.cg scaffold/Model.hs.cg
scaffold/Foundation.hs.cg scaffold/Foundation.hs.cg
scaffold/LICENSE.cg scaffold/LICENSE.cg
@ -28,17 +28,17 @@ extra-source-files:
scaffold/tiny/Application.hs.cg scaffold/tiny/Application.hs.cg
scaffold/tiny/config/routes.cg scaffold/tiny/config/routes.cg
scaffold/tiny/Settings.hs.cg scaffold/tiny/Settings.hs.cg
scaffold/lucius/normalize.lucius.cg scaffold/templates/normalize.lucius.cg
scaffold/postgresqlConnPool.cg scaffold/postgresqlConnPool.cg
scaffold/sqliteConnPool.cg scaffold/sqliteConnPool.cg
scaffold/.ghci.cg scaffold/.ghci.cg
scaffold/project.cabal.cg scaffold/project.cabal.cg
scaffold/Application.hs.cg scaffold/Application.hs.cg
scaffold/julius/homepage.julius.cg scaffold/templates/homepage.julius.cg
scaffold/hamlet/homepage.hamlet.cg scaffold/templates/homepage.hamlet.cg
scaffold/hamlet/default-layout.hamlet.cg scaffold/templates/default-layout.hamlet.cg
scaffold/hamlet/default-layout-wrapper.hamlet.cg scaffold/templates/default-layout-wrapper.hamlet.cg
scaffold/hamlet/boilerplate-layout.hamlet.cg scaffold/templates/boilerplate-layout.hamlet.cg
scaffold/deploy/Procfile.cg scaffold/deploy/Procfile.cg
scaffold/main.hs.cg scaffold/main.hs.cg
scaffold/Handler/Root.hs.cg scaffold/Handler/Root.hs.cg