Safe Haskell | None |
---|---|
Language | Haskell2010 |
- main :: IO ()
- initSample :: SnapletInit Sample Sample
- sampleTemplate :: Text
- initBlog :: forall b. (HasReCaptcha b, HasHeist b) => Snaplet (Heist b) -> SnapletInit b Blog
Main
main
=serveSnaplet
defaultConfig
initSample
You can load this into GHCi and run it, with full logging to stdout/stderr
>>>
:main --verbose --access-log= --error-log=
initSample :: SnapletInit Sample Sample Source
Requires 'snaplets/heist/templates/sample.tpl' - a suggested version of which
is available in this module as sampleTemplate
.
This simple asks for your site and private key through stdin.
Necessities
Heist template, written to $PWD/snaplets/heist/recaptcha-example.tpl
sampleTemplate ≈ <html> <head> <recaptcha-script /> </head> <body> <form method='POST'> <input type='text' name='name' placeholder='Name'> <input type='text' name='email' placeholder='Email'> <br> <textarea class='field' name='content' rows='20' placeholder='Content'></textarea> <br> <recaptcha-div /> <input type='submit' value='Comment'> </form> </body> </html>
Implementation
initBlog :: forall b. (HasReCaptcha b, HasHeist b) => Snaplet (Heist b) -> SnapletInit b Blog Source
A "blog" snaplet which reads hypothetical "posts" by their id
, routing
GET on /posts/:id to display a post, and POST on /posts/:id to add a
comment to them. For loose, useless definitions of "post" and "comment" -
this snaplet is only for demonstration purposes.