Skip to content

Commit

Permalink
Receive input from the user.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Trinkle committed Nov 15, 2013
1 parent 6e7d1d5 commit a6496e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion memoise.cabal
@@ -1,5 +1,5 @@
Name: memoise
Version: 0.5
Version: 0.6
License: BSD3
Author: Ryan Trinkle
Maintainer: ryan.trinkle@gmail.com
Expand Down
7 changes: 6 additions & 1 deletion snaplets/heist/templates/index.tpl
Expand Up @@ -15,7 +15,12 @@
</div>
</div>
<div class="hero-unit">
<h1>Hello, world!</h1>
<h1>memoi.se</h1>
<p>The world's laziest hyperlink shortener</p>
<form action="/" class="form-inline" method="post">
<input type="text" name="url" autofocus="autofocus" placeholder="Enter URL">
<input type="submit" class="btn btn-primary" value="Submit">
</form>
</div>
<div class="navbar navbar-fixed-bottom container-fluid">
<div class="navbar-inner">
Expand Down
6 changes: 5 additions & 1 deletion src/Main.hs
Expand Up @@ -12,7 +12,11 @@ instance HasHeist Memoise where
heistLens = subSnaplet heist

indexHandler :: Handler Memoise Memoise ()
indexHandler = render "index"
indexHandler = do
mUrl <- getParam "url"
case mUrl of
Just url -> redirect url
Nothing -> render "index"

memoiseInit :: SnapletInit Memoise Memoise
memoiseInit = makeSnaplet "memoise" "The world's laziest hyperlink shortener" Nothing $ do
Expand Down

0 comments on commit a6496e2

Please sign in to comment.