From 62597317839c7945bfbc4b7a00f55d2db6459ab6 Mon Sep 17 00:00:00 2001 From: Clint Adams Date: Fri, 24 Apr 2015 12:53:02 -0400 Subject: Finally put pfifcontractors into git --- Settings.hs | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Settings.hs (limited to 'Settings.hs') diff --git a/Settings.hs b/Settings.hs new file mode 100644 index 0000000..78d240f --- /dev/null +++ b/Settings.hs @@ -0,0 +1,68 @@ +-- | 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 Foundation.hs file. +module Settings + ( widgetFile + , PersistConfig + , staticRoot + , staticDir + , Extra (..) + , parseExtra + ) where + +import Prelude +import Text.Shakespeare.Text (st) +import Language.Haskell.TH.Syntax +import Database.Persist.Postgresql (PostgresConf) +import Yesod.Default.Config +import qualified Yesod.Default.Util +import Data.Text (Text) +import Data.Yaml +import Control.Applicative +import Settings.Development + +-- | Which Persistent backend this site is using. +type PersistConfig = PostgresConf + +-- Static setting below. Changing these requires a recompile + +-- | 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 Foundation.hs, you will +-- have to make a corresponding change here. +-- +-- To see how this value is used, see urlRenderOverride in Foundation.hs +staticRoot :: AppConfig DefaultEnv x -> Text +staticRoot conf = [st|#{appRoot conf}/static|] + + +-- The rest of this file contains settings which rarely need changing by a +-- user. + +widgetFile :: String -> Q Exp +widgetFile = if development then Yesod.Default.Util.widgetFileReload + else Yesod.Default.Util.widgetFileNoReload + +data Extra = Extra + { extraCopyright :: Text + , extraAnalytics :: Maybe Text -- ^ Google Analytics + } deriving Show + +parseExtra :: DefaultEnv -> Object -> Parser Extra +parseExtra _ o = Extra + <$> o .: "copyright" + <*> o .:? "analytics" -- cgit v1.2.3