diff --git a/Handler/Common.hs b/Handler/Common.hs deleted file mode 100644 index eadd206..0000000 --- a/Handler/Common.hs +++ /dev/null @@ -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") diff --git a/Import.hs b/Import.hs deleted file mode 100644 index a102001..0000000 --- a/Import.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Import - ( module Import - ) where - -import Foundation as Import -import Import.NoFoundation as Import diff --git a/Import/NoFoundation.hs b/Import/NoFoundation.hs deleted file mode 100644 index 15bf2dc..0000000 --- a/Import/NoFoundation.hs +++ /dev/null @@ -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 diff --git a/Model.hs b/Model.hs deleted file mode 100644 index d857057..0000000 --- a/Model.hs +++ /dev/null @@ -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") diff --git a/app/DevelMain.hs b/app/DevelMain.hs index b327943..38fe870 100644 --- a/app/DevelMain.hs +++ b/app/DevelMain.hs @@ -1,3 +1,18 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + -- | Running your app inside GHCi. -- -- To start up GHCi for usage with Yesod, first make sure you are in dev mode: diff --git a/app/devel.hs b/app/devel.hs index 89f3d4f..ecd76ab 100644 --- a/app/devel.hs +++ b/app/devel.hs @@ -1,4 +1,20 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + {-# LANGUAGE PackageImports #-} + import "vervis" Application (develMain) import Prelude (IO) diff --git a/app/main.hs b/app/main.hs index 4ffa93d..8c2d8c0 100644 --- a/app/main.hs +++ b/app/main.hs @@ -1,3 +1,18 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + import Prelude (IO) import Application (appMain) diff --git a/config/models b/config/models index ed0fe39..8b50e5c 100644 --- a/config/models +++ b/config/models @@ -1,3 +1,17 @@ +-- This file is part of Vervis. +-- +-- Written in 2016 by fr33domlover . +-- +-- ♡ 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 +-- . + User ident Text password Text Maybe diff --git a/config/routes b/config/routes index ba811b0..464cb92 100644 --- a/config/routes +++ b/config/routes @@ -1,9 +1,23 @@ -/static StaticR Static appStatic -/auth AuthR Auth getAuth +-- This file is part of Vervis. +-- +-- Written in 2016 by fr33domlover . +-- +-- ♡ 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 +-- . + +/static StaticR Static appStatic +/auth AuthR Auth getAuth /favicon.ico FaviconR GET -/robots.txt RobotsR GET +/robots.txt RobotsR GET -/ HomeR GET POST +/ HomeR GET POST -/comments CommentR POST +/comments CommentR POST diff --git a/config/settings.yml b/config/settings.yml index 1397575..9a70811 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -1,9 +1,15 @@ -# Values formatted like "_env:ENV_VAR_NAME:default_value" can be overridden by the specified environment variable. -# See https://github.com/yesodweb/yesod/wiki/Configuration#overriding-configuration-values-with-environment-variables +# Values formatted like "_env:ENV_VAR_NAME:default_value" can be overridden by +# the specified environment variable. See the Yesod wiki, Configuration page. 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" # 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 # 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'") -# See https://github.com/yesodweb/yesod/wiki/Configuration#parsing-numeric-values-as-strings +# If you need a numeric value (e.g. 123) to parse as a String, wrap it in +# single quotes (e.g. "_env:PGPASS:'123'"). See the Yesod wiki, Configuration +# page. database: - user: "_env:PGUSER:vervis_LOWER" - password: "_env:PGPASS:vervis" + user: "_env:PGUSER:vervis" + password: "_env:PGPASS:vervis_password_here" host: "_env:PGHOST:localhost" port: "_env:PGPORT:5432" - database: "_env:PGDATABASE:vervis_LOWER" + database: "_env:PGDATABASE:vervis" poolsize: "_env:PGPOOLSIZE:10" -copyright: Insert copyright statement here -#analytics: UA-YOURCODE +copyright: Insert your statement against copyright here diff --git a/config/test-settings.yml b/config/test-settings.yml index 7f56e90..ace9f4a 100644 --- a/config/test-settings.yml +++ b/config/test-settings.yml @@ -1,2 +1,2 @@ database: - database: vervis_LOWER_test + database: vervis_dev_test diff --git a/Application.hs b/src/Application.hs similarity index 92% rename from Application.hs rename to src/Application.hs index d364362..505661f 100644 --- a/Application.hs +++ b/src/Application.hs @@ -1,4 +1,20 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + {-# OPTIONS_GHC -fno-warn-orphans #-} + module Application ( getApplicationDev , appMain @@ -11,7 +27,8 @@ module Application -- * for GHCI , handler , db - ) where + ) +where import Control.Monad.Logger (liftLoc, runLoggingT) import Database.Persist.Postgresql (createPostgresqlPool, pgConnStr, diff --git a/Foundation.hs b/src/Foundation.hs similarity index 93% rename from Foundation.hs rename to src/Foundation.hs index 6cc40e9..4aaa2f9 100644 --- a/Foundation.hs +++ b/src/Foundation.hs @@ -1,3 +1,18 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + module Foundation where import Import.NoFoundation diff --git a/Handler/Comment.hs b/src/Handler/Comment.hs similarity index 55% rename from Handler/Comment.hs rename to src/Handler/Comment.hs index edb20a8..eaf272b 100644 --- a/Handler/Comment.hs +++ b/src/Handler/Comment.hs @@ -1,3 +1,18 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + module Handler.Comment where import Import diff --git a/src/Handler/Common.hs b/src/Handler/Common.hs new file mode 100644 index 0000000..5bae553 --- /dev/null +++ b/src/Handler/Common.hs @@ -0,0 +1,35 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + +-- | 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") diff --git a/Handler/Home.hs b/src/Handler/Home.hs similarity index 76% rename from Handler/Home.hs rename to src/Handler/Home.hs index b481395..aebe3f2 100644 --- a/Handler/Home.hs +++ b/src/Handler/Home.hs @@ -1,3 +1,18 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + module Handler.Home where import Import diff --git a/src/Import.hs b/src/Import.hs new file mode 100644 index 0000000..c51bd51 --- /dev/null +++ b/src/Import.hs @@ -0,0 +1,19 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + +module Import ( module Import ) where + +import Foundation as Import +import Import.NoFoundation as Import diff --git a/src/Import/NoFoundation.hs b/src/Import/NoFoundation.hs new file mode 100644 index 0000000..46f8030 --- /dev/null +++ b/src/Import/NoFoundation.hs @@ -0,0 +1,24 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + +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 diff --git a/src/Model.hs b/src/Model.hs new file mode 100644 index 0000000..85efa4d --- /dev/null +++ b/src/Model.hs @@ -0,0 +1,28 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + +{-# 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") diff --git a/Settings.hs b/src/Settings.hs similarity index 82% rename from Settings.hs rename to src/Settings.hs index 01b6117..747b0ef 100644 --- a/Settings.hs +++ b/src/Settings.hs @@ -1,4 +1,20 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + {-# Language CPP #-} + -- | 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 @@ -52,8 +68,6 @@ data AppSettings = AppSettings -- Example app-specific configuration values. , appCopyright :: Text -- ^ Copyright text to appear in the footer of the page - , appAnalytics :: Maybe Text - -- ^ Google Analytics code } instance FromJSON AppSettings where @@ -78,7 +92,6 @@ instance FromJSON AppSettings where appSkipCombining <- o .:? "skip-combining" .!= defaultDev appCopyright <- o .: "copyright" - appAnalytics <- o .:? "analytics" return AppSettings {..} @@ -99,10 +112,12 @@ combineSettings = def -- user. widgetFile :: String -> Q Exp -widgetFile = (if appReloadTemplates compileTimeAppSettings +widgetFile = + let wf = + if appReloadTemplates compileTimeAppSettings then widgetFileReload - else widgetFileNoReload) - widgetFileSettings + else widgetFileNoReload + in wf widgetFileSettings -- | Raw bytes at compile time of @config/settings.yml@ configSettingsYmlBS :: ByteString @@ -112,11 +127,12 @@ configSettingsYmlBS = $(embedFile configSettingsYml) configSettingsYmlValue :: Value 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 = case fromJSON $ applyEnvValue False mempty configSettingsYmlValue of - Error e -> error e + Error e -> error e Success settings -> settings -- The following two functions can be used to combine multiple CSS or JS files @@ -126,11 +142,13 @@ compileTimeAppSettings = -- > $(combineStylesheets 'StaticR [style1_css, style2_css]) combineStylesheets :: Name -> [Route Static] -> Q Exp -combineStylesheets = combineStylesheets' - (appSkipCombining compileTimeAppSettings) - combineSettings +combineStylesheets = + combineStylesheets' + (appSkipCombining compileTimeAppSettings) + combineSettings combineScripts :: Name -> [Route Static] -> Q Exp -combineScripts = combineScripts' - (appSkipCombining compileTimeAppSettings) - combineSettings +combineScripts = + combineScripts' + (appSkipCombining compileTimeAppSettings) + combineSettings diff --git a/Settings/StaticFiles.hs b/src/Settings/StaticFiles.hs similarity index 56% rename from Settings/StaticFiles.hs rename to src/Settings/StaticFiles.hs index c8021d3..6eccef1 100644 --- a/Settings/StaticFiles.hs +++ b/src/Settings/StaticFiles.hs @@ -1,3 +1,18 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ 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 + - . + -} + module Settings.StaticFiles where import Settings (appStaticDir, compileTimeAppSettings) diff --git a/templates/default-layout-wrapper.hamlet b/templates/default-layout-wrapper.hamlet index c2d4576..46ccae9 100644 --- a/templates/default-layout-wrapper.hamlet +++ b/templates/default-layout-wrapper.hamlet @@ -49,14 +49,3 @@ $newline never ^{pageBody pc}