From b978bcc2bbaffc58d329bbd826a500e77934a910 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 10 Apr 2014 12:46:37 +0300 Subject: [PATCH] Initial Stackage upload code --- Application.hs | 1 + Model.hs | 6 ++---- Types.hs | 3 ++- config/models | 8 ++++++++ config/routes | 1 + stackage-server.cabal | 9 +++++++++ templates/homepage.hamlet | 7 +++++++ 7 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Application.hs b/Application.hs index daadee9..ee7807e 100644 --- a/Application.hs +++ b/Application.hs @@ -34,6 +34,7 @@ import Handler.Profile import Handler.Email import Handler.ResetToken import Handler.HackageSdist +import Handler.UploadStackage -- This line actually creates our YesodDispatch instance. It is the second half -- of the call to mkYesodData which occurs in Foundation.hs. Please see the diff --git a/Model.hs b/Model.hs index 36ed1cb..aa0f581 100644 --- a/Model.hs +++ b/Model.hs @@ -1,11 +1,9 @@ module Model where -import Prelude -import Yesod -import Data.Text (Text) +import ClassyPrelude.Yesod import Database.Persist.Quasi -import Data.Typeable (Typeable) import Data.Slug (Slug) +import Types -- You can define all of your database entities in the entities file. -- You can find more information on persistent and how to declare entities diff --git a/Types.hs b/Types.hs index 4475b4c..09b5294 100644 --- a/Types.hs +++ b/Types.hs @@ -3,13 +3,14 @@ module Types where import ClassyPrelude.Yesod import Data.BlobStore (ToPath (..)) import Text.Blaze (ToMarkup) +import Database.Persist.Sql (PersistFieldSql) newtype PackageName = PackageName { unPackageName :: Text } deriving (Show, Read, Typeable, Eq, Ord, Hashable, PathPiece, ToMarkup) newtype Version = Version { unVersion :: Text } deriving (Show, Read, Typeable, Eq, Ord, Hashable, PathPiece, ToMarkup) newtype PackageSetIdent = PackageSetIdent { unPackageSetIdent :: Text } - deriving (Show, Read, Typeable, Eq, Ord, Hashable, PathPiece, ToMarkup) + deriving (Show, Read, Typeable, Eq, Ord, Hashable, PathPiece, ToMarkup, PersistField, PersistFieldSql) data StoreKey = HackageCabal !PackageName !Version | HackageSdist !PackageName !Version diff --git a/config/models b/config/models index f4ef0c5..d448040 100644 --- a/config/models +++ b/config/models @@ -13,3 +13,11 @@ Email Verkey email Text verkey Text + +Stackage + user UserId + ident PackageSetIdent + uploaded UTCTime + title Text + desc Text + UniqueStackage ident diff --git a/config/routes b/config/routes index 3bda7b4..899e216 100644 --- a/config/routes +++ b/config/routes @@ -9,3 +9,4 @@ /email/#EmailId EmailR DELETE /reset-token ResetTokenR POST /hackage/#PackageName/#Version HackageSdistR GET +/upload UploadStackageR GET PUT diff --git a/stackage-server.cabal b/stackage-server.cabal index 7df4fee..bc349a8 100644 --- a/stackage-server.cabal +++ b/stackage-server.cabal @@ -28,6 +28,7 @@ library Handler.Email Handler.ResetToken Handler.HackageSdist + Handler.UploadStackage if flag(dev) || flag(library-only) cpp-options: -DDEVELOPMENT @@ -88,10 +89,18 @@ library , blaze-markup >= 0.6 && < 0.7 , ghc-prim , system-fileio + , system-filepath , resourcet , aws >= 0.9 && < 0.10 , conduit-extra , tar >= 0.4 && < 0.5 + , temporary >= 1.2 && < 1.3 + , cryptohash-conduit >= 0.1.1 && < 0.2 + , exceptions + , byteable + , cryptohash + , base64-bytestring + , zlib executable stackage-server if flag(library-only) diff --git a/templates/homepage.hamlet b/templates/homepage.hamlet index e69de29..4dd9420 100644 --- a/templates/homepage.hamlet +++ b/templates/homepage.hamlet @@ -0,0 +1,7 @@ +

Browse stackages + +FIXME! + +

Upload + +Upload