Permalink
Browse files

Mirror requests

  • Loading branch information...
1 parent 8f65a33 commit 0ce73d6b3290e9a8251ce06b1b39d4a249a9e9c6 @yogsototh committed Feb 20, 2012
Showing with 26 additions and 0 deletions.
  1. +1 −0 Application.hs
  2. +15 −0 Handler/Mirror.hs
  3. +1 −0 config/routes
  4. +4 −0 templates/mirror.hamlet
  5. +4 −0 templates/posted.hamlet
  6. +1 −0 yosog.cabal
View
@@ -25,6 +25,7 @@ import Network.HTTP.Conduit (newManager, def)
-- Import all relevant handler modules here.
import Handler.Root
import Handler.Echo
+import Handler.Mirror
-- This line actually creates our YesodSite instance. It is the second half
-- of the call to mkYesodData which occurs in Foundation.hs. Please see
View
@@ -0,0 +1,15 @@
+module Handler.Mirror where
+
+import Import
+import qualified Data.Text as T
+
+getMirrorR :: Handler RepHtml
+getMirrorR = do
+ defaultLayout $ do
+ $(widgetFile "mirror")
+
+postMirrorR :: Handler RepHtml
+postMirrorR = do
+ postedText <- runInputPost $ ireq textField "content"
+ defaultLayout $ do
+ $(widgetFile "posted")
View
@@ -7,3 +7,4 @@
/ RootR GET
/echo/#Text EchoR GET
+/mirror MirrorR GET POST
View
@@ -0,0 +1,4 @@
+<h1> Enter your text
+<form method=post action=@{MirrorR}>
+ <input type=text name=content>
+ <input type=submit>
View
@@ -0,0 +1,4 @@
+<h1>You've just posted
+<p>#{postedText}#{T.reverse postedText}
+<hr>
+<p><a href=@{MirrorR}>Get back
View
@@ -34,6 +34,7 @@ library
Settings.StaticFiles
Handler.Root
Handler.Echo
+ Handler.Mirror
ghc-options: -Wall -threaded -O0
cpp-options: -DDEVELOPMENT

0 comments on commit 0ce73d6

Please sign in to comment.