From 4814d994dc3e8942c122e092f234e3382c773eda Mon Sep 17 00:00:00 2001 From: Chris Done Date: Sun, 1 Jun 2014 13:35:10 +0200 Subject: [PATCH] Start of implementation of wireframe --- Application.hs | 6 +-- Foundation.hs | 1 + Handler/Snapshots.hs | 29 ++++++++++ config/routes | 1 + stackage-server.cabal | 1 + templates/all-snapshots.hamlet | 7 +++ templates/default-layout-wrapper.hamlet | 7 ++- templates/default-layout.hamlet | 48 ++++++++++------- templates/default-layout.julius | 0 templates/default-layout.lucius | 17 +++++- templates/homepage.hamlet | 22 ++++---- templates/profile.hamlet | 71 +++++++++++++------------ templates/upload-stackage.hamlet | 9 ++-- 13 files changed, 141 insertions(+), 78 deletions(-) create mode 100644 Handler/Snapshots.hs create mode 100644 templates/all-snapshots.hamlet create mode 100644 templates/default-layout.julius diff --git a/Application.hs b/Application.hs index c73e8f8..702d2e2 100644 --- a/Application.hs +++ b/Application.hs @@ -39,6 +39,7 @@ import qualified Echo -- Import all relevant handler modules here. -- Don't forget to add new modules to your cabal file! import Handler.Home +import Handler.Snapshots import Handler.Profile import Handler.Email import Handler.ResetToken @@ -152,7 +153,7 @@ makeFoundation useEcho conf = do (messageLoggerSource foundation logger) -- Start the cabal file loader - void $ forkIO $ forever $ flip runLoggingT (messageLoggerSource foundation logger) $ do + {-void $ forkIO $ forever $ flip runLoggingT (messageLoggerSource foundation logger) $ do $logInfoS "CLEANUP" "Cleaning up /tmp" now <- liftIO getCurrentTime runResourceT $ sourceDirectory "/tmp" $$ mapM_C (cleanupTemp now) @@ -180,8 +181,7 @@ makeFoundation useEcho conf = do case eres of Left e -> $logError $ tshow e Right () -> return () - liftIO $ threadDelay $ 30 * 60 * 1000000 - + liftIO $ threadDelay $ 30 * 60 * 1000000 -} return foundation cleanupTemp :: UTCTime -> FilePath -> ResourceT (LoggingT IO) () diff --git a/Foundation.hs b/Foundation.hs index 144154b..f472812 100644 --- a/Foundation.hs +++ b/Foundation.hs @@ -87,6 +87,7 @@ instance Yesod App where -- value passed to hamletToRepHtml cannot be a widget, this allows -- you to use normal widget features in default-layout. + cur <- getCurrentRoute pc <- widgetToPageContent $ do $(combineStylesheets 'StaticR [ css_normalize_css diff --git a/Handler/Snapshots.hs b/Handler/Snapshots.hs new file mode 100644 index 0000000..14e40c7 --- /dev/null +++ b/Handler/Snapshots.hs @@ -0,0 +1,29 @@ +{-# LANGUAGE TupleSections, OverloadedStrings #-} + +module Handler.Snapshots where + +import Import +import qualified Database.Esqueleto as E + +-- This is a handler function for the GET request method on the HomeR +-- resource pattern. All of your resource patterns are defined in +-- config/routes +-- +-- The majority of the code you will write in Yesod lives in these handler +-- functions. You can spread them across multiple files if you are so +-- inclined, or create a single monolithic file. +getAllSnapshotsR :: Handler Html +getAllSnapshotsR = do + stackages <- runDB $ E.select $ E.from $ \(stackage `E.InnerJoin` user) -> do + E.on (stackage E.^. StackageUser E.==. user E.^. UserId) + E.orderBy [E.desc $ stackage E.^. StackageUploaded] + return + ( stackage E.^. StackageIdent + , stackage E.^. StackageTitle + , stackage E.^. StackageUploaded + , user E.^. UserDisplay + , user E.^. UserHandle + ) + defaultLayout $ do + setTitle "Stackage Server" + $(widgetFile "all-snapshots") diff --git a/config/routes b/config/routes index 16c9f92..64dafa0 100644 --- a/config/routes +++ b/config/routes @@ -5,6 +5,7 @@ /robots.txt RobotsR GET / HomeR GET +/snapshots AllSnapshotsR GET /profile ProfileR GET PUT /email/#EmailId EmailR DELETE /reset-token ResetTokenR POST diff --git a/stackage-server.cabal b/stackage-server.cabal index fafe7a6..890cffc 100644 --- a/stackage-server.cabal +++ b/stackage-server.cabal @@ -25,6 +25,7 @@ library Data.Hackage.Views Types Handler.Home + Handler.Snapshots Handler.Profile Handler.Email Handler.ResetToken diff --git a/templates/all-snapshots.hamlet b/templates/all-snapshots.hamlet new file mode 100644 index 0000000..94ff5a8 --- /dev/null +++ b/templates/all-snapshots.hamlet @@ -0,0 +1,7 @@ +
+