Scaffolded site puts routes/entities in separate files
This commit is contained in:
parent
9b36dc2bf6
commit
b236e1f913
@ -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
|
||||
|
||||
@ -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")
|
||||
|
||||
|
||||
10
scaffold/entities.cg
Normal file
10
scaffold/entities.cg
Normal file
@ -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
|
||||
|
||||
7
scaffold/mini-routes.cg
Normal file
7
scaffold/mini-routes.cg
Normal file
@ -0,0 +1,7 @@
|
||||
/static StaticR Static getStatic
|
||||
|
||||
/favicon.ico FaviconR GET
|
||||
/robots.txt RobotsR GET
|
||||
|
||||
/ RootR GET
|
||||
|
||||
@ -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.
|
||||
|
||||
8
scaffold/routes.cg
Normal file
8
scaffold/routes.cg
Normal file
@ -0,0 +1,8 @@
|
||||
/static StaticR Static getStatic
|
||||
/auth AuthR Auth getAuth
|
||||
|
||||
/favicon.ico FaviconR GET
|
||||
/robots.txt RobotsR GET
|
||||
|
||||
/ RootR GET
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user