From 7e37608df95c909913f6e96ab900be14cd1ddf70 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Fri, 14 Oct 2011 09:44:56 +0200 Subject: [PATCH] Scaffolding: unified templates folder --- yesod-default/Yesod/Default/Util.hs | 16 ++++----- yesod-default/yesod-default.cabal | 2 +- yesod/Scaffolding/Scaffolder.hs | 34 +++++++++---------- yesod/scaffold/Foundation.hs.cg | 2 +- yesod/scaffold/project.cabal.cg | 2 +- .../boilerplate-layout.hamlet.cg | 0 .../default-layout-wrapper.hamlet.cg | 0 .../default-layout.hamlet.cg | 0 .../default-layout.lucius.cg | 0 .../{hamlet => templates}/homepage.hamlet.cg | 0 .../{julius => templates}/homepage.julius.cg | 0 .../{lucius => templates}/homepage.lucius.cg | 0 .../{lucius => templates}/normalize.lucius.cg | 0 yesod/scaffold/tiny/Application.hs.cg | 1 - yesod/scaffold/tiny/Foundation.hs.cg | 2 +- yesod/scaffold/tiny/project.cabal.cg | 2 +- yesod/yesod.cabal | 16 ++++----- 17 files changed, 38 insertions(+), 39 deletions(-) rename yesod/scaffold/{hamlet => templates}/boilerplate-layout.hamlet.cg (100%) rename yesod/scaffold/{hamlet => templates}/default-layout-wrapper.hamlet.cg (100%) rename yesod/scaffold/{hamlet => templates}/default-layout.hamlet.cg (100%) rename yesod/scaffold/{lucius => templates}/default-layout.lucius.cg (100%) rename yesod/scaffold/{hamlet => templates}/homepage.hamlet.cg (100%) rename yesod/scaffold/{julius => templates}/homepage.julius.cg (100%) rename yesod/scaffold/{lucius => templates}/homepage.lucius.cg (100%) rename yesod/scaffold/{lucius => templates}/normalize.lucius.cg (100%) diff --git a/yesod-default/Yesod/Default/Util.hs b/yesod-default/Yesod/Default/Util.hs index 4ab93b33..fa21a8b3 100644 --- a/yesod-default/Yesod/Default/Util.hs +++ b/yesod-default/Yesod/Default/Util.hs @@ -58,18 +58,18 @@ globFile kind x = kind ++ "/" ++ x ++ "." ++ kind widgetFileProduction :: FilePath -> Q Exp widgetFileProduction x = do - let h = whenExists x "hamlet" whamletFile - let c = whenExists x "cassius" cassiusFile - let j = whenExists x "julius" juliusFile - let l = whenExists x "lucius" luciusFile + let h = whenExists x "templates" whamletFile + let c = whenExists x "templates" cassiusFile + let j = whenExists x "templates" juliusFile + let l = whenExists x "templates" luciusFile [|$h >> addCassius $c >> addJulius $j >> addLucius $l|] widgetFileDebug :: FilePath -> Q Exp widgetFileDebug x = do - let h = whenExists x "hamlet" whamletFile - let c = whenExists x "cassius" cassiusFileDebug - let j = whenExists x "julius" juliusFileDebug - let l = whenExists x "lucius" luciusFileDebug + let h = whenExists x "templates" whamletFile + let c = whenExists x "templates" cassiusFileDebug + let j = whenExists x "templates" juliusFileDebug + let l = whenExists x "templates" luciusFileDebug [|$h >> addCassius $c >> addJulius $j >> addLucius $l|] whenExists :: String -> String -> (FilePath -> Q Exp) -> Q Exp diff --git a/yesod-default/yesod-default.cabal b/yesod-default/yesod-default.cabal index ec8524aa..7c43324a 100644 --- a/yesod-default/yesod-default.cabal +++ b/yesod-default/yesod-default.cabal @@ -1,5 +1,5 @@ name: yesod-default -version: 0.3.1 +version: 0.4.0 license: BSD3 license-file: LICENSE author: Patrick Brisbin diff --git a/yesod/Scaffolding/Scaffolder.hs b/yesod/Scaffolding/Scaffolder.hs index 15790c95..b48fcee2 100644 --- a/yesod/Scaffolding/Scaffolder.hs +++ b/yesod/Scaffolding/Scaffolder.hs @@ -128,10 +128,7 @@ scaffold = do mkDir fp = createDirectoryIfMissing True $ dir ++ '/' : fp mkDir "Handler" - mkDir "hamlet" - mkDir "cassius" - mkDir "lucius" - mkDir "julius" + mkDir "templates" mkDir "static" mkDir "static/css" mkDir "static/js" @@ -163,20 +160,23 @@ scaffold = do unless isTiny $ writeFile' "Model.hs" $(codegen "Model.hs") writeFile' "Settings.hs" $ ifTiny $(codegen "tiny/Settings.hs") $(codegen "Settings.hs") writeFile' "Settings/StaticFiles.hs" $(codegen "Settings/StaticFiles.hs") - writeFile' "lucius/default-layout.lucius" - $(codegen "lucius/default-layout.lucius") - writeFile' "hamlet/default-layout.hamlet" - $(codegen "hamlet/default-layout.hamlet") - writeFile' "hamlet/default-layout-wrapper.hamlet" - $(codegen "hamlet/default-layout-wrapper.hamlet") - writeFile' "hamlet/boilerplate-layout.hamlet" - $(codegen "hamlet/boilerplate-layout.hamlet") - writeFile' "lucius/normalize.lucius" - $(codegen "lucius/normalize.lucius") - writeFile' "hamlet/homepage.hamlet" $(codegen "hamlet/homepage.hamlet") + writeFile' "templates/default-layout.lucius" + $(codegen "templates/default-layout.lucius") + writeFile' "templates/default-layout.hamlet" + $(codegen "templates/default-layout.hamlet") + writeFile' "templates/default-layout-wrapper.hamlet" + $(codegen "templates/default-layout-wrapper.hamlet") + writeFile' "templates/boilerplate-layout.hamlet" + $(codegen "templates/boilerplate-layout.hamlet") + writeFile' "templates/normalize.lucius" + $(codegen "templates/normalize.lucius") + writeFile' "templates/homepage.hamlet" + $(codegen "templates/homepage.hamlet") writeFile' "config/routes" $ ifTiny $(codegen "tiny/config/routes") $(codegen "config/routes") - writeFile' "lucius/homepage.lucius" $(codegen "lucius/homepage.lucius") - writeFile' "julius/homepage.julius" $(codegen "julius/homepage.julius") + writeFile' "templates/homepage.lucius" + $(codegen "templates/homepage.lucius") + writeFile' "templates/homepage.julius" + $(codegen "templates/homepage.julius") unless isTiny $ writeFile' "config/models" $(codegen "config/models") writeFile' "messages/en.msg" $(codegen "messages/en.msg") diff --git a/yesod/scaffold/Foundation.hs.cg b/yesod/scaffold/Foundation.hs.cg index 4e1d736b..caedd061 100644 --- a/yesod/scaffold/Foundation.hs.cg +++ b/yesod/scaffold/Foundation.hs.cg @@ -95,7 +95,7 @@ instance Yesod ~sitearg~ where pc <- widgetToPageContent $ do $(widgetFile "normalize") $(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 -- a separate domain. Please see the staticRoot setting in Settings.hs diff --git a/yesod/scaffold/project.cabal.cg b/yesod/scaffold/project.cabal.cg index a61906c4..ac7297cb 100644 --- a/yesod/scaffold/project.cabal.cg +++ b/yesod/scaffold/project.cabal.cg @@ -52,7 +52,7 @@ executable ~project~ , yesod-core >= 0.9.3 && < 0.10 , yesod-auth >= 0.7.3 && < 0.8 , 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 , mime-mail >= 0.3.0.3 && < 0.4 , clientsession >= 0.7.3 && < 0.8 diff --git a/yesod/scaffold/hamlet/boilerplate-layout.hamlet.cg b/yesod/scaffold/templates/boilerplate-layout.hamlet.cg similarity index 100% rename from yesod/scaffold/hamlet/boilerplate-layout.hamlet.cg rename to yesod/scaffold/templates/boilerplate-layout.hamlet.cg diff --git a/yesod/scaffold/hamlet/default-layout-wrapper.hamlet.cg b/yesod/scaffold/templates/default-layout-wrapper.hamlet.cg similarity index 100% rename from yesod/scaffold/hamlet/default-layout-wrapper.hamlet.cg rename to yesod/scaffold/templates/default-layout-wrapper.hamlet.cg diff --git a/yesod/scaffold/hamlet/default-layout.hamlet.cg b/yesod/scaffold/templates/default-layout.hamlet.cg similarity index 100% rename from yesod/scaffold/hamlet/default-layout.hamlet.cg rename to yesod/scaffold/templates/default-layout.hamlet.cg diff --git a/yesod/scaffold/lucius/default-layout.lucius.cg b/yesod/scaffold/templates/default-layout.lucius.cg similarity index 100% rename from yesod/scaffold/lucius/default-layout.lucius.cg rename to yesod/scaffold/templates/default-layout.lucius.cg diff --git a/yesod/scaffold/hamlet/homepage.hamlet.cg b/yesod/scaffold/templates/homepage.hamlet.cg similarity index 100% rename from yesod/scaffold/hamlet/homepage.hamlet.cg rename to yesod/scaffold/templates/homepage.hamlet.cg diff --git a/yesod/scaffold/julius/homepage.julius.cg b/yesod/scaffold/templates/homepage.julius.cg similarity index 100% rename from yesod/scaffold/julius/homepage.julius.cg rename to yesod/scaffold/templates/homepage.julius.cg diff --git a/yesod/scaffold/lucius/homepage.lucius.cg b/yesod/scaffold/templates/homepage.lucius.cg similarity index 100% rename from yesod/scaffold/lucius/homepage.lucius.cg rename to yesod/scaffold/templates/homepage.lucius.cg diff --git a/yesod/scaffold/lucius/normalize.lucius.cg b/yesod/scaffold/templates/normalize.lucius.cg similarity index 100% rename from yesod/scaffold/lucius/normalize.lucius.cg rename to yesod/scaffold/templates/normalize.lucius.cg diff --git a/yesod/scaffold/tiny/Application.hs.cg b/yesod/scaffold/tiny/Application.hs.cg index 110747bc..7419e196 100644 --- a/yesod/scaffold/tiny/Application.hs.cg +++ b/yesod/scaffold/tiny/Application.hs.cg @@ -14,7 +14,6 @@ import Yesod.Default.Config import Yesod.Default.Main (defaultDevelApp, defaultRunner) import Yesod.Default.Handlers (getFaviconR, getRobotsR) import Yesod.Logger (Logger) -import Data.ByteString (ByteString) import Network.Wai (Application) import Data.Dynamic (Dynamic, toDyn) diff --git a/yesod/scaffold/tiny/Foundation.hs.cg b/yesod/scaffold/tiny/Foundation.hs.cg index 50e5e1ec..c8c72d34 100644 --- a/yesod/scaffold/tiny/Foundation.hs.cg +++ b/yesod/scaffold/tiny/Foundation.hs.cg @@ -81,7 +81,7 @@ instance Yesod ~sitearg~ where pc <- widgetToPageContent $ do $(widgetFile "normalize") $(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 -- a separate domain. Please see the staticroot setting in Settings.hs diff --git a/yesod/scaffold/tiny/project.cabal.cg b/yesod/scaffold/tiny/project.cabal.cg index 1d987f2d..d6725b56 100644 --- a/yesod/scaffold/tiny/project.cabal.cg +++ b/yesod/scaffold/tiny/project.cabal.cg @@ -48,7 +48,7 @@ executable ~project~ build-depends: base >= 4 && < 5 , yesod-core >= 0.9.3 && < 0.10 , 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 , bytestring >= 0.9 && < 0.10 , text >= 0.11 && < 0.12 diff --git a/yesod/yesod.cabal b/yesod/yesod.cabal index 2692cb3d..9f202099 100644 --- a/yesod/yesod.cabal +++ b/yesod/yesod.cabal @@ -17,8 +17,8 @@ homepage: http://www.yesodweb.com/ extra-source-files: input/*.cg - scaffold/lucius/default-layout.lucius.cg - scaffold/lucius/homepage.lucius.cg + scaffold/templates/default-layout.lucius.cg + scaffold/templates/homepage.lucius.cg scaffold/Model.hs.cg scaffold/Foundation.hs.cg scaffold/LICENSE.cg @@ -28,17 +28,17 @@ extra-source-files: scaffold/tiny/Application.hs.cg scaffold/tiny/config/routes.cg scaffold/tiny/Settings.hs.cg - scaffold/lucius/normalize.lucius.cg + scaffold/templates/normalize.lucius.cg scaffold/postgresqlConnPool.cg scaffold/sqliteConnPool.cg scaffold/.ghci.cg scaffold/project.cabal.cg scaffold/Application.hs.cg - scaffold/julius/homepage.julius.cg - scaffold/hamlet/homepage.hamlet.cg - scaffold/hamlet/default-layout.hamlet.cg - scaffold/hamlet/default-layout-wrapper.hamlet.cg - scaffold/hamlet/boilerplate-layout.hamlet.cg + scaffold/templates/homepage.julius.cg + scaffold/templates/homepage.hamlet.cg + scaffold/templates/default-layout.hamlet.cg + scaffold/templates/default-layout-wrapper.hamlet.cg + scaffold/templates/boilerplate-layout.hamlet.cg scaffold/deploy/Procfile.cg scaffold/main.hs.cg scaffold/Handler/Root.hs.cg