Move some files around, tweak the generated code a bit
This commit is contained in:
parent
952f6baafd
commit
f4dcf17f3f
25 changed files with 314 additions and 148 deletions
|
@ -1,16 +0,0 @@
|
||||||
-- | Common handler functions.
|
|
||||||
module Handler.Common where
|
|
||||||
|
|
||||||
import Data.FileEmbed (embedFile)
|
|
||||||
import Import
|
|
||||||
|
|
||||||
-- These handlers embed files in the executable at compile time to avoid a
|
|
||||||
-- runtime dependency, and for efficiency.
|
|
||||||
|
|
||||||
getFaviconR :: Handler TypedContent
|
|
||||||
getFaviconR = return $ TypedContent "image/x-icon"
|
|
||||||
$ toContent $(embedFile "config/favicon.ico")
|
|
||||||
|
|
||||||
getRobotsR :: Handler TypedContent
|
|
||||||
getRobotsR = return $ TypedContent typePlain
|
|
||||||
$ toContent $(embedFile "config/robots.txt")
|
|
|
@ -1,6 +0,0 @@
|
||||||
module Import
|
|
||||||
( module Import
|
|
||||||
) where
|
|
||||||
|
|
||||||
import Foundation as Import
|
|
||||||
import Import.NoFoundation as Import
|
|
|
@ -1,11 +0,0 @@
|
||||||
module Import.NoFoundation
|
|
||||||
( module Import
|
|
||||||
) where
|
|
||||||
|
|
||||||
import ClassyPrelude.Yesod as Import
|
|
||||||
import Model as Import
|
|
||||||
import Settings as Import
|
|
||||||
import Settings.StaticFiles as Import
|
|
||||||
import Yesod.Auth as Import
|
|
||||||
import Yesod.Core.Types as Import (loggerSet)
|
|
||||||
import Yesod.Default.Config2 as Import
|
|
13
Model.hs
13
Model.hs
|
@ -1,13 +0,0 @@
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
|
||||||
|
|
||||||
module Model where
|
|
||||||
|
|
||||||
import ClassyPrelude.Yesod
|
|
||||||
import Database.Persist.Quasi
|
|
||||||
|
|
||||||
-- 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 sqlSettings, mkMigrate "migrateAll"]
|
|
||||||
$(persistFileWith lowerCaseSettings "config/models")
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
-- | Running your app inside GHCi.
|
-- | Running your app inside GHCi.
|
||||||
--
|
--
|
||||||
-- To start up GHCi for usage with Yesod, first make sure you are in dev mode:
|
-- To start up GHCi for usage with Yesod, first make sure you are in dev mode:
|
||||||
|
|
16
app/devel.hs
16
app/devel.hs
|
@ -1,4 +1,20 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
{-# LANGUAGE PackageImports #-}
|
{-# LANGUAGE PackageImports #-}
|
||||||
|
|
||||||
import "vervis" Application (develMain)
|
import "vervis" Application (develMain)
|
||||||
import Prelude (IO)
|
import Prelude (IO)
|
||||||
|
|
||||||
|
|
15
app/main.hs
15
app/main.hs
|
@ -1,3 +1,18 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
import Prelude (IO)
|
import Prelude (IO)
|
||||||
import Application (appMain)
|
import Application (appMain)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
-- This file is part of Vervis.
|
||||||
|
--
|
||||||
|
-- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
--
|
||||||
|
-- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
--
|
||||||
|
-- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
-- rights to this software to the public domain worldwide. This software is
|
||||||
|
-- distributed without any warranty.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
-- with this software. If not, see
|
||||||
|
-- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
User
|
User
|
||||||
ident Text
|
ident Text
|
||||||
password Text Maybe
|
password Text Maybe
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
-- This file is part of Vervis.
|
||||||
|
--
|
||||||
|
-- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
--
|
||||||
|
-- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
--
|
||||||
|
-- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
-- rights to this software to the public domain worldwide. This software is
|
||||||
|
-- distributed without any warranty.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
-- with this software. If not, see
|
||||||
|
-- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
/static StaticR Static appStatic
|
/static StaticR Static appStatic
|
||||||
/auth AuthR Auth getAuth
|
/auth AuthR Auth getAuth
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
# Values formatted like "_env:ENV_VAR_NAME:default_value" can be overridden by the specified environment variable.
|
# Values formatted like "_env:ENV_VAR_NAME:default_value" can be overridden by
|
||||||
# See https://github.com/yesodweb/yesod/wiki/Configuration#overriding-configuration-values-with-environment-variables
|
# the specified environment variable. See the Yesod wiki, Configuration page.
|
||||||
|
|
||||||
static-dir: "_env:STATIC_DIR:static"
|
static-dir: "_env:STATIC_DIR:static"
|
||||||
host: "_env:HOST:*4" # any IPv4 host
|
|
||||||
port: "_env:PORT:3000" # NB: The port `yesod devel` uses is distinct from this value. Set the `yesod devel` port from the command line.
|
# any IPv4 host
|
||||||
|
host: "_env:HOST:*4"
|
||||||
|
|
||||||
|
# The port `yesod devel` uses is distinct from this value. Set the
|
||||||
|
# `yesod devel` port from the command line.
|
||||||
|
port: "_env:PORT:3000"
|
||||||
|
|
||||||
ip-from-header: "_env:IP_FROM_HEADER:false"
|
ip-from-header: "_env:IP_FROM_HEADER:false"
|
||||||
|
|
||||||
# Default behavior: determine the application root from the request headers.
|
# Default behavior: determine the application root from the request headers.
|
||||||
|
@ -20,16 +26,16 @@ ip-from-header: "_env:IP_FROM_HEADER:false"
|
||||||
# mutable-static: false
|
# mutable-static: false
|
||||||
# skip-combining: false
|
# skip-combining: false
|
||||||
|
|
||||||
# NB: If you need a numeric value (e.g. 123) to parse as a String, wrap it in single quotes (e.g. "_env:PGPASS:'123'")
|
# If you need a numeric value (e.g. 123) to parse as a String, wrap it in
|
||||||
# See https://github.com/yesodweb/yesod/wiki/Configuration#parsing-numeric-values-as-strings
|
# single quotes (e.g. "_env:PGPASS:'123'"). See the Yesod wiki, Configuration
|
||||||
|
# page.
|
||||||
|
|
||||||
database:
|
database:
|
||||||
user: "_env:PGUSER:vervis_LOWER"
|
user: "_env:PGUSER:vervis"
|
||||||
password: "_env:PGPASS:vervis"
|
password: "_env:PGPASS:vervis_password_here"
|
||||||
host: "_env:PGHOST:localhost"
|
host: "_env:PGHOST:localhost"
|
||||||
port: "_env:PGPORT:5432"
|
port: "_env:PGPORT:5432"
|
||||||
database: "_env:PGDATABASE:vervis_LOWER"
|
database: "_env:PGDATABASE:vervis"
|
||||||
poolsize: "_env:PGPOOLSIZE:10"
|
poolsize: "_env:PGPOOLSIZE:10"
|
||||||
|
|
||||||
copyright: Insert copyright statement here
|
copyright: Insert your statement against copyright here
|
||||||
#analytics: UA-YOURCODE
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
database:
|
database:
|
||||||
database: vervis_LOWER_test
|
database: vervis_dev_test
|
||||||
|
|
|
@ -1,4 +1,20 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||||
|
|
||||||
module Application
|
module Application
|
||||||
( getApplicationDev
|
( getApplicationDev
|
||||||
, appMain
|
, appMain
|
||||||
|
@ -11,7 +27,8 @@ module Application
|
||||||
-- * for GHCI
|
-- * for GHCI
|
||||||
, handler
|
, handler
|
||||||
, db
|
, db
|
||||||
) where
|
)
|
||||||
|
where
|
||||||
|
|
||||||
import Control.Monad.Logger (liftLoc, runLoggingT)
|
import Control.Monad.Logger (liftLoc, runLoggingT)
|
||||||
import Database.Persist.Postgresql (createPostgresqlPool, pgConnStr,
|
import Database.Persist.Postgresql (createPostgresqlPool, pgConnStr,
|
|
@ -1,3 +1,18 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
module Foundation where
|
module Foundation where
|
||||||
|
|
||||||
import Import.NoFoundation
|
import Import.NoFoundation
|
|
@ -1,3 +1,18 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
module Handler.Comment where
|
module Handler.Comment where
|
||||||
|
|
||||||
import Import
|
import Import
|
35
src/Handler/Common.hs
Normal file
35
src/Handler/Common.hs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
|
-- | Common handler functions.
|
||||||
|
module Handler.Common where
|
||||||
|
|
||||||
|
import Data.FileEmbed (embedFile)
|
||||||
|
import Import
|
||||||
|
|
||||||
|
-- These handlers embed files in the executable at compile time to avoid a
|
||||||
|
-- runtime dependency, and for efficiency.
|
||||||
|
|
||||||
|
getFaviconR :: Handler TypedContent
|
||||||
|
getFaviconR =
|
||||||
|
return $
|
||||||
|
TypedContent "image/x-icon" $
|
||||||
|
toContent $(embedFile "config/favicon.ico")
|
||||||
|
|
||||||
|
getRobotsR :: Handler TypedContent
|
||||||
|
getRobotsR =
|
||||||
|
return $
|
||||||
|
TypedContent typePlain $
|
||||||
|
toContent $(embedFile "config/robots.txt")
|
|
@ -1,3 +1,18 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
module Handler.Home where
|
module Handler.Home where
|
||||||
|
|
||||||
import Import
|
import Import
|
19
src/Import.hs
Normal file
19
src/Import.hs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
|
module Import ( module Import ) where
|
||||||
|
|
||||||
|
import Foundation as Import
|
||||||
|
import Import.NoFoundation as Import
|
24
src/Import/NoFoundation.hs
Normal file
24
src/Import/NoFoundation.hs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
|
module Import.NoFoundation ( module Import ) where
|
||||||
|
|
||||||
|
import ClassyPrelude.Yesod as Import
|
||||||
|
import Model as Import
|
||||||
|
import Settings as Import
|
||||||
|
import Settings.StaticFiles as Import
|
||||||
|
import Yesod.Auth as Import
|
||||||
|
import Yesod.Core.Types as Import (loggerSet)
|
||||||
|
import Yesod.Default.Config2 as Import
|
28
src/Model.hs
Normal file
28
src/Model.hs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
|
|
||||||
|
module Model where
|
||||||
|
|
||||||
|
import ClassyPrelude.Yesod
|
||||||
|
import Database.Persist.Quasi
|
||||||
|
|
||||||
|
-- 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 sqlSettings, mkMigrate "migrateAll"]
|
||||||
|
$(persistFileWith lowerCaseSettings "config/models")
|
|
@ -1,4 +1,20 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
{-# Language CPP #-}
|
{-# Language CPP #-}
|
||||||
|
|
||||||
-- | Settings are centralized, as much as possible, into this file. This
|
-- | Settings are centralized, as much as possible, into this file. This
|
||||||
-- includes database connection settings, static file locations, etc.
|
-- includes database connection settings, static file locations, etc.
|
||||||
-- In addition, you can configure a number of different aspects of Yesod
|
-- In addition, you can configure a number of different aspects of Yesod
|
||||||
|
@ -52,8 +68,6 @@ data AppSettings = AppSettings
|
||||||
-- Example app-specific configuration values.
|
-- Example app-specific configuration values.
|
||||||
, appCopyright :: Text
|
, appCopyright :: Text
|
||||||
-- ^ Copyright text to appear in the footer of the page
|
-- ^ Copyright text to appear in the footer of the page
|
||||||
, appAnalytics :: Maybe Text
|
|
||||||
-- ^ Google Analytics code
|
|
||||||
}
|
}
|
||||||
|
|
||||||
instance FromJSON AppSettings where
|
instance FromJSON AppSettings where
|
||||||
|
@ -78,7 +92,6 @@ instance FromJSON AppSettings where
|
||||||
appSkipCombining <- o .:? "skip-combining" .!= defaultDev
|
appSkipCombining <- o .:? "skip-combining" .!= defaultDev
|
||||||
|
|
||||||
appCopyright <- o .: "copyright"
|
appCopyright <- o .: "copyright"
|
||||||
appAnalytics <- o .:? "analytics"
|
|
||||||
|
|
||||||
return AppSettings {..}
|
return AppSettings {..}
|
||||||
|
|
||||||
|
@ -99,10 +112,12 @@ combineSettings = def
|
||||||
-- user.
|
-- user.
|
||||||
|
|
||||||
widgetFile :: String -> Q Exp
|
widgetFile :: String -> Q Exp
|
||||||
widgetFile = (if appReloadTemplates compileTimeAppSettings
|
widgetFile =
|
||||||
|
let wf =
|
||||||
|
if appReloadTemplates compileTimeAppSettings
|
||||||
then widgetFileReload
|
then widgetFileReload
|
||||||
else widgetFileNoReload)
|
else widgetFileNoReload
|
||||||
widgetFileSettings
|
in wf widgetFileSettings
|
||||||
|
|
||||||
-- | Raw bytes at compile time of @config/settings.yml@
|
-- | Raw bytes at compile time of @config/settings.yml@
|
||||||
configSettingsYmlBS :: ByteString
|
configSettingsYmlBS :: ByteString
|
||||||
|
@ -112,7 +127,8 @@ configSettingsYmlBS = $(embedFile configSettingsYml)
|
||||||
configSettingsYmlValue :: Value
|
configSettingsYmlValue :: Value
|
||||||
configSettingsYmlValue = either throw id $ decodeEither' configSettingsYmlBS
|
configSettingsYmlValue = either throw id $ decodeEither' configSettingsYmlBS
|
||||||
|
|
||||||
-- | A version of @AppSettings@ parsed at compile time from @config/settings.yml@.
|
-- | A version of @AppSettings@ parsed at compile time from
|
||||||
|
-- @config/settings.yml@.
|
||||||
compileTimeAppSettings :: AppSettings
|
compileTimeAppSettings :: AppSettings
|
||||||
compileTimeAppSettings =
|
compileTimeAppSettings =
|
||||||
case fromJSON $ applyEnvValue False mempty configSettingsYmlValue of
|
case fromJSON $ applyEnvValue False mempty configSettingsYmlValue of
|
||||||
|
@ -126,11 +142,13 @@ compileTimeAppSettings =
|
||||||
-- > $(combineStylesheets 'StaticR [style1_css, style2_css])
|
-- > $(combineStylesheets 'StaticR [style1_css, style2_css])
|
||||||
|
|
||||||
combineStylesheets :: Name -> [Route Static] -> Q Exp
|
combineStylesheets :: Name -> [Route Static] -> Q Exp
|
||||||
combineStylesheets = combineStylesheets'
|
combineStylesheets =
|
||||||
|
combineStylesheets'
|
||||||
(appSkipCombining compileTimeAppSettings)
|
(appSkipCombining compileTimeAppSettings)
|
||||||
combineSettings
|
combineSettings
|
||||||
|
|
||||||
combineScripts :: Name -> [Route Static] -> Q Exp
|
combineScripts :: Name -> [Route Static] -> Q Exp
|
||||||
combineScripts = combineScripts'
|
combineScripts =
|
||||||
|
combineScripts'
|
||||||
(appSkipCombining compileTimeAppSettings)
|
(appSkipCombining compileTimeAppSettings)
|
||||||
combineSettings
|
combineSettings
|
|
@ -1,3 +1,18 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
-
|
||||||
|
- The author(s) have dedicated all copyright and related and neighboring
|
||||||
|
- rights to this software to the public domain worldwide. This software is
|
||||||
|
- distributed without any warranty.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
|
- with this software. If not, see
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
module Settings.StaticFiles where
|
module Settings.StaticFiles where
|
||||||
|
|
||||||
import Settings (appStaticDir, compileTimeAppSettings)
|
import Settings (appStaticDir, compileTimeAppSettings)
|
|
@ -49,14 +49,3 @@ $newline never
|
||||||
^{pageBody pc}
|
^{pageBody pc}
|
||||||
<footer>
|
<footer>
|
||||||
#{appCopyright $ appSettings master}
|
#{appCopyright $ appSettings master}
|
||||||
|
|
||||||
$maybe analytics <- appAnalytics $ appSettings master
|
|
||||||
<script>
|
|
||||||
if(!window.location.href.match(/localhost/)){
|
|
||||||
window._gaq = [['_setAccount','#{analytics}'],['_trackPageview'],['_trackPageLoadTime']];
|
|
||||||
(function() {
|
|
||||||
\ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
||||||
\ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
||||||
\ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
|
|
|
@ -47,28 +47,3 @@
|
||||||
^{formWidget}
|
^{formWidget}
|
||||||
<button .btn .btn-primary type="submit">
|
<button .btn .btn-primary type="submit">
|
||||||
Send it! <span class="glyphicon glyphicon-upload"></span>
|
Send it! <span class="glyphicon glyphicon-upload"></span>
|
||||||
|
|
||||||
<section.page-header>
|
|
||||||
<h2>JSON
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Yesod has JSON support baked-in.
|
|
||||||
The form below makes an AJAX request with Javascript,
|
|
||||||
then updates the page with your submission.
|
|
||||||
(see <tt>Handler/Comment.hs</tt>, <tt>templates/homepage.julius</tt>,
|
|
||||||
and <tt>Handler/Home.hs</tt> for the implementation).
|
|
||||||
<form ##{commentFormId}>
|
|
||||||
<.form-group>
|
|
||||||
<textarea ##{commentTextareaId} placeholder="Your comment here..." required></textarea>
|
|
||||||
<button .btn .btn-primary type="submit">
|
|
||||||
Create comment
|
|
||||||
|
|
||||||
<ul ##{commentListId}>
|
|
||||||
|
|
||||||
<section.page-header>
|
|
||||||
<h2>Testing
|
|
||||||
|
|
||||||
<p>
|
|
||||||
And last but not least, Testing. In <tt>test/Spec.hs</tt> you will find a #
|
|
||||||
test suite that performs tests on this page. #
|
|
||||||
You can run your tests by doing: <pre>stack test</pre>
|
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
document.getElementById(#{toJSON aDomId}).innerHTML = "This text was added by the Javascript part of the homepage widget.";
|
|
||||||
|
|
||||||
$(function() {
|
|
||||||
$("##{rawJS commentFormId}").submit(function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
var message = $("##{rawJS commentTextareaId}").val();
|
|
||||||
// (Browsers that enforce the "required" attribute on the textarea won't see this alert)
|
|
||||||
if (!message) {
|
|
||||||
alert("Please fill out the comment form first.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make an AJAX request to the server to create a new comment
|
|
||||||
$.ajax({
|
|
||||||
url: '@{CommentR}',
|
|
||||||
type: 'POST',
|
|
||||||
contentType: "application/json",
|
|
||||||
data: JSON.stringify({
|
|
||||||
message: message,
|
|
||||||
}),
|
|
||||||
success: function (data) {
|
|
||||||
var newNode = $("<li></li>");
|
|
||||||
newNode.text(data.message);
|
|
||||||
$("##{rawJS commentListId}").append(newNode);
|
|
||||||
},
|
|
||||||
error: function (data) {
|
|
||||||
console.log("Error creating comment: " + data);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -107,7 +107,7 @@ library
|
||||||
, time
|
, time
|
||||||
, case-insensitive
|
, case-insensitive
|
||||||
, wai
|
, wai
|
||||||
hs-source-dirs: ., app
|
hs-source-dirs: src
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
if flag(dev) || flag(library-only)
|
if flag(dev) || flag(library-only)
|
||||||
|
|
Loading…
Reference in a new issue