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.ByteString.Lazy as L
|
||||||
import qualified Data.Text.Lazy as LT
|
import qualified Data.Text.Lazy as LT
|
||||||
import qualified Data.Text.Lazy.Encoding as LT
|
import qualified Data.Text.Lazy.Encoding as LT
|
||||||
import Control.Monad (when)
|
import Control.Monad (when, unless)
|
||||||
|
|
||||||
qq :: String
|
qq :: String
|
||||||
#if GHC7
|
#if GHC7
|
||||||
@ -99,8 +99,10 @@ main = do
|
|||||||
writeFile' "hamlet/default-layout.hamlet"
|
writeFile' "hamlet/default-layout.hamlet"
|
||||||
$(codegen "default-layout_hamlet")
|
$(codegen "default-layout_hamlet")
|
||||||
writeFile' "hamlet/homepage.hamlet" $ if backendS == "m" then $(codegen "mini-homepage_hamlet") else $(codegen "homepage_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' "cassius/homepage.cassius" $(codegen "homepage_cassius")
|
||||||
writeFile' "julius/homepage.julius" $(codegen "homepage_julius")
|
writeFile' "julius/homepage.julius" $(codegen "homepage_julius")
|
||||||
|
unless (backendS == "m") $ writeFile' "entities" $(codegen "entities")
|
||||||
|
|
||||||
S.writeFile (dir ++ "/favicon.ico")
|
S.writeFile (dir ++ "/favicon.ico")
|
||||||
$(runIO (S.readFile "scaffold/favicon_ico.cg") >>= \bs -> do
|
$(runIO (S.readFile "scaffold/favicon_ico.cg") >>= \bs -> do
|
||||||
|
|||||||
@ -5,18 +5,9 @@ import Yesod
|
|||||||
import Database.Persist.TH (share, mkMigrate)
|
import Database.Persist.TH (share, mkMigrate)
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
|
|
||||||
-- You can define all of your database entities here. You can find more
|
-- You can define all of your database entities in the entities file.
|
||||||
-- information on persistent and how to declare entities at:
|
-- You can find more information on persistent and how to declare entities
|
||||||
|
-- at:
|
||||||
-- http://www.yesodweb.com/book/persistent/
|
-- http://www.yesodweb.com/book/persistent/
|
||||||
share [mkPersist, mkMigrate "migrateAll"] [~qq~persist|
|
share [mkPersist, mkMigrate "migrateAll"] $(persistFile "entities")
|
||||||
User
|
|
||||||
ident Text
|
|
||||||
password Text Maybe Update
|
|
||||||
UniqueUser ident
|
|
||||||
Email
|
|
||||||
email Text
|
|
||||||
user UserId Maybe Update
|
|
||||||
verkey Text Maybe Update
|
|
||||||
UniqueEmail email
|
|
||||||
|]
|
|
||||||
|
|
||||||
|
|||||||
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~
|
, resources~sitearg~
|
||||||
, Handler
|
, Handler
|
||||||
, Widget
|
, Widget
|
||||||
, module Yesod.Handler
|
|
||||||
, module Yesod.Widget
|
|
||||||
, module Yesod.Dispatch
|
|
||||||
, module Yesod.Core
|
, module Yesod.Core
|
||||||
, module Yesod.Content
|
|
||||||
, module Settings
|
, module Settings
|
||||||
, StaticRoute (..)
|
, StaticRoute (..)
|
||||||
, lift
|
, lift
|
||||||
@ -65,14 +61,7 @@ type Widget = GWidget ~sitearg~ ~sitearg~
|
|||||||
-- for our application to be in scope. However, the handler functions
|
-- for our application to be in scope. However, the handler functions
|
||||||
-- usually require access to the ~sitearg~Route datatype. Therefore, we
|
-- usually require access to the ~sitearg~Route datatype. Therefore, we
|
||||||
-- split these actions into two functions and place them in separate files.
|
-- split these actions into two functions and place them in separate files.
|
||||||
mkYesodData "~sitearg~" [parseRoutes|
|
mkYesodData "~sitearg~" $(parseRoutesFile "routes")
|
||||||
/static StaticR Static getStatic
|
|
||||||
|
|
||||||
/favicon.ico FaviconR GET
|
|
||||||
/robots.txt RobotsR GET
|
|
||||||
|
|
||||||
/ RootR GET
|
|
||||||
|]
|
|
||||||
|
|
||||||
-- Please see the documentation for the Yesod typeclass. There are a number
|
-- Please see the documentation for the Yesod typeclass. There are a number
|
||||||
-- of settings which can be configured by overriding methods here.
|
-- 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
|
-- for our application to be in scope. However, the handler functions
|
||||||
-- usually require access to the ~sitearg~Route datatype. Therefore, we
|
-- usually require access to the ~sitearg~Route datatype. Therefore, we
|
||||||
-- split these actions into two functions and place them in separate files.
|
-- split these actions into two functions and place them in separate files.
|
||||||
mkYesodData "~sitearg~" [~qq~parseRoutes|
|
mkYesodData "~sitearg~" $(parseRoutesFile "routes")
|
||||||
/static StaticR Static getStatic
|
|
||||||
/auth AuthR Auth getAuth
|
|
||||||
|
|
||||||
/favicon.ico FaviconR GET
|
|
||||||
/robots.txt RobotsR GET
|
|
||||||
|
|
||||||
/ RootR GET
|
|
||||||
|]
|
|
||||||
|
|
||||||
-- Please see the documentation for the Yesod typeclass. There are a number
|
-- Please see the documentation for the Yesod typeclass. There are a number
|
||||||
-- of settings which can be configured by overriding methods here.
|
-- of settings which can be configured by overriding methods here.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user