Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fixed the example1 to work with snap 0.9 #7

Merged
merged 1 commit into from almost 2 years ago

2 participants

drozzy Petr Pilař
drozzy

Issue:
#5

See diff for details.

Petr Pilař
Owner

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

Petr Pilař Palmik merged commit 014fc12 into from
Petr Pilař Palmik closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 17, 2012
drozzy drozzy Fixed example1 by fixing dependencies and renaming template folder an…
…d added gitignore for logs and dist folders
3aeec9a
This page is out of date. Refresh to see the latest.
4 .gitignore
... ... @@ -1 +1,3 @@
1   -*.*~
  1 +*.*~
  2 +dist
  3 +*.log
1  examples/example1/.gitignore
... ... @@ -0,0 +1 @@
  1 +log
15 examples/example1/example1.cabal
@@ -7,7 +7,7 @@ license-file: LICENSE
7 7 author: Petr Pilař
8 8 maintainer: jondoe@example.com
9 9 build-type: Simple
10   -cabal-version: >= 1.6
  10 +cabal-version: >= 1.2
11 11 homepage: example.com
12 12 category: Web
13 13
@@ -22,15 +22,16 @@ Executable snaplet-mongodb-minimalistic-example1
22 22 Build-depends:
23 23 base >= 4 && < 5,
24 24 bytestring >= 0.9.1 && < 0.10,
25   - data-lens >= 2.0.1 && < 2.1,
  25 + data-lens >= 2.0.1 && < 2.11,
26 26 data-lens-template >= 2.1 && < 2.2,
27   - heist >= 0.7 && < 0.8,
  27 + heist >= 0.8 && < 0.9,
28 28 mtl >= 2 && < 3,
29   - snap == 0.7.*,
30   - snap-core == 0.7.*,
31   - snap-server == 0.7.*,
  29 + snap == 0.9.*,
  30 + snap-core == 0.9.*,
  31 + snap-server == 0.9.*,
  32 + snap-loader-static == 0.9.*,
32 33 text >= 0.11 && < 0.12,
33   - xmlhtml == 0.1.*,
  34 + xmlhtml >= 0.1,
34 35 snaplet-mongodb-minimalistic,
35 36 mongoDB,
36 37 utf8-string
0  examples/example1/log/access.log
No changes.
0  examples/example1/log/error.log
No changes.
0  examples/example1/resources/templates/index.tpl → examples/example1/snaplets/heist/templates/index.tpl
File renamed without changes
0  examples/example1/resources/static/screen.css → examples/example1/snaplets/static/screen.css
File renamed without changes
16 examples/example1/src/Main.hs
@@ -10,17 +10,15 @@ import qualified Data.Text as T
10 10 import Snap.Http.Server
11 11 import Snap.Snaplet
12 12 import Snap.Core
13   -
14   -import Application
15   -
  13 +import Snap.Snaplet.Config
16 14 import System.IO
17 15
18 16 import Site
19 17
20 18 #ifdef DEVELOPMENT
21   -import Snap.Loader.Devel
  19 +import Snap.Loader.Dynamic
22 20 #else
23   -import Snap.Loader.Prod
  21 +import Snap.Loader.Static
24 22 #endif
25 23
26 24 main :: IO ()
@@ -32,7 +30,7 @@ main = do
32 30 _ <- try $ httpServe conf $ site :: IO (Either SomeException ())
33 31 cleanup
34 32
35   -getConf :: IO (Config Snap ())
  33 +getConf :: IO (Config Snap AppConfig)
36 34 getConf = commandLineConfig defaultConfig
37 35
38 36
@@ -49,8 +47,8 @@ getConf = commandLineConfig defaultConfig
49 47 --
50 48 -- This sample doesn't actually use the config passed in, but more
51 49 -- sophisticated code might.
52   -getActions :: Config Snap () -> IO (Snap (), IO ())
53   -getActions _ = do
54   - (msgs, site, cleanup) <- runSnaplet app
  50 +getActions :: Config Snap AppConfig -> IO (Snap (), IO ())
  51 +getActions conf = do
  52 + (msgs, site, cleanup) <- runSnaplet (appEnvironment =<< getOther conf) app
55 53 hPutStrLn stderr $ T.unpack msgs
56 54 return (site, cleanup)
4 examples/example1/src/Site.hs
@@ -44,12 +44,12 @@ routes :: [(ByteString, Handler App App ())]
44 44 routes = [ ("/", method POST indexHandler)
45 45 , ("/", indexView)
46 46 , ("", with heist heistServe)
47   - , ("", serveDirectory "resources/static")
  47 + , ("", serveDirectory "static")
48 48 ]
49 49
50 50 app :: SnapletInit App App
51 51 app = makeSnaplet "app" "An snaplet example application." Nothing $ do
52   - h <- nestSnaplet "heist" heist $ heistInit "resources/templates"
  52 + h <- nestSnaplet "heist" heist $ heistInit "templates"
53 53 d <- nestSnaplet "database" database $ mongoDBInit 10 (host "127.0.0.1") "Snaplet-MongoDB"
54 54 addRoutes routes
55 55 return $ App h d

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.