Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed the example1 to work with snap 0.9 #7

Merged
merged 1 commit into from

2 participants

@drozzy

Issue:
#5

See diff for details.

@Palmik
Owner

Thanks for your contribution and sorry it took me so long to merge.

@Palmik Palmik merged commit 014fc12 into Palmik:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 17, 2012
  1. @drozzy

    Fixed example1 by fixing dependencies and renaming template folder an…

    drozzy authored
    …d added gitignore for logs and dist folders
This page is out of date. Refresh to see the latest.
View
4 .gitignore
@@ -1 +1,3 @@
-*.*~
+*.*~
+dist
+*.log
View
1  examples/example1/.gitignore
@@ -0,0 +1 @@
+log
View
15 examples/example1/example1.cabal
@@ -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
@@ -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
View
0  examples/example1/log/access.log
No changes.
View
0  examples/example1/log/error.log
No changes.
View
0  ...es/example1/resources/templates/index.tpl → ...ample1/snaplets/heist/templates/index.tpl
File renamed without changes
View
0  ...ples/example1/resources/static/screen.css → examples/example1/snaplets/static/screen.css
File renamed without changes
View
16 examples/example1/src/Main.hs
@@ -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 ()
@@ -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
@@ -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)
View
4 examples/example1/src/Site.hs
@@ -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
Something went wrong with that request. Please try again.