Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the example1 to work with snap 0.9 #7

Merged
merged 1 commit into from Oct 4, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
@@ -1 +1,3 @@
*.*~
*.*~
dist
*.log
1 change: 1 addition & 0 deletions examples/example1/.gitignore
@@ -0,0 +1 @@
log
15 changes: 8 additions & 7 deletions examples/example1/example1.cabal
Expand Up @@ -7,7 +7,7 @@ license-file: LICENSE
author: Petr Pilař
maintainer: jondoe@example.com
build-type: Simple
cabal-version: >= 1.6
cabal-version: >= 1.2
homepage: example.com
category: Web

Expand All @@ -22,15 +22,16 @@ Executable snaplet-mongodb-minimalistic-example1
Build-depends:
base >= 4 && < 5,
bytestring >= 0.9.1 && < 0.10,
data-lens >= 2.0.1 && < 2.1,
data-lens >= 2.0.1 && < 2.11,
data-lens-template >= 2.1 && < 2.2,
heist >= 0.7 && < 0.8,
heist >= 0.8 && < 0.9,
mtl >= 2 && < 3,
snap == 0.7.*,
snap-core == 0.7.*,
snap-server == 0.7.*,
snap == 0.9.*,
snap-core == 0.9.*,
snap-server == 0.9.*,
snap-loader-static == 0.9.*,
text >= 0.11 && < 0.12,
xmlhtml == 0.1.*,
xmlhtml >= 0.1,
snaplet-mongodb-minimalistic,
mongoDB,
utf8-string
Expand Down
Empty file removed examples/example1/log/access.log
Empty file.
Empty file removed examples/example1/log/error.log
Empty file.
16 changes: 7 additions & 9 deletions examples/example1/src/Main.hs
Expand Up @@ -10,17 +10,15 @@ import qualified Data.Text as T
import Snap.Http.Server
import Snap.Snaplet
import Snap.Core

import Application

import Snap.Snaplet.Config
import System.IO

import Site

#ifdef DEVELOPMENT
import Snap.Loader.Devel
import Snap.Loader.Dynamic
#else
import Snap.Loader.Prod
import Snap.Loader.Static
#endif

main :: IO ()
Expand All @@ -32,7 +30,7 @@ main = do
_ <- try $ httpServe conf $ site :: IO (Either SomeException ())
cleanup

getConf :: IO (Config Snap ())
getConf :: IO (Config Snap AppConfig)
getConf = commandLineConfig defaultConfig


Expand All @@ -49,8 +47,8 @@ getConf = commandLineConfig defaultConfig
--
-- This sample doesn't actually use the config passed in, but more
-- sophisticated code might.
getActions :: Config Snap () -> IO (Snap (), IO ())
getActions _ = do
(msgs, site, cleanup) <- runSnaplet app
getActions :: Config Snap AppConfig -> IO (Snap (), IO ())
getActions conf = do
(msgs, site, cleanup) <- runSnaplet (appEnvironment =<< getOther conf) app
hPutStrLn stderr $ T.unpack msgs
return (site, cleanup)
4 changes: 2 additions & 2 deletions examples/example1/src/Site.hs
Expand Up @@ -44,12 +44,12 @@ routes :: [(ByteString, Handler App App ())]
routes = [ ("/", method POST indexHandler)
, ("/", indexView)
, ("", with heist heistServe)
, ("", serveDirectory "resources/static")
, ("", serveDirectory "static")
]

app :: SnapletInit App App
app = makeSnaplet "app" "An snaplet example application." Nothing $ do
h <- nestSnaplet "heist" heist $ heistInit "resources/templates"
h <- nestSnaplet "heist" heist $ heistInit "templates"
d <- nestSnaplet "database" database $ mongoDBInit 10 (host "127.0.0.1") "Snaplet-MongoDB"
addRoutes routes
return $ App h d
Expand Down