feat(users/Profpatsch/whatcd-resolver): use stylize CSS

Gets rid of the giant bootstrap dependency and replaces it with a
little CSS file that formats our table nicely.

Change-Id: I3e0bb552481503679e7b229c4feaa4e9805f5eae
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13269
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
Profpatsch 2025-03-15 17:12:50 +01:00
parent 18f565567a
commit 10c8f3386b
2 changed files with 21 additions and 17 deletions

View file

@ -26,6 +26,14 @@ caseE2 m e2 = do
E21 a -> f1 $ getField @l1 a E21 a -> f1 $ getField @l1 a
E22 b -> f2 $ getField @l2 b E22 b -> f2 $ getField @l2 b
e21 :: forall l1 t1 l2 t2. LabelPrx l1 -> t1 -> E2 l1 t1 l2 t2
{-# INLINE e21 #-}
e21 LabelPrx a = E21 (label @l1 a)
e22 :: forall l1 t1 l2 t2. LabelPrx l2 -> t2 -> E2 l1 t1 l2 t2
{-# INLINE e22 #-}
e22 LabelPrx b = E22 (label @l2 b)
t2 :: forall l1 t1 l2 t2. LabelPrx l1 -> t1 -> LabelPrx l2 -> t2 -> T2 l1 t1 l2 t2 t2 :: forall l1 t1 l2 t2. LabelPrx l1 -> t1 -> LabelPrx l2 -> t2 -> T2 l1 t1 l2 t2
{-# INLINE t2 #-} {-# INLINE t2 #-}
t2 LabelPrx a LabelPrx b = T2 (label @l1 a) (label @l2 b) t2 LabelPrx a LabelPrx b = T2 (label @l1 a) (label @l2 b)

View file

@ -515,20 +515,13 @@ prefetchHtmlIntegrities :: (MonadOtel m, MonadThrow m) => m (OurHtmlIntegrities
prefetchHtmlIntegrities = do prefetchHtmlIntegrities = do
let resources = let resources =
[ HtmlIntegrity [ HtmlIntegrity
{ integrityName = "Bootstrap CSS", { integrityName = "Stylize CSS",
integrityUrl = "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css", integrityUrl = "https://raw.githubusercontent.com/vasanthv/stylize.css/master/stylize.css",
integrityHash = "sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM", integrityHash = "sha384-EsaVGfq7QMIquv7LCLomD9pQFZbPh2fOY3gcgN9MW/AlV2aQk/miZ1/EbrcwMr67",
localPath = "resources/bootstrap.min.css", localPath = "resources/stylize.css",
provideSourceMap = True, provideSourceMap = False,
isTag = E21 (label @"link" ()) isTag = e21 #link (),
}, ignoreUpstreamContentType = True
HtmlIntegrity
{ integrityName = "Bootstrap JS",
integrityUrl = "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js",
integrityHash = "sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz",
localPath = "resources/bootstrap.bundle.min.js",
provideSourceMap = True,
isTag = E22 (label @"script" ())
}, },
HtmlIntegrity HtmlIntegrity
{ integrityName = "htmx", { integrityName = "htmx",
@ -536,7 +529,8 @@ prefetchHtmlIntegrities = do
integrityHash = "sha384-L6OqL9pRWyyFU3+/bjdSri+iIphTN/bvYyM37tICVyOJkWZLpP2vGn6VUEXgzg6h", integrityHash = "sha384-L6OqL9pRWyyFU3+/bjdSri+iIphTN/bvYyM37tICVyOJkWZLpP2vGn6VUEXgzg6h",
localPath = "resources/htmx.js", localPath = "resources/htmx.js",
provideSourceMap = False, provideSourceMap = False,
isTag = E22 (label @"script" ()) isTag = e22 #script (),
ignoreUpstreamContentType = False
} }
] ]
resources resources
@ -1425,7 +1419,9 @@ data HtmlIntegrity = HtmlIntegrity
-- | Whether there is a resource map at the URL + `.map` -- | Whether there is a resource map at the URL + `.map`
provideSourceMap :: Bool, provideSourceMap :: Bool,
-- | is @<link>@ or @<script>@ tag? -- | is @<link>@ or @<script>@ tag?
isTag :: E2 "link" () "script" () isTag :: E2 "link" () "script" (),
-- | ignore upstream content type
ignoreUpstreamContentType :: Bool
} }
-- | Fetch a resource, calculate its integrity hash, and return a html @<link>@ snippet and a handler to return the resource. -- | Fetch a resource, calculate its integrity hash, and return a html @<link>@ snippet and a handler to return the resource.
@ -1504,7 +1500,7 @@ prefetchResourceIntegrity dat = inSpan' [fmt|prefetching resource {dat.integrity
Wai.responseLBS Wai.responseLBS
Http.ok200 Http.ok200
[ ( "Content-Type", [ ( "Content-Type",
mContentType (if dat.ignoreUpstreamContentType then mempty else mContentType)
& fromMaybe & fromMaybe
( tagMatch ( tagMatch
#script #script