diff --git a/scaffold.hs b/scaffold.hs index a91d1f46..b411231c 100644 --- a/scaffold.hs +++ b/scaffold.hs @@ -10,7 +10,7 @@ import Control.Applicative ((<$>)) import qualified Data.ByteString.Lazy as L import qualified Data.Text.Lazy as LT import qualified Data.Text.Lazy.Encoding as LT -import Control.Monad (when) +import Control.Monad (when, unless) qq :: String #if GHC7 @@ -99,8 +99,10 @@ main = do 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' "cassius/homepage.cassius" $(codegen "homepage_cassius") writeFile' "julius/homepage.julius" $(codegen "homepage_julius") + unless (backendS == "m") $ writeFile' "entities" $(codegen "entities") S.writeFile (dir ++ "/favicon.ico") $(runIO (S.readFile "scaffold/favicon_ico.cg") >>= \bs -> do diff --git a/scaffold/Model_hs.cg b/scaffold/Model_hs.cg index 97fbb96a..79fad3e9 100644 --- a/scaffold/Model_hs.cg +++ b/scaffold/Model_hs.cg @@ -5,18 +5,9 @@ import Yesod import Database.Persist.TH (share, mkMigrate) import Data.Text (Text) --- You can define all of your database entities here. You can find more --- information on persistent and how to declare entities at: +-- You can define all of your database entities in the entities file. +-- You can find more information on persistent and how to declare entities +-- at: -- http://www.yesodweb.com/book/persistent/ -share [mkPersist, mkMigrate "migrateAll"] [~qq~persist| -User - ident Text - password Text Maybe Update - UniqueUser ident -Email - email Text - user UserId Maybe Update - verkey Text Maybe Update - UniqueEmail email -|] +share [mkPersist, mkMigrate "migrateAll"] $(persistFile "entities") diff --git a/scaffold/entities.cg b/scaffold/entities.cg new file mode 100644 index 00000000..0fafb17a --- /dev/null +++ b/scaffold/entities.cg @@ -0,0 +1,10 @@ +User + ident Text + password Text Maybe Update + UniqueUser ident +Email + email Text + user UserId Maybe Update + verkey Text Maybe Update + UniqueEmail email + diff --git a/scaffold/mini-routes.cg b/scaffold/mini-routes.cg new file mode 100644 index 00000000..f8eb4921 --- /dev/null +++ b/scaffold/mini-routes.cg @@ -0,0 +1,7 @@ +/static StaticR Static getStatic + +/favicon.ico FaviconR GET +/robots.txt RobotsR GET + +/ RootR GET + diff --git a/scaffold/mini-sitearg_hs.cg b/scaffold/mini-sitearg_hs.cg index 81984903..b2e68221 100644 --- a/scaffold/mini-sitearg_hs.cg +++ b/scaffold/mini-sitearg_hs.cg @@ -6,11 +6,7 @@ module ~sitearg~ , resources~sitearg~ , Handler , Widget - , module Yesod.Handler - , module Yesod.Widget - , module Yesod.Dispatch , module Yesod.Core - , module Yesod.Content , module Settings , StaticRoute (..) , lift @@ -65,14 +61,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~" [parseRoutes| -/static StaticR Static getStatic - -/favicon.ico FaviconR GET -/robots.txt RobotsR GET - -/ RootR GET -|] +mkYesodData "~sitearg~" $(parseRoutesFile "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/routes.cg b/scaffold/routes.cg new file mode 100644 index 00000000..88b05c1c --- /dev/null +++ b/scaffold/routes.cg @@ -0,0 +1,8 @@ +/static StaticR Static getStatic +/auth AuthR Auth getAuth + +/favicon.ico FaviconR GET +/robots.txt RobotsR GET + +/ RootR GET + diff --git a/scaffold/sitearg_hs.cg b/scaffold/sitearg_hs.cg index 13c18945..8ab1ac81 100644 --- a/scaffold/sitearg_hs.cg +++ b/scaffold/sitearg_hs.cg @@ -72,15 +72,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~" [~qq~parseRoutes| -/static StaticR Static getStatic -/auth AuthR Auth getAuth - -/favicon.ico FaviconR GET -/robots.txt RobotsR GET - -/ RootR GET -|] +mkYesodData "~sitearg~" $(parseRoutesFile "routes") -- Please see the documentation for the Yesod typeclass. There are a number -- of settings which can be configured by overriding methods here.