feat(users/Profpatsch/whatcd-resolver): also link json ld fields

We can cross-reference all of these to schema.org, it should work for
most of the fields.

Change-Id: I38d8dbc7e964764886ddd156c4148bcf3ee376f3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9744
Autosubmit: Profpatsch <mail@profpatsch.de>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
This commit is contained in:
Profpatsch 2023-10-16 00:58:33 +02:00 committed by clbot
parent 81b790af1d
commit 7129749968

View file

@ -452,7 +452,7 @@ renderJsonld = \case
<dd><a href={obj.id_}>{obj.id_}</a></dd> <dd><a href={obj.id_}>{obj.id_}</a></dd>
<dt>Fields</dt> <dt>Fields</dt>
<dd> <dd>
{obj.previewFields & toDefinitionList renderJsonld} {obj.previewFields & toDefinitionList schemaType renderJsonld}
<div> <div>
<button <button
hx-get={snippetHref obj.id_} hx-get={snippetHref obj.id_}
@ -471,11 +471,11 @@ renderJsonld = \case
schemaTypes xs = schemaTypes xs =
xs xs
<&> ( \t -> <&> schemaType
let href :: Text = [fmt|https://schema.org/{t}|] in [hsx|<a href={href} target="_blank">{t}</a>|]
)
& List.intersperse ", " & List.intersperse ", "
& mconcat & mconcat
schemaType t =
let href :: Text = [fmt|https://schema.org/{t}|] in [hsx|<a href={href} target="_blank">{t}</a>|]
JsonldArray arr -> JsonldArray arr ->
toOrderedList renderJsonld arr toOrderedList renderJsonld arr
JsonldField f -> mkVal f JsonldField f -> mkVal f
@ -569,7 +569,7 @@ mkVal = \case
Json.Object obj -> Json.Object obj ->
obj obj
& KeyMap.toMapText & KeyMap.toMapText
& toDefinitionList mkVal & toDefinitionList (Html.toHtml @Text) mkVal
toOrderedList :: (Foldable t1) => (t2 -> Html) -> t1 t2 -> Html toOrderedList :: (Foldable t1) => (t2 -> Html) -> t1 t2 -> Html
toOrderedList mkValFn arr = toOrderedList mkValFn arr =
@ -584,11 +584,11 @@ toUnorderedList mkValFn arr =
& Html.ul & Html.ul
-- | Render a definition list from a Map -- | Render a definition list from a Map
toDefinitionList :: (t -> Html) -> Map Text t -> Html toDefinitionList :: (Text -> Html) -> (t -> Html) -> Map Text t -> Html
toDefinitionList mkValFn obj = toDefinitionList mkKeyFn mkValFn obj =
obj obj
& Map.toList & Map.toList
& foldMap (\(k, v) -> Html.dt (Html.toHtml @Text k) <> Html.dd (mkValFn v)) & foldMap (\(k, v) -> Html.dt (mkKeyFn k) <> Html.dd (mkValFn v))
& Html.dl & Html.dl
-- | Render a table-like structure of json values as an HTML table. -- | Render a table-like structure of json values as an HTML table.