{-# LANGUAGE DeriveDataTypeable, FlexibleContexts, FlexibleInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, OverloadedStrings, RecordWildCards, TemplateHaskell, TypeFamilies, TypeSynonymInstances, OverloadedStrings #-} {-# OPTIONS_GHC -F -pgmFhsx2hs #-} module Pages ( route ) where import Data.Text (Text) import qualified Data.Text as Text (null) import qualified Data.Text.Lazy as Lazy (pack) import Data.Time.Clock (getCurrentTime) import Events (GetPasteById(GetPasteById), GetRecentPastes(GetRecentPastes), InsertPaste(InsertPaste)) import Happstack.Foundation ((++>), (<$>), (<++), Applicative((<*), (<*>)), asContentType, Attr((:=)), EmbedAsAttr(asAttr), EmbedAsChild(asChild), errorList, fieldset, form, fromStringLit, inputSubmit, inputText, label, li, method, Method(GET), MonadIO(liftIO), notFound, ok, query, reform, Response, seeOtherURL, select, serveFile, textarea, transformEither, transformEitherM, ul, update, whereami, XML, XMLGen(genElement)) import Route (CtrlV, CtrlVForm, Route(..)) import Template (appTemplate) import Types (Format(..), Paste(..), PasteId(..), PasteMeta(PasteMeta, format, nickname, pasteId, pasted, title)) ------------------------------------------------------------------------------ -- Pages ------------------------------------------------------------------------------ -- | page handler for 'ViewRecent' viewRecentPage :: CtrlV Response viewRecentPage = do method GET recent <- query (GetRecentPastes 20 0) case recent of [] -> appTemplate "Recent Pastes" ()
There are no pastes yet.
_ -> appTemplate "Recent Pastes" () $ <%>| id | title | author | date | format |
|---|
Paste <% pid %> could not be found.
(Just (Paste (PasteMeta{..}) paste)) -> do ok () appTemplate (Lazy.pack $ "Paste " ++ (show $ unPasteId pid)) () $<% txt %>-- | page handler for 'NewPaste' newPastePage :: CtrlV Response newPastePage = do here <- whereami appTemplate "Add a Paste" () $ <%>