Fixed scaffolding; removed tiny; added bootstrap.css
This commit is contained in:
parent
95cbf51b95
commit
6e17c1ae17
@ -26,7 +26,7 @@ prompt f = do
|
|||||||
hFlush stdout
|
hFlush stdout
|
||||||
prompt f
|
prompt f
|
||||||
|
|
||||||
data Backend = Sqlite | Postgresql | Mysql | MongoDB | Tiny
|
data Backend = Sqlite | Postgresql | Mysql | MongoDB
|
||||||
deriving (Eq, Read, Show, Enum, Bounded)
|
deriving (Eq, Read, Show, Enum, Bounded)
|
||||||
|
|
||||||
puts :: String -> IO ()
|
puts :: String -> IO ()
|
||||||
@ -64,14 +64,12 @@ scaffold = do
|
|||||||
"p" -> (Postgresql, "GenericSql", "SqlPersist", "Postgresql", "sqlSettings")
|
"p" -> (Postgresql, "GenericSql", "SqlPersist", "Postgresql", "sqlSettings")
|
||||||
"mysql" -> (Mysql, "GenericSql", "SqlPersist", "MySQL", "sqlSettings")
|
"mysql" -> (Mysql, "GenericSql", "SqlPersist", "MySQL", "sqlSettings")
|
||||||
"mongo" -> (MongoDB, "MongoDB", "Action", "MongoDB", "MkPersistSettings { mpsBackend = ConT ''Action }")
|
"mongo" -> (MongoDB, "MongoDB", "Action", "MongoDB", "MkPersistSettings { mpsBackend = ConT ''Action }")
|
||||||
"t" -> (Tiny, "","","",undefined)
|
|
||||||
_ -> error $ "Invalid backend: " ++ backendC
|
_ -> error $ "Invalid backend: " ++ backendC
|
||||||
(modelImports) = case backend of
|
(modelImports) = case backend of
|
||||||
MongoDB -> "import Database.Persist." ++ importGenericDB ++ "\nimport Language.Haskell.TH.Syntax"
|
MongoDB -> "import Database.Persist." ++ importGenericDB ++ "\nimport Language.Haskell.TH.Syntax"
|
||||||
Sqlite -> ""
|
Sqlite -> ""
|
||||||
Postgresql -> ""
|
Postgresql -> ""
|
||||||
Mysql -> ""
|
Mysql -> ""
|
||||||
Tiny -> undefined
|
|
||||||
|
|
||||||
uncapitalize s = toLower (head s) : tail s
|
uncapitalize s = toLower (head s) : tail s
|
||||||
backendLower = uncapitalize $ show backend
|
backendLower = uncapitalize $ show backend
|
||||||
@ -96,7 +94,6 @@ scaffold = do
|
|||||||
Sqlite -> "sqlite"
|
Sqlite -> "sqlite"
|
||||||
Postgresql -> "postgresql"
|
Postgresql -> "postgresql"
|
||||||
Mysql -> "mysql"
|
Mysql -> "mysql"
|
||||||
Tiny -> error "Accessing dbConfigFile for Tiny"
|
|
||||||
|
|
||||||
let configPersist =
|
let configPersist =
|
||||||
case backend of
|
case backend of
|
||||||
@ -104,7 +101,6 @@ scaffold = do
|
|||||||
Sqlite -> "SqliteConf"
|
Sqlite -> "SqliteConf"
|
||||||
Postgresql -> "PostgresConf"
|
Postgresql -> "PostgresConf"
|
||||||
Mysql -> "MySQLConf"
|
Mysql -> "MySQLConf"
|
||||||
Tiny -> error "Accessing configPersist for Tiny"
|
|
||||||
|
|
||||||
putStrLn "That's it! I'm creating your files now..."
|
putStrLn "That's it! I'm creating your files now..."
|
||||||
|
|
||||||
@ -113,7 +109,6 @@ scaffold = do
|
|||||||
Postgresql -> $(codegen "postgresqlConnPool")
|
Postgresql -> $(codegen "postgresqlConnPool")
|
||||||
Mysql -> ""
|
Mysql -> ""
|
||||||
MongoDB -> $(codegen "mongoDBConnPool")
|
MongoDB -> $(codegen "mongoDBConnPool")
|
||||||
Tiny -> ""
|
|
||||||
|
|
||||||
packages =
|
packages =
|
||||||
if backend == MongoDB
|
if backend == MongoDB
|
||||||
@ -151,29 +146,25 @@ scaffold = do
|
|||||||
Postgresql -> writeFile' ("config/" ++ backendLower ++ ".yml") $(codegen "config/postgresql.yml")
|
Postgresql -> writeFile' ("config/" ++ backendLower ++ ".yml") $(codegen "config/postgresql.yml")
|
||||||
MongoDB -> writeFile' ("config/" ++ backendLower ++ ".yml") $(codegen "config/mongoDB.yml")
|
MongoDB -> writeFile' ("config/" ++ backendLower ++ ".yml") $(codegen "config/mongoDB.yml")
|
||||||
Mysql -> writeFile' ("config/" ++ backendLower ++ ".yml") $(codegen "config/mysql.yml")
|
Mysql -> writeFile' ("config/" ++ backendLower ++ ".yml") $(codegen "config/mysql.yml")
|
||||||
Tiny -> return ()
|
|
||||||
|
|
||||||
let isTiny = backend == Tiny
|
|
||||||
ifTiny a b = if isTiny then a else b
|
|
||||||
|
|
||||||
writeFile' "config/settings.yml" $(codegen "config/settings.yml")
|
writeFile' "config/settings.yml" $(codegen "config/settings.yml")
|
||||||
writeFile' "main.hs" $(codegen "main.hs")
|
writeFile' "main.hs" $(codegen "main.hs")
|
||||||
writeFile' "devel.hs" $(codegen "devel.hs")
|
writeFile' "devel.hs" $(codegen "devel.hs")
|
||||||
writeFile' (project ++ ".cabal") $ ifTiny $(codegen "tiny/project.cabal") $(codegen "project.cabal")
|
writeFile' (project ++ ".cabal") $(codegen "project.cabal")
|
||||||
when useTests $
|
when useTests $
|
||||||
appendFile' (project ++ ".cabal") $(codegen "cabal_test_suite")
|
appendFile' (project ++ ".cabal") $(codegen "cabal_test_suite")
|
||||||
|
|
||||||
writeFile' ".ghci" $(codegen ".ghci")
|
writeFile' ".ghci" $(codegen ".ghci")
|
||||||
writeFile' "LICENSE" $(codegen "LICENSE")
|
writeFile' "LICENSE" $(codegen "LICENSE")
|
||||||
writeFile' "Foundation.hs" $ ifTiny $(codegen "tiny/Foundation.hs") $(codegen "Foundation.hs")
|
writeFile' "Foundation.hs" $(codegen "Foundation.hs")
|
||||||
writeFile' "Import.hs" $ ifTiny $(codegen "tiny/Import.hs") $(codegen "Import.hs")
|
writeFile' "Import.hs" $(codegen "Import.hs")
|
||||||
writeFile' "Application.hs" $ ifTiny $(codegen "tiny/Application.hs") $(codegen "Application.hs")
|
writeFile' "Application.hs" $(codegen "Application.hs")
|
||||||
writeFile' "Handler/Home.hs" $(codegen "Handler/Home.hs")
|
writeFile' "Handler/Home.hs" $(codegen "Handler/Home.hs")
|
||||||
unless isTiny $ writeFile' "Model.hs" $(codegen "Model.hs")
|
writeFile' "Model.hs" $(codegen "Model.hs")
|
||||||
writeFile' "Settings.hs" $ ifTiny $(codegen "tiny/Settings.hs") $(codegen "Settings.hs")
|
writeFile' "Settings.hs" $(codegen "Settings.hs")
|
||||||
writeFile' "Settings/StaticFiles.hs" $(codegen "Settings/StaticFiles.hs")
|
writeFile' "Settings/StaticFiles.hs" $(codegen "Settings/StaticFiles.hs")
|
||||||
writeFile' "templates/default-layout.lucius"
|
writeFile' "static/css/bootstrap.css"
|
||||||
$(codegen "templates/default-layout.lucius")
|
$(codegen "static/css/bootstrap.css")
|
||||||
writeFile' "templates/default-layout.hamlet"
|
writeFile' "templates/default-layout.hamlet"
|
||||||
$(codegen "templates/default-layout.hamlet")
|
$(codegen "templates/default-layout.hamlet")
|
||||||
writeFile' "templates/default-layout-wrapper.hamlet"
|
writeFile' "templates/default-layout-wrapper.hamlet"
|
||||||
@ -182,12 +173,12 @@ scaffold = do
|
|||||||
$(codegen "templates/normalize.lucius")
|
$(codegen "templates/normalize.lucius")
|
||||||
writeFile' "templates/homepage.hamlet"
|
writeFile' "templates/homepage.hamlet"
|
||||||
$(codegen "templates/homepage.hamlet")
|
$(codegen "templates/homepage.hamlet")
|
||||||
writeFile' "config/routes" $ ifTiny $(codegen "tiny/config/routes") $(codegen "config/routes")
|
writeFile' "config/routes" $(codegen "config/routes")
|
||||||
writeFile' "templates/homepage.lucius"
|
writeFile' "templates/homepage.lucius"
|
||||||
$(codegen "templates/homepage.lucius")
|
$(codegen "templates/homepage.lucius")
|
||||||
writeFile' "templates/homepage.julius"
|
writeFile' "templates/homepage.julius"
|
||||||
$(codegen "templates/homepage.julius")
|
$(codegen "templates/homepage.julius")
|
||||||
unless isTiny $ writeFile' "config/models" $(codegen "config/models")
|
writeFile' "config/models" $(codegen "config/models")
|
||||||
writeFile' "messages/en.msg" $(codegen "messages/en.msg")
|
writeFile' "messages/en.msg" $(codegen "messages/en.msg")
|
||||||
|
|
||||||
when useTests $ do
|
when useTests $ do
|
||||||
|
|||||||
@ -2,13 +2,9 @@ Yesod uses Persistent for its (you guessed it) persistence layer.
|
|||||||
This tool will build in either SQLite or PostgreSQL or MongoDB support for you.
|
This tool will build in either SQLite or PostgreSQL or MongoDB support for you.
|
||||||
We recommend starting with SQLite: it has no dependencies.
|
We recommend starting with SQLite: it has no dependencies.
|
||||||
|
|
||||||
We have another option: a tiny project with minimal dependencies.
|
|
||||||
Mostly this means no database and no authentication.
|
|
||||||
|
|
||||||
s = sqlite
|
s = sqlite
|
||||||
p = postgresql
|
p = postgresql
|
||||||
mongo = mongodb
|
mongo = mongodb
|
||||||
t = tiny
|
|
||||||
mysql = MySQL (experimental)
|
mysql = MySQL (experimental)
|
||||||
|
|
||||||
So, what'll it be?
|
So, what'll it be?
|
||||||
|
|||||||
@ -47,7 +47,7 @@ makeApplication conf logger = do
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
makeFoundation :: AppConfig DefaultEnv Extra -> Logger -> IO ~sitearg~
|
makeFoundation :: AppConfig DefaultEnv Extra -> Logger -> IO ~sitearg~
|
||||||
makeFoundation conf _ = do
|
makeFoundation conf setLogger = do
|
||||||
manager <- newManager def
|
manager <- newManager def
|
||||||
s <- staticSite
|
s <- staticSite
|
||||||
dbconf <- withYamlEnvironment "config/~dbConfigFile~.yml" (appEnv conf)
|
dbconf <- withYamlEnvironment "config/~dbConfigFile~.yml" (appEnv conf)
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import Yesod.Logger (Logger, logMsg, formatLogText)
|
|||||||
import Network.HTTP.Conduit (Manager)
|
import Network.HTTP.Conduit (Manager)
|
||||||
import qualified Settings
|
import qualified Settings
|
||||||
import qualified Database.Persist.Store
|
import qualified Database.Persist.Store
|
||||||
|
import Settings.StaticFiles
|
||||||
import Database.Persist.~importGenericDB~
|
import Database.Persist.~importGenericDB~
|
||||||
import Settings (widgetFile, Extra (..))
|
import Settings (widgetFile, Extra (..))
|
||||||
import Model
|
import Model
|
||||||
@ -93,6 +94,7 @@ instance Yesod ~sitearg~ where
|
|||||||
|
|
||||||
pc <- widgetToPageContent $ do
|
pc <- widgetToPageContent $ do
|
||||||
$(widgetFile "normalize")
|
$(widgetFile "normalize")
|
||||||
|
addStylesheet $ StaticR css_bootstrap_css
|
||||||
$(widgetFile "default-layout")
|
$(widgetFile "default-layout")
|
||||||
hamletToRepHtml $(hamletFile "templates/default-layout-wrapper.hamlet")
|
hamletToRepHtml $(hamletFile "templates/default-layout-wrapper.hamlet")
|
||||||
|
|
||||||
|
|||||||
3990
yesod/scaffold/static/css/bootstrap.css.cg
Normal file
3990
yesod/scaffold/static/css/bootstrap.css.cg
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,53 +0,0 @@
|
|||||||
body {
|
|
||||||
font-family: helvetica;
|
|
||||||
font-size: 18px;
|
|
||||||
background: #f0f0f0;
|
|
||||||
line-height: 1.9em;
|
|
||||||
}
|
|
||||||
.content {
|
|
||||||
width: 850px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
em, a , form{
|
|
||||||
font-style: normal;
|
|
||||||
padding: 0.3em;
|
|
||||||
border: 1px solid #e0e0e0;
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
form .required {
|
|
||||||
padding: 0.4em 0;
|
|
||||||
input {
|
|
||||||
margin-left: 0.5em;
|
|
||||||
}
|
|
||||||
.errors {
|
|
||||||
color: #f66;
|
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ol {
|
|
||||||
padding: 0;
|
|
||||||
li {
|
|
||||||
list-style-type: square;
|
|
||||||
margin: 0.5em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
li {
|
|
||||||
list-style-image: disc;
|
|
||||||
}
|
|
||||||
|
|
||||||
form {
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message {
|
|
||||||
border: 1px solid #ff2;
|
|
||||||
background: #ffa;
|
|
||||||
margin: 1em 0;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
footer {
|
|
||||||
text-align: center;
|
|
||||||
margin: 20px;
|
|
||||||
}
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
||||||
module Application
|
|
||||||
( makeApplication
|
|
||||||
, getApplicationDev
|
|
||||||
) where
|
|
||||||
|
|
||||||
import Import
|
|
||||||
import Settings (parseExtra)
|
|
||||||
import Settings.StaticFiles (staticSite)
|
|
||||||
import Yesod.Default.Config
|
|
||||||
import Yesod.Default.Main (defaultDevelApp)
|
|
||||||
import Yesod.Default.Handlers (getFaviconR, getRobotsR)
|
|
||||||
#if DEVELOPMENT
|
|
||||||
import Yesod.Logger (Logger, logBS)
|
|
||||||
import Network.Wai.Middleware.RequestLogger (logCallbackDev)
|
|
||||||
#else
|
|
||||||
import Yesod.Logger (Logger, logBS, toProduction)
|
|
||||||
import Network.Wai.Middleware.RequestLogger (logCallback)
|
|
||||||
#endif
|
|
||||||
import Network.Wai (Application)
|
|
||||||
|
|
||||||
-- Import all relevant handler modules here.
|
|
||||||
import Handler.Home
|
|
||||||
|
|
||||||
-- This line actually creates our YesodSite instance. It is the second half
|
|
||||||
-- of the call to mkYesodData which occurs in Foundation.hs. Please see
|
|
||||||
-- the comments there for more details.
|
|
||||||
mkYesodDispatch "~sitearg~" resources~sitearg~
|
|
||||||
|
|
||||||
makeFoundation :: AppConfig DefaultEnv Extra -> Logger -> IO ~sitearg~
|
|
||||||
makeFoundation conf _ = do
|
|
||||||
s <- staticSite
|
|
||||||
return $ ~sitearg~ conf setLogger s
|
|
||||||
|
|
||||||
-- This function allocates resources (such as a database connection pool),
|
|
||||||
-- performs initialization and creates a WAI application. This is also the
|
|
||||||
-- place to put your migrate statements to have automatic database
|
|
||||||
-- migrations handled by Yesod.
|
|
||||||
makeApplication :: AppConfig DefaultEnv Extra -> Logger -> IO Application
|
|
||||||
makeApplication conf logger = do
|
|
||||||
foundation <- makeFoundation
|
|
||||||
app <- toWaiAppPlain foundation
|
|
||||||
return $ logWare app
|
|
||||||
where
|
|
||||||
#ifdef DEVELOPMENT
|
|
||||||
logWare = logCallbackDev (logBS setLogger)
|
|
||||||
setLogger = logger
|
|
||||||
#else
|
|
||||||
setLogger = toProduction logger -- by default the logger is set for development
|
|
||||||
logWare = logCallback (logBS setLogger)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
-- for yesod devel
|
|
||||||
getApplicationDev :: IO (Int, Application)
|
|
||||||
getApplicationDev =
|
|
||||||
defaultDevelApp loader makeApplication
|
|
||||||
where
|
|
||||||
loader = loadConfig (configSettings Development)
|
|
||||||
{ csParseExtra = parseExtra
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,106 +0,0 @@
|
|||||||
module Foundation
|
|
||||||
( ~sitearg~ (..)
|
|
||||||
, Route (..)
|
|
||||||
, ~sitearg~Message (..)
|
|
||||||
, resources~sitearg~
|
|
||||||
, Handler
|
|
||||||
, Widget
|
|
||||||
, Form
|
|
||||||
, module Yesod.Core
|
|
||||||
, module Settings
|
|
||||||
, liftIO
|
|
||||||
) where
|
|
||||||
|
|
||||||
import Prelude
|
|
||||||
import Yesod.Core hiding (Route)
|
|
||||||
import Yesod.Form
|
|
||||||
import Yesod.Default.Config
|
|
||||||
import Yesod.Default.Util (addStaticContentExternal)
|
|
||||||
import Yesod.Static
|
|
||||||
import Settings.StaticFiles
|
|
||||||
import Yesod.Logger (Logger, logMsg, formatLogText)
|
|
||||||
import qualified Settings
|
|
||||||
import Settings (Extra (..), widgetFile)
|
|
||||||
import Control.Monad.IO.Class (liftIO)
|
|
||||||
import Web.ClientSession (getKey)
|
|
||||||
import Text.Hamlet (hamletFile)
|
|
||||||
|
|
||||||
-- | The site argument for your application. This can be a good place to
|
|
||||||
-- keep settings and values requiring initialization before your application
|
|
||||||
-- starts running, such as database connections. Every handler will have
|
|
||||||
-- access to the data present here.
|
|
||||||
data ~sitearg~ = ~sitearg~
|
|
||||||
{ settings :: AppConfig DefaultEnv Extra
|
|
||||||
, getLogger :: Logger
|
|
||||||
, getStatic :: Static -- ^ Settings for static file serving.
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Set up i18n messages. See the message folder.
|
|
||||||
mkMessage "~sitearg~" "messages" "en"
|
|
||||||
|
|
||||||
-- This is where we define all of the routes in our application. For a full
|
|
||||||
-- explanation of the syntax, please see:
|
|
||||||
-- http://docs.yesodweb.com/book/web-routes-quasi/
|
|
||||||
--
|
|
||||||
-- This function does three things:
|
|
||||||
--
|
|
||||||
-- * Creates the route datatype ~sitearg~Route. Every valid URL in your
|
|
||||||
-- application can be represented as a value of this type.
|
|
||||||
-- * Creates the associated type:
|
|
||||||
-- type instance Route ~sitearg~ = ~sitearg~Route
|
|
||||||
-- * Creates the value resources~sitearg~ which contains information on the
|
|
||||||
-- resources declared below. This is used in Handler.hs by the call to
|
|
||||||
-- mkYesodDispatch
|
|
||||||
--
|
|
||||||
-- What this function does *not* do is create a YesodSite instance for
|
|
||||||
-- ~sitearg~. Creating that instance requires all of the handler functions
|
|
||||||
-- 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 "config/routes")
|
|
||||||
|
|
||||||
type Form x = Html -> MForm ~sitearg~ ~sitearg~ (FormResult x, Widget)
|
|
||||||
|
|
||||||
-- Please see the documentation for the Yesod typeclass. There are a number
|
|
||||||
-- of settings which can be configured by overriding methods here.
|
|
||||||
instance Yesod ~sitearg~ where
|
|
||||||
approot = ApprootMaster $ appRoot . settings
|
|
||||||
|
|
||||||
-- Store session data on the client in encrypted cookies,
|
|
||||||
-- default session idle timeout is 120 minutes
|
|
||||||
makeSessionBackend _ = do
|
|
||||||
key <- getKey "config/client_session_key.aes"
|
|
||||||
return . Just $ clientSessionBackend key 120
|
|
||||||
|
|
||||||
defaultLayout widget = do
|
|
||||||
master <- getYesod
|
|
||||||
mmsg <- getMessage
|
|
||||||
|
|
||||||
-- We break up the default layout into two components:
|
|
||||||
-- default-layout is the contents of the body tag, and
|
|
||||||
-- default-layout-wrapper is the entire page. Since the final
|
|
||||||
-- value passed to hamletToRepHtml cannot be a widget, this allows
|
|
||||||
-- you to use normal widget features in default-layout.
|
|
||||||
|
|
||||||
pc <- widgetToPageContent $ do
|
|
||||||
$(widgetFile "normalize")
|
|
||||||
$(widgetFile "default-layout")
|
|
||||||
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
|
|
||||||
urlRenderOverride y (StaticR s) =
|
|
||||||
Just $ uncurry (joinPath y (Settings.staticRoot $ settings y)) $ renderRoute s
|
|
||||||
urlRenderOverride _ _ = Nothing
|
|
||||||
|
|
||||||
messageLogger y loc level msg =
|
|
||||||
formatLogText (getLogger y) loc level msg >>= logMsg (getLogger y)
|
|
||||||
|
|
||||||
-- This function creates static content files in the static folder
|
|
||||||
-- and names them based on a hash of their content. This allows
|
|
||||||
-- expiration dates to be set far in the future without worry of
|
|
||||||
-- users receiving stale content.
|
|
||||||
addStaticContent = addStaticContentExternal (const $ Left ()) base64md5 Settings.staticDir (StaticR . flip StaticRoute [])
|
|
||||||
|
|
||||||
-- Place Javascript at bottom of the body tag so the rest of the page loads first
|
|
||||||
jsLoader _ = BottomOfBody
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
module Import
|
|
||||||
( module Prelude
|
|
||||||
, module Foundation
|
|
||||||
, (<>)
|
|
||||||
, Text
|
|
||||||
, module Data.Monoid
|
|
||||||
, module Control.Applicative
|
|
||||||
) where
|
|
||||||
|
|
||||||
import Prelude hiding (writeFile, readFile)
|
|
||||||
import Foundation
|
|
||||||
import Data.Monoid (Monoid (mappend, mempty, mconcat))
|
|
||||||
import Control.Applicative ((<$>), (<*>), pure)
|
|
||||||
import Data.Text (Text)
|
|
||||||
|
|
||||||
infixr 5 <>
|
|
||||||
(<>) :: Monoid m => m -> m -> m
|
|
||||||
(<>) = mappend
|
|
||||||
@ -1,60 +0,0 @@
|
|||||||
-- | Settings are centralized, as much as possible, into this file. This
|
|
||||||
-- includes database connection settings, static file locations, etc.
|
|
||||||
-- In addition, you can configure a number of different aspects of Yesod
|
|
||||||
-- by overriding methods in the Yesod typeclass. That instance is
|
|
||||||
-- declared in the ~project~.hs file.
|
|
||||||
module Settings
|
|
||||||
( widgetFile
|
|
||||||
, staticRoot
|
|
||||||
, staticDir
|
|
||||||
, Extra (..)
|
|
||||||
, parseExtra
|
|
||||||
) where
|
|
||||||
|
|
||||||
import Prelude
|
|
||||||
import Text.Shakespeare.Text (st)
|
|
||||||
import Language.Haskell.TH.Syntax
|
|
||||||
import Yesod.Default.Config
|
|
||||||
import qualified Yesod.Default.Util
|
|
||||||
import Data.Text (Text)
|
|
||||||
import Data.Yaml
|
|
||||||
import Control.Applicative
|
|
||||||
|
|
||||||
-- | The location of static files on your system. This is a file system
|
|
||||||
-- path. The default value works properly with your scaffolded site.
|
|
||||||
staticDir :: FilePath
|
|
||||||
staticDir = "static"
|
|
||||||
|
|
||||||
-- | The base URL for your static files. As you can see by the default
|
|
||||||
-- value, this can simply be "static" appended to your application root.
|
|
||||||
-- A powerful optimization can be serving static files from a separate
|
|
||||||
-- domain name. This allows you to use a web server optimized for static
|
|
||||||
-- files, more easily set expires and cache values, and avoid possibly
|
|
||||||
-- costly transference of cookies on static files. For more information,
|
|
||||||
-- please see:
|
|
||||||
-- http://code.google.com/speed/page-speed/docs/request.html#ServeFromCookielessDomain
|
|
||||||
--
|
|
||||||
-- If you change the resource pattern for StaticR in ~project~.hs, you will
|
|
||||||
-- have to make a corresponding change here.
|
|
||||||
--
|
|
||||||
-- To see how this value is used, see urlRenderOverride in ~project~.hs
|
|
||||||
staticRoot :: AppConfig DefaultEnv a -> Text
|
|
||||||
staticRoot conf = [st|#{appRoot conf}/static|]
|
|
||||||
|
|
||||||
widgetFile :: String -> Q Exp
|
|
||||||
#if DEVELOPMENT
|
|
||||||
widgetFile = Yesod.Default.Util.widgetFileReload
|
|
||||||
#else
|
|
||||||
widgetFile = Yesod.Default.Util.widgetFileNoReload
|
|
||||||
#endif
|
|
||||||
|
|
||||||
data Extra = Extra
|
|
||||||
{ extraCopyright :: Text
|
|
||||||
, extraAnalytics :: Maybe Text -- ^ Google Analytics
|
|
||||||
}
|
|
||||||
|
|
||||||
parseExtra :: DefaultEnv -> Object -> Parser Extra
|
|
||||||
parseExtra _ o = Extra
|
|
||||||
<$> o .: "copyright"
|
|
||||||
<*> o .:? "analytics"
|
|
||||||
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
/static StaticR Static getStatic
|
|
||||||
|
|
||||||
/favicon.ico FaviconR GET
|
|
||||||
/robots.txt RobotsR GET
|
|
||||||
|
|
||||||
/ HomeR GET
|
|
||||||
|
|
||||||
@ -1,84 +0,0 @@
|
|||||||
name: ~project~
|
|
||||||
version: 0.0.0
|
|
||||||
license: BSD3
|
|
||||||
license-file: LICENSE
|
|
||||||
author: ~name~
|
|
||||||
maintainer: ~name~
|
|
||||||
synopsis: The greatest Yesod web application ever.
|
|
||||||
description: I'm sure you can say something clever here if you try.
|
|
||||||
category: Web
|
|
||||||
stability: Experimental
|
|
||||||
cabal-version: >= 1.6
|
|
||||||
build-type: Simple
|
|
||||||
homepage: http://~project~.yesodweb.com/
|
|
||||||
|
|
||||||
Flag dev
|
|
||||||
Description: Turn on development settings, like auto-reload templates.
|
|
||||||
Default: False
|
|
||||||
|
|
||||||
Flag library-only
|
|
||||||
Description: Build for use with "yesod devel"
|
|
||||||
Default: False
|
|
||||||
|
|
||||||
library
|
|
||||||
if flag(library-only)
|
|
||||||
Buildable: True
|
|
||||||
else
|
|
||||||
Buildable: False
|
|
||||||
exposed-modules: Application
|
|
||||||
other-modules: Foundation
|
|
||||||
Import
|
|
||||||
Settings
|
|
||||||
Settings.StaticFiles
|
|
||||||
Handler.Home
|
|
||||||
|
|
||||||
ghc-options: -Wall -threaded -O0
|
|
||||||
cpp-options: -DDEVELOPMENT
|
|
||||||
|
|
||||||
extensions: TemplateHaskell
|
|
||||||
QuasiQuotes
|
|
||||||
OverloadedStrings
|
|
||||||
NoImplicitPrelude
|
|
||||||
CPP
|
|
||||||
OverloadedStrings
|
|
||||||
MultiParamTypeClasses
|
|
||||||
TypeFamilies
|
|
||||||
|
|
||||||
executable ~project~
|
|
||||||
if flag(library-only)
|
|
||||||
Buildable: False
|
|
||||||
|
|
||||||
if flag(dev)
|
|
||||||
cpp-options: -DDEVELOPMENT
|
|
||||||
ghc-options: -Wall -threaded -O0
|
|
||||||
else
|
|
||||||
ghc-options: -Wall -threaded -O2
|
|
||||||
|
|
||||||
main-is: main.hs
|
|
||||||
|
|
||||||
extensions: TemplateHaskell
|
|
||||||
QuasiQuotes
|
|
||||||
OverloadedStrings
|
|
||||||
NoImplicitPrelude
|
|
||||||
CPP
|
|
||||||
OverloadedStrings
|
|
||||||
MultiParamTypeClasses
|
|
||||||
TypeFamilies
|
|
||||||
|
|
||||||
build-depends: base >= 4 && < 5
|
|
||||||
, yesod-core >= 1.0 && < 1.1
|
|
||||||
, yesod-form >= 1.0 && < 1.1
|
|
||||||
, yesod-static >= 1.0 && < 1.1
|
|
||||||
, yesod-default >= 1.0 && < 1.1
|
|
||||||
, clientsession >= 0.7.3 && < 0.8
|
|
||||||
, bytestring >= 0.9 && < 0.10
|
|
||||||
, text >= 0.11 && < 0.12
|
|
||||||
, template-haskell
|
|
||||||
, hamlet >= 1.0 && < 1.1
|
|
||||||
, shakespeare-text >= 1.0 && < 1.1
|
|
||||||
, wai >= 1.2 && < 1.3
|
|
||||||
, wai-extra >= 1.2 && < 1.3
|
|
||||||
, transformers >= 0.2 && < 0.3
|
|
||||||
, monad-control >= 0.3 && < 0.4
|
|
||||||
, yaml >= 0.7 && < 0.8
|
|
||||||
|
|
||||||
@ -26,12 +26,6 @@ extra-source-files:
|
|||||||
scaffold/main.hs.cg
|
scaffold/main.hs.cg
|
||||||
scaffold/postgresqlConnPool.cg
|
scaffold/postgresqlConnPool.cg
|
||||||
scaffold/Foundation.hs.cg
|
scaffold/Foundation.hs.cg
|
||||||
scaffold/tiny/project.cabal.cg
|
|
||||||
scaffold/tiny/Foundation.hs.cg
|
|
||||||
scaffold/tiny/Import.hs.cg
|
|
||||||
scaffold/tiny/Settings.hs.cg
|
|
||||||
scaffold/tiny/Application.hs.cg
|
|
||||||
scaffold/tiny/config/routes.cg
|
|
||||||
scaffold/sqliteConnPool.cg
|
scaffold/sqliteConnPool.cg
|
||||||
scaffold/cabal_test_suite.cg
|
scaffold/cabal_test_suite.cg
|
||||||
scaffold/Import.hs.cg
|
scaffold/Import.hs.cg
|
||||||
@ -42,7 +36,7 @@ extra-source-files:
|
|||||||
scaffold/Application.hs.cg
|
scaffold/Application.hs.cg
|
||||||
scaffold/deploy/Procfile.cg
|
scaffold/deploy/Procfile.cg
|
||||||
scaffold/templates/homepage.hamlet.cg
|
scaffold/templates/homepage.hamlet.cg
|
||||||
scaffold/templates/default-layout.lucius.cg
|
scaffold/static/css/bootstrap.css.cg
|
||||||
scaffold/templates/default-layout.hamlet.cg
|
scaffold/templates/default-layout.hamlet.cg
|
||||||
scaffold/templates/homepage.julius.cg
|
scaffold/templates/homepage.julius.cg
|
||||||
scaffold/templates/default-layout-wrapper.hamlet.cg
|
scaffold/templates/default-layout-wrapper.hamlet.cg
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user