From d8da1f2abfebecc6368a23f6e38a6fc11de5ace0 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Sun, 30 Jun 2019 01:41:54 +0000 Subject: [PATCH] Display summary and pretty JSON for notifications and for outboxes --- src/Vervis/Handler/Inbox.hs | 9 +++++---- templates/person/notifications.hamlet | 9 ++++++--- templates/person/outbox.hamlet | 7 ++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Vervis/Handler/Inbox.hs b/src/Vervis/Handler/Inbox.hs index 952eb74..85d3261 100644 --- a/src/Vervis/Handler/Inbox.hs +++ b/src/Vervis/Handler/Inbox.hs @@ -127,6 +127,11 @@ import Vervis.RemoteActorStore import Yesod.RenderSource import Vervis.Settings +objectSummary o = + case M.lookup "summary" o of + Just (String t) | not (T.null t) -> Just t + _ -> Nothing + getInboxR :: Handler Html getInboxR = do acts <- @@ -236,10 +241,6 @@ getInbox here getInboxId = do error $ "InboxItem #" ++ show ibid ++ " both local and remote" (Just act, Nothing) -> persistJSONObject act (Nothing, Just obj) -> persistJSONObject obj - objectSummary o = - case M.lookup "summary" o of - Just (String t) | not (T.null t) -> Just t - _ -> Nothing getSharerInboxR :: ShrIdent -> Handler TypedContent getSharerInboxR shr = getInbox here getInboxId diff --git a/templates/person/notifications.hamlet b/templates/person/notifications.hamlet index e6e83e0..cc9bdc6 100644 --- a/templates/person/notifications.hamlet +++ b/templates/person/notifications.hamlet @@ -17,9 +17,12 @@ $# .
- $forall (activity, widget, enctype) <- notifications -
-      #{TLB.toLazyText $ encodePrettyToTextBuilder activity}
+  $forall (obj, widget, enctype) <- notifications
+    $maybe summary <- objectSummary obj
+      
+ ^{preEscapedToHtml summary} + $nothing + ^{renderPrettyJSONSkylighting obj}
^{widget} diff --git a/templates/person/outbox.hamlet b/templates/person/outbox.hamlet index ecad7bf..8bc34a0 100644 --- a/templates/person/outbox.hamlet +++ b/templates/person/outbox.hamlet @@ -22,6 +22,11 @@ $# .
$forall Entity _ (OutboxItem _ doc published) <- items
#{showTime published} -
^{renderPrettyJSON' $ BL.fromStrict $ persistJSONBytes doc} + $with obj <- persistJSONObject doc + $maybe summary <- objectSummary obj +
+ ^{preEscapedToHtml summary} + $nothing + ^{renderPrettyJSONSkylighting obj} ^{pageNav}