diff --git a/scaffold.hs b/scaffold.hs index d7097e1c..70539c33 100644 --- a/scaffold.hs +++ b/scaffold.hs @@ -98,10 +98,12 @@ scaffold = do mkDir "Handler" mkDir "hamlet" mkDir "cassius" + mkDir "lucius" mkDir "julius" mkDir "static" + mkDir "config" - writeFile' (project ++ ".hs") $(codegen "test_hs") + writeFile' ("config/" ++ project ++ ".hs") $(codegen "test_hs") writeFile' "devel-server.hs" $(codegen "devel-server_hs") writeFile' (project ++ ".cabal") $ if backendS == "m" then $(codegen "mini-cabal") else $(codegen "cabal") writeFile' "LICENSE" $(codegen "LICENSE") @@ -109,19 +111,19 @@ scaffold = do writeFile' "Controller.hs" $ if backendS == "m" then $(codegen "mini-Controller_hs") else $(codegen "Controller_hs") writeFile' "Handler/Root.hs" $ if backendS == "m" then $(codegen "mini-Root_hs") else $(codegen "Root_hs") when (backendS /= "m") $ writeFile' "Model.hs" $(codegen "Model_hs") - writeFile' "Settings.hs" $ if backendS == "m" then $(codegen "mini-Settings_hs") else $(codegen "Settings_hs") - writeFile' "StaticFiles.hs" $(codegen "StaticFiles_hs") + writeFile' "config/Settings.hs" $ if backendS == "m" then $(codegen "mini-Settings_hs") else $(codegen "Settings_hs") + writeFile' "config/StaticFiles.hs" $(codegen "StaticFiles_hs") writeFile' "cassius/default-layout.cassius" $(codegen "default-layout_cassius") writeFile' "hamlet/default-layout.hamlet" $(codegen "default-layout_hamlet") writeFile' "hamlet/homepage.hamlet" $ if backendS == "m" then $(codegen "mini-homepage_hamlet") else $(codegen "homepage_hamlet") - writeFile' "routes" $ if backendS == "m" then $(codegen "mini-routes") else $(codegen "routes") + writeFile' "config/routes" $ if backendS == "m" then $(codegen "mini-routes") else $(codegen "routes") writeFile' "cassius/homepage.cassius" $(codegen "homepage_cassius") writeFile' "julius/homepage.julius" $(codegen "homepage_julius") - unless (backendS == "m") $ writeFile' "entities" $(codegen "entities") + unless (backendS == "m") $ writeFile' "config/models" $(codegen "entities") - S.writeFile (dir ++ "/favicon.ico") + S.writeFile (dir ++ "/config/favicon.ico") $(runIO (S.readFile "scaffold/favicon_ico.cg") >>= \bs -> do pack <- [|S.pack|] return $ pack `AppE` LitE (StringL $ S.unpack bs)) diff --git a/scaffold/Controller_hs.cg b/scaffold/Controller_hs.cg index 726a2309..324816ee 100644 --- a/scaffold/Controller_hs.cg +++ b/scaffold/Controller_hs.cg @@ -26,7 +26,7 @@ mkYesodDispatch "~sitearg~" resources~sitearg~ -- Some default handlers that ship with the Yesod site template. You will -- very rarely need to modify this. getFaviconR :: Handler () -getFaviconR = sendFile "image/x-icon" "favicon.ico" +getFaviconR = sendFile "image/x-icon" "config/favicon.ico" getRobotsR :: Handler RepPlain getRobotsR = return $ RepPlain $ toContent ("User-agent: *" :: ByteString) diff --git a/scaffold/Model_hs.cg b/scaffold/Model_hs.cg index eec15f98..ba2130ac 100644 --- a/scaffold/Model_hs.cg +++ b/scaffold/Model_hs.cg @@ -8,5 +8,5 @@ import Data.Text (Text) -- You can find more information on persistent and how to declare entities -- at: -- http://www.yesodweb.com/book/persistent/ -share [mkPersist, mkMigrate "migrateAll"] $(persistFile "entities") +share [mkPersist, mkMigrate "migrateAll"] $(persistFile "config/models") diff --git a/scaffold/Settings_hs.cg b/scaffold/Settings_hs.cg index 28604294..04845033 100644 --- a/scaffold/Settings_hs.cg +++ b/scaffold/Settings_hs.cg @@ -10,6 +10,7 @@ module Settings ( hamletFile , cassiusFile , juliusFile + , luciusFile , widgetFile , connStr , ConnectionPool @@ -23,9 +24,10 @@ module Settings import qualified Text.Hamlet as H import qualified Text.Cassius as H import qualified Text.Julius as H +import qualified Text.Lucius as H import Language.Haskell.TH.Syntax ~importDB~ -import Yesod (MonadControlIO, addWidget, addCassius, addJulius) +import Yesod (MonadControlIO, addWidget, addCassius, addJulius, addLucius) import Data.Monoid (mempty, mappend) import System.Directory (doesFileExist) import Data.Text (Text) @@ -104,10 +106,11 @@ connectionCount = 10 -- used; to get the same auto-loading effect, it is recommended that you -- use the devel server. -toHamletFile, toCassiusFile, toJuliusFile :: String -> FilePath +toHamletFile, toCassiusFile, toJuliusFile, toLuciusFile :: String -> FilePath toHamletFile x = "hamlet/" ++ x ++ ".hamlet" toCassiusFile x = "cassius/" ++ x ++ ".cassius" toJuliusFile x = "julius/" ++ x ++ ".julius" +toLuciusFile x = "lucius/" ++ x ++ ".lucius" hamletFile :: FilePath -> Q Exp hamletFile = H.hamletFile . toHamletFile @@ -119,6 +122,13 @@ cassiusFile = H.cassiusFile . toCassiusFile cassiusFile = H.cassiusFileDebug . toCassiusFile #endif +luciusFile :: FilePath -> Q Exp +#ifdef PRODUCTION +luciusFile = H.luciusFile . toLuciusFile +#else +luciusFile = H.luciusFileDebug . toLuciusFile +#endif + juliusFile :: FilePath -> Q Exp #ifdef PRODUCTION juliusFile = H.juliusFile . toJuliusFile @@ -131,7 +141,8 @@ widgetFile x = do let h = unlessExists toHamletFile hamletFile let c = unlessExists toCassiusFile cassiusFile let j = unlessExists toJuliusFile juliusFile - [|addWidget $h >> addCassius $c >> addJulius $j|] + let l = unlessExists toLuciusFile luciusFile + [|addWidget $h >> addCassius $c >> addJulius $j >> addLucius $l|] where unlessExists tofn f = do e <- qRunIO $ doesFileExist $ tofn x diff --git a/scaffold/cabal.cg b/scaffold/cabal.cg index 83474931..16ad2f80 100644 --- a/scaffold/cabal.cg +++ b/scaffold/cabal.cg @@ -26,6 +26,7 @@ library else Buildable: False exposed-modules: Controller + hs-source-dirs: ., config other-modules: ~sitearg~ Model Settings @@ -42,7 +43,8 @@ executable ~project~ else ghc-options: -Wall -threaded - main-is: ~project~.hs + main-is: config/~project~.hs + hs-source-dirs: ., config build-depends: base >= 4 && < 5 , yesod >= 0.8 && < 0.9 diff --git a/scaffold/mini-Controller_hs.cg b/scaffold/mini-Controller_hs.cg index b207c5dc..36999c82 100644 --- a/scaffold/mini-Controller_hs.cg +++ b/scaffold/mini-Controller_hs.cg @@ -25,7 +25,7 @@ mkYesodDispatch "~sitearg~" resources~sitearg~ -- Some default handlers that ship with the Yesod site template. You will -- very rarely need to modify this. getFaviconR :: Handler () -getFaviconR = sendFile "image/x-icon" "favicon.ico" +getFaviconR = sendFile "image/x-icon" "config/favicon.ico" getRobotsR :: Handler RepPlain getRobotsR = return $ RepPlain $ toContent ("User-agent: *" :: ByteString) diff --git a/scaffold/mini-Settings_hs.cg b/scaffold/mini-Settings_hs.cg index b3909933..b48fe2e5 100644 --- a/scaffold/mini-Settings_hs.cg +++ b/scaffold/mini-Settings_hs.cg @@ -10,6 +10,7 @@ module Settings ( hamletFile , cassiusFile , juliusFile + , luciusFile , widgetFile , approot , staticroot @@ -19,8 +20,9 @@ module Settings import qualified Text.Hamlet as H import qualified Text.Cassius as H import qualified Text.Julius as H +import qualified Text.Lucius as H import Language.Haskell.TH.Syntax -import Yesod.Widget (addWidget, addCassius, addJulius) +import Yesod.Widget (addWidget, addCassius, addJulius, addLucius) import Data.Monoid (mempty, mappend) import System.Directory (doesFileExist) import Data.Text (Text) @@ -76,10 +78,11 @@ staticroot = approot `mappend` "/static" -- used; to get the same auto-loading effect, it is recommended that you -- use the devel server. -toHamletFile, toCassiusFile, toJuliusFile :: String -> FilePath +toHamletFile, toCassiusFile, toJuliusFile, toLuciusFile :: String -> FilePath toHamletFile x = "hamlet/" ++ x ++ ".hamlet" toCassiusFile x = "cassius/" ++ x ++ ".cassius" toJuliusFile x = "julius/" ++ x ++ ".julius" +toLuciusFile x = "lucius/" ++ x ++ ".lucius" hamletFile :: FilePath -> Q Exp hamletFile = H.hamletFile . toHamletFile @@ -91,6 +94,13 @@ cassiusFile = H.cassiusFile . toCassiusFile cassiusFile = H.cassiusFileDebug . toCassiusFile #endif +luciusFile :: FilePath -> Q Exp +#ifdef PRODUCTION +luciusFile = H.luciusFile . toLuciusFile +#else +luciusFile = H.luciusFileDebug . toLuciusFile +#endif + juliusFile :: FilePath -> Q Exp #ifdef PRODUCTION juliusFile = H.juliusFile . toJuliusFile @@ -103,7 +113,8 @@ widgetFile x = do let h = unlessExists toHamletFile hamletFile let c = unlessExists toCassiusFile cassiusFile let j = unlessExists toJuliusFile juliusFile - [|addWidget $h >> addCassius $c >> addJulius $j|] + let l = unlessExists toLuciusFile luciusFile + [|addWidget $h >> addCassius $c >> addJulius $j >> addLucius $l|] where unlessExists tofn f = do e <- qRunIO $ doesFileExist $ tofn x diff --git a/scaffold/mini-cabal.cg b/scaffold/mini-cabal.cg index 7e48ea42..485b71be 100644 --- a/scaffold/mini-cabal.cg +++ b/scaffold/mini-cabal.cg @@ -26,6 +26,7 @@ library else Buildable: False exposed-modules: Controller + hs-source-dirs: ., config other-modules: ~sitearg~ Settings StaticFiles @@ -41,7 +42,8 @@ executable ~project~ else ghc-options: -Wall -threaded - main-is: ~project~.hs + main-is: config/~project~.hs + hs-source-dirs: ., config build-depends: base >= 4 && < 5 , yesod-core >= 0.8 && < 0.9 diff --git a/scaffold/mini-sitearg_hs.cg b/scaffold/mini-sitearg_hs.cg index d71aec4d..e8995f54 100644 --- a/scaffold/mini-sitearg_hs.cg +++ b/scaffold/mini-sitearg_hs.cg @@ -60,7 +60,7 @@ type Widget = GWidget ~sitearg~ ~sitearg~ -- for our application to be in scope. However, the handler functions -- usually require access to the ~sitearg~Route datatype. Therefore, we -- split these actions into two functions and place them in separate files. -mkYesodData "~sitearg~" $(parseRoutesFile "routes") +mkYesodData "~sitearg~" $(parseRoutesFile "config/routes") -- Please see the documentation for the Yesod typeclass. There are a number -- of settings which can be configured by overriding methods here. diff --git a/scaffold/sitearg_hs.cg b/scaffold/sitearg_hs.cg index d632a659..a2329abe 100644 --- a/scaffold/sitearg_hs.cg +++ b/scaffold/sitearg_hs.cg @@ -71,7 +71,7 @@ type Widget = GWidget ~sitearg~ ~sitearg~ -- for our application to be in scope. However, the handler functions -- usually require access to the ~sitearg~Route datatype. Therefore, we -- split these actions into two functions and place them in separate files. -mkYesodData "~sitearg~" $(parseRoutesFile "routes") +mkYesodData "~sitearg~" $(parseRoutesFile "config/routes") -- Please see the documentation for the Yesod typeclass. There are a number -- of settings which can be configured by overriding methods here.