From 52331eeadce8d250564851c25fc965172640bc55 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 12 Oct 2019 11:23:10 +0200 Subject: Implement client routing --- server/src/Controller/Index.hs | 2 +- server/src/Design/View/Header.hs | 7 +++++-- server/src/Design/View/NotFound.hs | 21 +++++++++++++++++++++ server/src/Design/Views.hs | 21 +++++++++++---------- server/src/Main.hs | 36 ++++++++++++++++++++---------------- 5 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 server/src/Design/View/NotFound.hs (limited to 'server/src') diff --git a/server/src/Controller/Index.hs b/server/src/Controller/Index.hs index fbda527..5ebe921 100644 --- a/server/src/Controller/Index.hs +++ b/server/src/Controller/Index.hs @@ -57,7 +57,7 @@ askSignIn conf form = let url = T.concat [ if Conf.https conf then "https://" else "http://", Conf.hostname conf, - "/signIn/", + "/api/signIn/", token ] maybeSentMail <- liftIO . SendMail.sendMail conf $ SignIn.mail conf user url [email] diff --git a/server/src/Design/View/Header.hs b/server/src/Design/View/Header.hs index 2422686..59e0e51 100644 --- a/server/src/Design/View/Header.hs +++ b/server/src/Design/View/Header.hs @@ -40,8 +40,11 @@ design = do ".current" & backgroundColor (Color.chestnutRose -. 20) Media.mobile $ fontSize (px 13) - (".item" # hover) <> (".item" # focus) ? backgroundColor (Color.chestnutRose +. 10) - (".item.current" # hover) <> (".item.current" # focus) ? backgroundColor (Color.chestnutRose -. 10) + (".item" # hover) <> (".item" # focus) ? + backgroundColor (Color.chestnutRose +. 10) + + (".item.current" # hover) <> (".item.current" # focus) ? + backgroundColor (Color.chestnutRose -. 10) ".nameSignOut" ? do display flex diff --git a/server/src/Design/View/NotFound.hs b/server/src/Design/View/NotFound.hs new file mode 100644 index 0000000..150c6fc --- /dev/null +++ b/server/src/Design/View/NotFound.hs @@ -0,0 +1,21 @@ +module Design.View.NotFound + ( design + ) where + +import Clay +import Prelude hiding (rem) + +import qualified Design.Color as Color + +design :: Css +design = do + + marginLeft (rem 3) + + ".link" ? do + display block + marginTop (rem 1) + color Color.chestnutRose + textDecoration underline + hover & + color (Color.chestnutRose +. 15) diff --git a/server/src/Design/Views.hs b/server/src/Design/Views.hs index b9e3cf8..bf39cff 100644 --- a/server/src/Design/Views.hs +++ b/server/src/Design/Views.hs @@ -4,16 +4,16 @@ module Design.Views import Clay -import qualified Design.View.Header as Header -import qualified Design.View.Payment as Payment -import qualified Design.View.SignIn as SignIn -import qualified Design.View.Stat as Stat -import qualified Design.View.Table as Table - -import qualified Design.Color as Color -import qualified Design.Constants as Constants -import qualified Design.Helper as Helper -import qualified Design.Media as Media +import qualified Design.Color as Color +import qualified Design.Constants as Constants +import qualified Design.Helper as Helper +import qualified Design.Media as Media +import qualified Design.View.Header as Header +import qualified Design.View.NotFound as NotFound +import qualified Design.View.Payment as Payment +import qualified Design.View.SignIn as SignIn +import qualified Design.View.Stat as Stat +import qualified Design.View.Table as Table design :: Css design = do @@ -21,6 +21,7 @@ design = do ".payment" ? Payment.design ".signIn" ? SignIn.design ".stat" ? Stat.design + ".notfound" ? NotFound.design Table.design ".withMargin" ? do diff --git a/server/src/Main.hs b/server/src/Main.hs index 0ccf5e2..e3dad9e 100644 --- a/server/src/Main.hs +++ b/server/src/Main.hs @@ -15,48 +15,52 @@ main = do conf <- Conf.get "application.conf" _ <- runDaemons conf S.scotty (Conf.port conf) $ do - S.middleware $ W.gzip $ W.def { W.gzipFiles = GzipCompress } - S.middleware . staticPolicy $ noDots >-> addBase "public" - S.get "/" $ do - Index.get conf + S.middleware $ + W.gzip $ W.def { W.gzipFiles = GzipCompress } + + S.middleware . staticPolicy $ + noDots >-> addBase "public" - S.post "/askSignIn" $ do + S.post "/api/askSignIn" $ S.jsonData >>= Index.askSignIn conf - S.get "/signIn/:signInToken" $ do + S.get "/api/signIn/:signInToken" $ do signInToken <- S.param "signInToken" Index.trySignIn conf signInToken - S.post "/signOut" $ + S.post "/api/signOut" $ Index.signOut conf - S.post "/payment" $ + S.post "/api/payment" $ S.jsonData >>= Payment.create - S.put "/payment" $ + S.put "/api/payment" $ S.jsonData >>= Payment.edit - S.delete "/payment/:id" $ do + S.delete "/api/payment/:id" $ do paymentId <- S.param "id" Payment.delete paymentId - S.post "/income" $ + S.post "/api/income" $ S.jsonData >>= Income.create - S.put "/income" $ + S.put "/api/income" $ S.jsonData >>= Income.edit - S.delete "/income/:id" $ do + S.delete "/api/income/:id" $ do incomeId <- S.param "id" Income.delete incomeId - S.post "/category" $ + S.post "/api/category" $ S.jsonData >>= Category.create - S.put "/category" $ + S.put "/api/category" $ S.jsonData >>= Category.edit - S.delete "/category/:id" $ do + S.delete "/api/category/:id" $ do categoryId <- S.param "id" Category.delete categoryId + + S.notFound $ + Index.get conf -- cgit v1.2.3