Skip to content

Commit a6496e2

Browse files
author
Ryan Trinkle
committed
Receive input from the user.
1 parent 6e7d1d5 commit a6496e2

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

memoise.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: memoise
2-
Version: 0.5
2+
Version: 0.6
33
License: BSD3
44
Author: Ryan Trinkle
55
Maintainer: ryan.trinkle@gmail.com

snaplets/heist/templates/index.tpl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
</div>
1616
</div>
1717
<div class="hero-unit">
18-
<h1>Hello, world!</h1>
18+
<h1>memoi.se</h1>
19+
<p>The world's laziest hyperlink shortener</p>
20+
<form action="/" class="form-inline" method="post">
21+
<input type="text" name="url" autofocus="autofocus" placeholder="Enter URL">
22+
<input type="submit" class="btn btn-primary" value="Submit">
23+
</form>
1924
</div>
2025
<div class="navbar navbar-fixed-bottom container-fluid">
2126
<div class="navbar-inner">

src/Main.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ instance HasHeist Memoise where
1212
heistLens = subSnaplet heist
1313

1414
indexHandler :: Handler Memoise Memoise ()
15-
indexHandler = render "index"
15+
indexHandler = do
16+
mUrl <- getParam "url"
17+
case mUrl of
18+
Just url -> redirect url
19+
Nothing -> render "index"
1620

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

0 commit comments

Comments
 (0)