From dee8c3aafb41d984bc69274ed320272ee7ee2bbf Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sun, 6 Dec 2020 12:05:58 -0500 Subject: Remove Miso from Devalloc I decided to finish the Devalloc frontend by just removing it. This way I can have everything in one file, the code is much simpler, and I can scale up as needed. Anyway, this works fine with Turbolinks and that's pretty cool, so you get the same basic feel as with any other SPA. --- Biz/Devalloc/Core.hs | 86 -------------------------------- Biz/Devalloc/Host.hs | 135 ++++++++++++++++++++++++++++++++------------------- Biz/Devalloc/Node.hs | 32 ------------ Biz/Devalloc/Path.hs | 27 ----------- 4 files changed, 86 insertions(+), 194 deletions(-) delete mode 100644 Biz/Devalloc/Core.hs delete mode 100644 Biz/Devalloc/Node.hs delete mode 100644 Biz/Devalloc/Path.hs (limited to 'Biz/Devalloc') diff --git a/Biz/Devalloc/Core.hs b/Biz/Devalloc/Core.hs deleted file mode 100644 index a56c386..0000000 --- a/Biz/Devalloc/Core.hs +++ /dev/null @@ -1,86 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TypeOperators #-} -{-# LANGUAGE DataKinds #-} - -module Biz.Devalloc.Core - ( Form (..), - Move (..), - make, - signup, - view, - ) -where - -import Alpha -import Miso hiding (view) -import qualified Miso.String -import Servant.API -import Servant.Links (URI) - -data Move - = NoOp - | ChangeURI URI - -newtype Form = Form {uri :: URI} - deriving (Eq) - -make :: URI -> Form -make uri = Form uri - -signup :: View Move -signup = - p_ - [] - [ a_ - [href_ "mailto:ben@bsima.me?subject=Devalloc+signup"] - [text "Request access via email"] - ] - - -view :: Form -> View Move -view _ = - div_ - [] - [ h1_ [] [text "Devalloc"], - p_ - [] - [ text - "Devalloc analyzes your codebase trends, finds patterns \ - \ in how your developers work, and protects against tech debt." - ], - p_ [] [text "Just hook it up to your CI system - it will warn you when it finds a problem."], - signup, - h2_ [] [text "Identify blackholes in your codebase"], - p_ - [] - [ text - <| Miso.String.intercalate - " " - [ "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." - ] - ], - h2_ - [] - [text "Protect against lost knowledge"], - p_ - [] - [text "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."], - h2_ - [] - [text "Don't just measure code coverage - also know your dev coverage"], - p_ - [] - [text "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."], - ul_ - [] - [ li_ [] [text "Find developer hot spots in your code: which pieces of code get continually rewritten, taking up valuable dev time?"], - li_ [] [text "Know how your devs work best: which ones have depth of knowledge, and which ones have breadth?"] - ], - p_ [] [text "(Paid only)"], - h2_ [] [text "See how your teams *actually* organize themselves with cluster analysis"], - p_ [] [text "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."], - p_ [] [text "(Paid only)"], - signup - ] 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 diff --git a/Biz/Devalloc/Node.hs b/Biz/Devalloc/Node.hs deleted file mode 100644 index 51acbf1..0000000 --- a/Biz/Devalloc/Node.hs +++ /dev/null @@ -1,32 +0,0 @@ -{-# LANGUAGE NoImplicitPrelude #-} -{-# LANGUAGE RecordWildCards #-} - --- : out devalloc.js --- --- : dep clay --- : dep ghcjs-base --- : dep miso --- : dep potolude --- : dep servant --- : dep text -module Biz.Devalloc.Node (main) where - -import Alpha -import qualified Biz.Devalloc.Core as Core -import Miso - -main :: IO () -main = miso <| \currentURI -> App {model = Core.make currentURI, ..} - where - update = move - view = view - subs = [] - events = defaultEvents - initialAction = Core.NoOp - mountPoint = Nothing - -move :: Core.Move -> Core.Form -> Effect Core.Move Core.Form -move mov form = case mov of - Core.NoOp -> noEff form - Core.ChangeURI u -> form <# (pushURI u >> pure Core.NoOp) - diff --git a/Biz/Devalloc/Path.hs b/Biz/Devalloc/Path.hs deleted file mode 100644 index 1463fc4..0000000 --- a/Biz/Devalloc/Path.hs +++ /dev/null @@ -1,27 +0,0 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TypeOperators #-} - -module Biz.Devalloc.Path - ( Paths, - home, - signup, - ) -where - -import Alpha -import qualified Biz.Devalloc.Core as Core -import Miso -import Servant - -type Paths = Home :<|> Signup - -type Home = View Core.Move - -type Signup = "signup" :> View Core.Move - -home :: URI -home = linkURI <| safeLink (Proxy :: Proxy Paths) (Proxy :: Proxy Home) - -signup :: URI -signup = linkURI <| safeLink (Proxy :: Proxy Paths) (Proxy :: Proxy Signup) -- cgit v1.2.3