Skip to content
Permalink
Browse files

Prepare the new home

- Remove bootstrap and unused files.
- Configure i18n.
- Remove unused code.
- Configure ghci to handle warnings as fatal errors.
  • Loading branch information...
ggarciajr committed Jan 26, 2016
1 parent 4ca4fba commit 7864f7d88782e531d89510deda2c1a7878706e2a
@@ -4,6 +4,7 @@ module Application
, appMain
, develMain
, makeFoundation
, makeLogWare
-- * for DevelMain
, getApplicationRepl
, shutdownApp
@@ -17,6 +18,7 @@ import Database.Persist.Postgresql (createPostgresqlPool, pgConnStr,
pgPoolSize, runSqlPool)
import Import
import Language.Haskell.TH.Syntax (qLocation)
import Network.Wai (Middleware)
import Network.Wai.Handler.Warp (Settings, defaultSettings,
defaultShouldDisplayException,
runSettings, setHost,
@@ -79,7 +81,14 @@ makeFoundation appSettings = do
-- applying some additional middlewares.
makeApplication :: App -> IO Application
makeApplication foundation = do
logWare <- mkRequestLogger def
logWare <- makeLogWare foundation
-- Create the WAI application and apply middlewares
appPlain <- toWaiAppPlain foundation
return $ logWare $ defaultMiddlewaresNoLogging appPlain

makeLogWare :: App -> IO Middleware
makeLogWare foundation =
mkRequestLogger def
{ outputFormat =
if appDetailedRequestLogging $ appSettings foundation
then Detailed True
@@ -90,9 +99,6 @@ makeApplication foundation = do
, destination = Logger $ loggerSet $ appLogger foundation
}

-- Create the WAI application and apply middlewares
appPlain <- toWaiAppPlain foundation
return $ logWare $ defaultMiddlewaresNoLogging appPlain

-- | Warp settings for the given foundation value.
warpSettings :: App -> Settings
@@ -65,14 +65,7 @@ instance Yesod App where
-- you to use normal widget features in default-layout.

pc <- widgetToPageContent $ do
addStylesheet $ StaticR css_bootstrap_css

-- this is an array of static js files that yesod will
-- combine into one single js file and load it via a
-- <script> tag.
$(combineScripts 'StaticR
[ js_bundle_js
])

$(widgetFile "default-layout")
withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet")

@@ -161,3 +154,6 @@ unsafeHandler = Unsafe.fakeHandlerGetLogger appLogger
-- https://github.com/yesodweb/yesod/wiki/Sending-email
-- https://github.com/yesodweb/yesod/wiki/Serve-static-files-from-a-separate-domain
-- https://github.com/yesodweb/yesod/wiki/i18n-messages-in-the-scaffolding

-- Add I18N support
mkMessage "App" "messages" "en"
@@ -1,9 +1,6 @@
module Handler.Home where

import Import
import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3,
withSmallInput)

import Import
-- This is a handler function for the GET request method on the HomeR
-- resource pattern. All of your resource patterns are defined in
-- config/routes
@@ -13,28 +10,8 @@ import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3,
-- inclined, or create a single monolithic file.
getHomeR :: Handler Html
getHomeR = do
(formWidget, formEnctype) <- generateFormPost sampleForm
let submission = Nothing :: Maybe (FileInfo, Text)
handlerName = "getHomeR" :: Text
defaultLayout $ do
aDomId <- newIdent
setTitle "Welcome To Yesod!"
$(widgetFile "homepage")

postHomeR :: Handler Html
postHomeR = do
((result, formWidget), formEnctype) <- runFormPost sampleForm
let handlerName = "postHomeR" :: Text
submission = case result of
FormSuccess res -> Just res
_ -> Nothing
master <- getYesod

defaultLayout $ do
aDomId <- newIdent
setTitle "Welcome To Yesod!"
setTitleI MsgTitle
$(widgetFile "homepage")

sampleForm :: Form (FileInfo, Text)
sampleForm = renderBootstrap3 BootstrapBasicForm $ (,)
<$> fileAFormReq "Choose a file"
<*> areq textField (withSmallInput "What's on the file?") Nothing
@@ -4,4 +4,4 @@
/favicon.ico FaviconR GET
/robots.txt RobotsR GET

/ HomeR GET POST
/ HomeR GET
@@ -25,5 +25,5 @@ database:
database: "_env:PGDATABASE:flora"
poolsize: "_env:PGPOOLSIZE:10"

copyright: Insert copyright statement here
copyright: Copyright © 2016 Flora Time Tracker. All rights reserved.
#analytics: UA-YOURCODE
@@ -25,9 +25,9 @@ library

if flag(dev) || flag(library-only)
cpp-options: -DDEVELOPMENT
ghc-options: -Wall -fwarn-tabs -O0
ghc-options: -W -Wall -Werror -fwarn-tabs -O0
else
ghc-options: -Wall -fwarn-tabs -O2
ghc-options: -W -Wall -Werror -fwarn-tabs -O2

extensions: TemplateHaskell
QuasiQuotes
@@ -82,6 +82,7 @@ library
, containers
, vector
, time
, wai
-- yesod Could not find module 'Foreign.Store'
-- need to find a better way so there is no need
-- to include this in the final binary.
@@ -94,15 +95,18 @@ executable flora
main-is: main.hs
hs-source-dirs: app
build-depends: base, flora

ghc-options: -threaded -O2 -rtsopts -with-rtsopts=-N
ghc-options: -W -Wall -Werror -threaded -O -rtsopts -with-rtsopts=-N

test-suite test
type: exitcode-stdio-1.0
main-is: Spec.hs
hs-source-dirs: test
ghc-options: -Wall

other-modules: Handler.CommonSpec
, Handler.HomeSpec
, TestImport

extensions: TemplateHaskell
QuasiQuotes
OverloadedStrings
@@ -122,7 +126,7 @@ test-suite test

build-depends: base
, flora
, yesod-test
, yesod-test >= 1.5.0.1 && < 1.6
, yesod-core
, yesod
, persistent
@@ -131,6 +135,6 @@ test-suite test
, monad-logger
, shakespeare
, transformers
, hspec
, hspec >= 2.0.0
, classy-prelude
, classy-prelude-yesod
@@ -0,0 +1 @@
Title: Flora Time Tracker
@@ -0,0 +1 @@
Title: Flora Rastreador de Tempo
@@ -1,7 +1,7 @@
# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md

# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-4.1
resolver: lts-5.0

# Local packages, usually specified by relative directory name
packages:
Oops, something went wrong.

0 comments on commit 7864f7d

Please sign in to comment.
You can’t perform that action at this time.