From 04a2e9a817a4c5cdfda7ec040808f065aa25b519 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Mon, 3 Jun 2019 22:22:32 +0000 Subject: [PATCH] In HTML pages with AP support, display link to pretty formatted JSON --- src/Yesod/ActivityPub.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Yesod/ActivityPub.hs b/src/Yesod/ActivityPub.hs index bee49ee..4e6023d 100644 --- a/src/Yesod/ActivityPub.hs +++ b/src/Yesod/ActivityPub.hs @@ -26,6 +26,7 @@ import Prelude import Control.Exception import Control.Monad.Logger.CallStack import Data.ByteString (ByteString) +import Data.Foldable import Data.List.NonEmpty (NonEmpty) import Data.Text (Text) import Network.HTTP.Client @@ -131,4 +132,14 @@ provideHtmlAndAP object widget = do [whamlet|
#{encodePrettyToLazyText doc}
                         |]
-                    _ -> widget
+                    _ -> do
+                        widget
+                        mroute <- getCurrentRoute
+                        for_ mroute $ \ route -> do
+                            params <- reqGetParams <$> getRequest
+                            let pj = ("prettyjson", "true")
+                            [whamlet|
+                                
+ + [See JSON] + |]