From 2f32da5812583c6675bdc9ff88a3a3d5cefbb82f Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 25 Jul 2020 15:40:24 -0700 Subject: hero: rename Assets -> Pack and lint fixes --- Hero/Assets.hs | 16 --------------- Hero/Core.hs | 52 ++++++++++++++++++++++++------------------------- Hero/Host.hs | 21 ++++++++------------ Hero/Look/Typography.hs | 4 ++-- Hero/Pack.hs | 16 +++++++++++++++ 5 files changed, 52 insertions(+), 57 deletions(-) delete mode 100644 Hero/Assets.hs create mode 100644 Hero/Pack.hs (limited to 'Hero') diff --git a/Hero/Assets.hs b/Hero/Assets.hs deleted file mode 100644 index 2e2d72c..0000000 --- a/Hero/Assets.hs +++ /dev/null @@ -1,16 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE NoImplicitPrelude #-} - --- | A module to wrap the CDN and provide convient helper functions to assets. -module Hero.Assets where - -import Protolude - -cdnEdge :: Text -cdnEdge = "https://heroverse.sfo2.cdn.digitaloceanspaces.com" - -demo :: Text -demo = cdnEdge <> "/old-assets/demo/" - -icon :: Text -icon = cdnEdge <> "/icons/" diff --git a/Hero/Core.hs b/Hero/Core.hs index 3870c59..9f67bd7 100644 --- a/Hero/Core.hs +++ b/Hero/Core.hs @@ -30,9 +30,9 @@ import Data.String.Quote import Data.Text (Text, replace, toLower) import GHC.Generics (Generic) import qualified GHC.Show as Legacy -import qualified Hero.Assets as Assets import Hero.Look as Look import Hero.Look.Typography +import qualified Hero.Pack as Pack import Miso import qualified Miso (for_) import Miso.Extend @@ -145,49 +145,49 @@ instance Elemental Button where el (Arrow act) = button_ [class_ "button is-large turn-page", onClick act] - [img_ [src_ $ ms $ Assets.demo <> image <> ".png"]] + [img_ [src_ $ ms $ Pack.demo <> image <> ".png"]] where image = case act of PrevPage -> "prev-page" NextPage -> "next-page" _ -> "prev-page" el (Save c u) = - if c `elem` (userLibrary u) -- in library + if c `elem` userLibrary u -- in library then a_ [class_ "wrs-button saved", onClick $ ToggleInLibrary c] - [ img_ [src_ $ ms $ Assets.icon <> "save.svg"], + [ img_ [src_ $ ms $ Pack.icon <> "save.svg"], span_ [] [text "saved"] ] else-- not in library a_ [class_ "wrs-button", onClick $ ToggleInLibrary c] - [ img_ [src_ $ ms $ Assets.icon <> "save.svg"], + [ img_ [src_ $ ms $ Pack.icon <> "save.svg"], span_ [] [text "save"] ] el (SaveIcon c u) = - if c `elem` (userLibrary u) -- in library + if c `elem` userLibrary u -- in library then button_ [ class_ "button is-large has-background-black", onClick $ ToggleInLibrary c ] - [img_ [src_ $ ms $ Assets.demo <> "library-add.png"]] + [img_ [src_ $ ms $ Pack.demo <> "library-add.png"]] else-- not in library button_ [ class_ "button is-large has-background-black-bis", onClick $ ToggleInLibrary c ] - [img_ [src_ $ ms $ Assets.demo <> "library-add.png"]] + [img_ [src_ $ ms $ Pack.demo <> "library-add.png"]] el (ZoomIcon zmodel comic page) = button_ [ id_ "zoom-button", class_ "button is-large", onClick $ ToggleZoom comic page ] - [ img_ [src_ $ ms $ Assets.demo <> "zoom.png"], + [ img_ [src_ $ ms $ Pack.demo <> "zoom.png"], input_ [ type_ "range", min_ "0", @@ -204,13 +204,13 @@ instance Elemental Button where el (Read c) = a_ [class_ "wrs-button", onClick $ SelectExperience c] - [ img_ [src_ $ ms $ Assets.icon <> "read.svg"], + [ img_ [src_ $ ms $ Pack.icon <> "read.svg"], span_ [] [text "read"] ] el (Watch c) = a_ [class_ "wrs-button", onClick $ StartWatching c] - [ img_ [src_ $ ms $ Assets.icon <> "watch.svg"], + [ img_ [src_ $ ms $ Pack.icon <> "watch.svg"], span_ [] [text "watch"] ] @@ -378,7 +378,7 @@ login _ = [id_ "login-inner"] [ img_ [ class_ fadeIn, - src_ $ ms $ Assets.cdnEdge <> "/old-assets/images/icons/hero-large.png" + src_ $ ms $ Pack.cdnEdge <> "/old-assets/images/icons/hero-large.png" ], hr_ [class_ fadeIn], form_ @@ -406,7 +406,7 @@ login _ = img_ [ id_ "hero-logo", class_ "blur-out", - src_ $ ms $ Assets.cdnEdge <> "/old-assets/images/icons/success-her-image.png" + src_ $ ms $ Pack.cdnEdge <> "/old-assets/images/icons/success-her-image.png" ] ] ] @@ -468,7 +468,7 @@ discoverFooter = ], div_ [css euro, id_ "app-foot-logo", onClick DumpModel] - [ a_ [class_ "social-icon", href_ "#"] [img_ [src_ $ ms $ Assets.icon <> "hero-logo.svg"]], + [ a_ [class_ "social-icon", href_ "#"] [img_ [src_ $ ms $ Pack.icon <> "hero-logo.svg"]], span_ [] [text "© Hero Records, Inc. All Rights Reserved"] ] ] @@ -478,7 +478,7 @@ discoverFooter = smallImg x lnk = a_ (attrs lnk) - [img_ [src_ $ ms $ Assets.cdnEdge <> "/old-assets/images/icons/" <> x]] + [img_ [src_ $ ms $ Pack.cdnEdge <> "/old-assets/images/icons/" <> x]] -- * comic @@ -508,7 +508,7 @@ instance IsMediaObject Comic where id_ $ "comic-" <> ms comicId, onClick $ SetMediaInfo $ Just c ] - [ img_ [src_ $ ms $ Assets.demo <> comicSlug c <> ".png"], + [ img_ [src_ $ ms $ Pack.demo <> comicSlug c <> ".png"], span_ [] [text $ "Issue #" <> ms comicIssue], span_ [] [text $ ms comicName] ] @@ -518,7 +518,7 @@ instance IsMediaObject Comic where [id_ "featured-comic"] [ img_ [ id_ "featured-banner", - src_ $ ms $ Assets.demo <> "feature-banner.png" + src_ $ ms $ Pack.demo <> "feature-banner.png" ], div_ [id_ "featured-content"] @@ -532,7 +532,7 @@ instance IsMediaObject Comic where [ img_ [ src_ $ ms - $ Assets.demo <> comicSlug comic <> "-logo.png" + $ Pack.demo <> comicSlug comic <> "-logo.png" ] ], div_ [class_ "comic-action-menu"] $ @@ -548,7 +548,7 @@ instance IsMediaObject Comic where [class_ "media-info", css euro] [ div_ [class_ "media-info-meta"] - [ column [img_ [src_ $ ms $ Assets.demo <> "dmc-widethumb.png"]], + [ column [img_ [src_ $ ms $ Pack.demo <> "dmc-widethumb.png"]], column [ span_ [style_ title] [text $ ms comicName], span_ [style_ subtitle] [text $ "Issue #" <> ms comicIssue], @@ -625,7 +625,7 @@ chooseExperiencePage comic page model = [onClick $ StartReading c] [ div_ [] - [ img_ [src_ $ ms $ Assets.demo <> name <> ".png"], + [ img_ [src_ $ ms $ Pack.demo <> name <> ".png"], span_ [] [text $ ms name] ], span_ [css thicc] [text $ ms artist], @@ -685,7 +685,7 @@ zoomScreen comic page model = ] where comicImg = - ms Assets.demo + ms Pack.demo <> ms (comicSlug comic) <> "-" <> padLeft page @@ -726,13 +726,13 @@ comicSpread comic page model = where comicImgLeft, comicImgRight :: MisoString comicImgLeft = - ms Assets.demo + ms Pack.demo <> ms (comicSlug comic) <> "-" <> padLeft page <> ".png" comicImgRight = - ms Assets.demo + ms Pack.demo <> ms (comicSlug comic) <> "-" <> padLeft (1 + page) @@ -828,7 +828,7 @@ appmenu = aside_ [id_ "appmenu"] $ btn img], + [ img_ [src_ $ ms $ Pack.icon <> img], span_ [] [text label] ] @@ -878,7 +878,7 @@ comicControls comic page model = ] [ audio_ [id_ audioId, loop_ True, crossorigin_ "anonymous"] - [source_ [src_ $ ms $ Assets.demo <> "stars-instrumental.mp3"]], + [source_ [src_ $ ms $ Pack.demo <> "stars-instrumental.mp3"]], el $ PlayPause audioId $ cpAudioState model, span_ [css $ euro <> thicc <> smol <> wide] @@ -912,7 +912,7 @@ topbar = [ class_ "button is-medium is-black", onClick $ ChangeURI discoverLink ] - [img_ [src_ $ ms $ Assets.icon <> "hero-logo.svg"]], + [img_ [src_ $ ms $ Pack.icon <> "hero-logo.svg"]], div_ [id_ "app-head-right"] [ button_ diff --git a/Hero/Host.hs b/Hero/Host.hs index 267d475..285861d 100644 --- a/Hero/Host.hs +++ b/Hero/Host.hs @@ -1,15 +1,10 @@ {-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PolyKinds #-} -{-# LANGUAGE QuasiQuotes #-} -{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} @@ -61,11 +56,11 @@ import qualified Data.Acid.Abstract as Acid import qualified Data.Aeson as Aeson import Data.Text (Text) import qualified Data.Text.Lazy as Lazy -import qualified Hero.Assets as Assets import Hero.Core import qualified Hero.Keep as Keep import qualified Hero.Look as Look import qualified Hero.Look.Typography as Typography +import qualified Hero.Pack as Pack import qualified Lucid as L import Lucid.Base import Miso @@ -243,9 +238,9 @@ authHandler :: ) authHandler cookieSettings jwtSettings loginForm = case loginForm of - (LoginForm "ben@bsima.me" "test") -> do + (LoginForm "ben@bsima.me" "test") -> applyCreds $ User "ben@bsima.me" "ben" [] - (LoginForm "mcovino@heroprojects.io" "test") -> do + (LoginForm "mcovino@heroprojects.io" "test") -> applyCreds $ User "mcovino@heroprojects.io" "mike" [] _ -> throwError err401 where @@ -295,7 +290,7 @@ instance L.ToHtml a => L.ToHtml (Templated a) where [ L.rel_ "apple-touch-icon", L.sizes_ "180x180", L.href_ $ - Assets.cdnEdge + Pack.cdnEdge <> "/old-assets/images/favicons/apple-touch-icon.png" ] L.link_ @@ -303,7 +298,7 @@ instance L.ToHtml a => L.ToHtml (Templated a) where L.type_ "image/png", L.sizes_ "32x32", L.href_ $ - Assets.cdnEdge + Pack.cdnEdge <> "/old-assets/images/favicons/favicon-32x32.png" ] L.link_ @@ -311,19 +306,19 @@ instance L.ToHtml a => L.ToHtml (Templated a) where L.type_ "image/png", L.sizes_ "16x16", L.href_ $ - Assets.cdnEdge + Pack.cdnEdge <> "/old-assets/images/favicons/favicon-16x16.png" ] L.link_ [ L.rel_ "manifest", L.href_ $ - Assets.cdnEdge + Pack.cdnEdge <> "/old-assets/images/favicons/manifest.json" ] L.link_ [ L.rel_ "mask-icon", L.href_ $ - Assets.cdnEdge + Pack.cdnEdge <> "/old-assets/images/favicons/safari-pinned-tab.svg" ] L.meta_ [L.charset_ "utf-8"] diff --git a/Hero/Look/Typography.hs b/Hero/Look/Typography.hs index 6358ef3..d51cdbc 100644 --- a/Hero/Look/Typography.hs +++ b/Hero/Look/Typography.hs @@ -8,7 +8,7 @@ import Alpha import Clay import Clay.Stylesheet (key) import Data.Semigroup ((<>)) -import qualified Hero.Assets as Assets +import qualified Hero.Pack as Pack main :: Css main = fonts @@ -47,7 +47,7 @@ coat :: Double -> Css coat = fontSize . Clay.rem fontRoot :: Text -fontRoot = Assets.cdnEdge <> "/old-assets/fonts/eurostile/Eurostile" +fontRoot = Pack.cdnEdge <> "/old-assets/fonts/eurostile/Eurostile" -- | font faces fonts :: Css diff --git a/Hero/Pack.hs b/Hero/Pack.hs new file mode 100644 index 0000000..d5c3a35 --- /dev/null +++ b/Hero/Pack.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE NoImplicitPrelude #-} + +-- | A module to wrap the CDN and provide convient helper functions to assets. +module Hero.Pack where + +import Protolude + +cdnEdge :: Text +cdnEdge = "https://heroverse.sfo2.cdn.digitaloceanspaces.com" + +demo :: Text +demo = cdnEdge <> "/old-assets/demo/" + +icon :: Text +icon = cdnEdge <> "/icons/" -- cgit v1.2.3