summaryrefslogtreecommitdiff
path: root/Biz/Devalloc/Host.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Devalloc/Host.hs')
-rw-r--r--Biz/Devalloc/Host.hs135
1 files changed, 86 insertions, 49 deletions
diff --git a/Biz/Devalloc/Host.hs b/Biz/Devalloc/Host.hs
index c6c6724..ce73cd5 100644
--- a/Biz/Devalloc/Host.hs
+++ b/Biz/Devalloc/Host.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
@@ -14,9 +15,9 @@
-- : sys cmark
-- : dep envy
-- : dep lucid
--- : dep miso
-- : dep protolude
-- : dep servant
+-- : dep servant-lucid
-- : dep servant-server
-- : dep warp
module Biz.Devalloc.Host
@@ -29,19 +30,18 @@ import Biz.App (CSS (..), HtmlApp (..))
-- import qualified CMark as Cmark
import qualified Biz.Look
-import qualified Biz.Devalloc.Core as Core
-import qualified Biz.Devalloc.Path as Path
import qualified Clay
import qualified Control.Exception as Exception
import qualified Data.Text as Text
import qualified Lucid
import qualified Lucid.Base as Lucid
-import Miso hiding (node)
+import qualified Lucid.Servant as Lucid
import qualified Network.Wai as Wai
+import Network.Wai.Application.Static (defaultWebAppSettings)
import qualified Network.Wai.Handler.Warp as Warp
import Network.Wai.Middleware.RequestLogger (logStdout)
-import Network.Wai.Application.Static (defaultWebAppSettings)
import Servant
+import Servant.HTML.Lucid
import qualified System.Envy as Envy
main :: IO ()
@@ -54,30 +54,38 @@ main = Exception.bracket startup shutdown run
putText "@"
putText "devalloc"
putText <| "port: " <> (show <| port cfg)
- putText <| "node: " <> (Text.pack <| node cfg)
- let static = serveDirectoryWith <| defaultWebAppSettings <| node cfg
- return (cfg, serve (Proxy @AllPaths) <| serverHandlers static)
+ return (cfg, serve (Proxy @AllPaths) <| paths cfg)
shutdown :: (Config, Application) -> IO ()
shutdown _ = pure ()
run :: (Config, Wai.Application) -> IO ()
run (cfg, app) = Warp.run (port cfg) (logStdout app)
-type HostPaths = ToServerRoutes Path.Paths HtmlApp Core.Move
-
-type AllPaths = ("static" :> Raw) :<|> HostPaths :<|> CssRoute
+data Config = Config
+ { port :: Warp.Port,
+ -- | A yaml file of pitches
+ pitches :: FilePath,
+ assets :: FilePath
+ }
+ deriving (Generic, Show)
-type CssRoute = "css" :> "main.css" :> Get '[CSS] Text
+instance Envy.DefConfig Config where
+ defConfig =
+ Config
+ { port = 3000,
+ pitches = "./Biz/Devalloc/pitch.md",
+ assets = "_/bild/dev/static/devalloc.js"
+ }
-cssHandlers :: Server CssRoute
-cssHandlers = return . toStrict <| Clay.render look
+instance Envy.FromEnv Config
+-- | Wraps pages in default HTML
instance Lucid.ToHtml a => Lucid.ToHtml (HtmlApp a) where
toHtmlRaw = Lucid.toHtml
toHtml (HtmlApp x) =
Lucid.doctypehtml_ <| do
Lucid.head_ <| do
Lucid.meta_ [Lucid.charset_ "utf-8"]
- jsRef "/static/all.js"
+ jsRef "//unpkg.com/turbolinks@5.2.0/dist/turbolinks.js"
cssRef "/css/main.css"
Lucid.body_ (Lucid.toHtml x)
where
@@ -96,42 +104,71 @@ instance Lucid.ToHtml a => Lucid.ToHtml (HtmlApp a) where
Lucid.href_ _href
]
-data Config = Config
- { port :: Warp.Port,
- -- | A yaml file of pitches
- pitches :: FilePath,
- node :: FilePath
- }
- deriving (Generic, Show)
+-- * paths and pages
-instance Envy.DefConfig Config where
- defConfig =
- Config
- { port = 3000,
- pitches = "./Biz/Devalloc/pitch.md",
- node = "_/bild/dev/static/devalloc.js"
- }
+type AllPaths =
+ Get '[HTML] (HtmlApp Path)
+ :<|> Signup
+ :<|> ("static" :> Raw)
+ :<|> "css" :> "main.css" :> Get '[CSS] Text
-instance Envy.FromEnv Config
+type Signup = "signup" :> Get '[HTML] (HtmlApp Path)
+
+paths :: Config -> Server AllPaths
+paths cfg =
+ path Home
+ :<|> path Signup
+ :<|> static
+ :<|> look
+ where
+ path = pure . HtmlApp
+ static = serveDirectoryWith <| defaultWebAppSettings <| assets cfg
+ look =
+ return . toStrict . Clay.render <| do
+ Biz.Look.fuckingStyle
+ "body" Clay.? Biz.Look.fontStack
+
+data Path
+ = Home
+ | Signup
+
+instance Lucid.ToHtml Path where
+ toHtmlRaw = Lucid.toHtml
+ toHtml = \case
+ Home -> Lucid.toHtml pitch
+ Signup -> Lucid.toHtml signup
-home :: Handler (HtmlApp (View Core.Move))
-home =
- Core.Form {Core.uri = Path.home}
- |> Core.view
- |> HtmlApp
- |> pure
+-- * parts
-signup :: Handler (HtmlApp (View Core.Move))
+signup :: Lucid.Html ()
signup =
- Core.Form {Core.uri = Path.signup}
- |> Core.view
- |> HtmlApp
- |> pure
-
-serverHandlers :: Tagged Handler Application -> Server AllPaths
-serverHandlers static = static :<|> (home :<|> signup) :<|> cssHandlers
-
-look :: Clay.Css
-look = do
- Biz.Look.fuckingStyle
- "body" Clay.? Biz.Look.fontStack
+ Lucid.p_ <| Lucid.a_ [Lucid.href_ "mailto:ben@bsima.me?subject=Devalloc+signup"] "Request access via email"
+
+pitch :: Lucid.Html ()
+pitch =
+ Lucid.div_ <| do
+ Lucid.h1_ "Devalloc"
+ Lucid.p_
+ "Devalloc analyzes your codebase trends, finds patterns \
+ \ in how your developers work, and protects against tech debt."
+ Lucid.p_ "Just hook it up to your CI system - it will warn you when it finds a problem."
+ Lucid.a_ [Lucid.safeHref_ "/" (Proxy :: Proxy AllPaths) (Proxy :: Proxy Signup)]
+ "Go to signup"
+ Lucid.h2_ "Identify blackholes in your codebase"
+ Lucid.p_
+ "What if none of your active employees have touched some part of the codebase? \
+ \ This happens too often with legacy code, and then it turns into a huge source of tech debt. \
+ \ Devalloc finds these \"blackholes\" and warns you about them so you can be proactive in eliminating tech debt."
+ Lucid.h2_ "Protect against lost knowledge"
+ Lucid.p_ "Not everyone can know every part of a codebase. By finding pieces of code that only 1 or 2 people have touched, devalloc identifes siloed knowledge. This allows you to protect against the risk of this knowledge leaving the company if an employee leaves."
+ Lucid.h2_ "Don't just measure code coverage - also know your dev coverage"
+ Lucid.p_ "No matter how smart your employees are, if you are under- or over-utilizing your developers then you will never get optimal performance from your team."
+ Lucid.ul_ <| do
+ Lucid.li_ "Find developer hot spots in your code: which pieces of code get continually rewritten, taking up valuable dev time?"
+ Lucid.li_ "Know how your devs work best: which ones have depth of knowledge, and which ones have breadth?"
+
+ Lucid.p_ "(Paid only)"
+ Lucid.h2_ "See how your teams *actually* organize themselves with cluster analysis"
+ Lucid.p_ "Does your team feel splintered or not cohesive? Which developers work best together? Devalloc analyzes the collaboration patterns between devs and helps you form optimal pairings and teams based on shared code and mindspace."
+ Lucid.p_ "(Paid only)"
+ signup