From 4007ffea52c9c2f4fd7ec7555ecb12adb5bce4e3 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Thu, 24 Dec 2015 12:38:26 -0800 Subject: [PATCH] pretty-print JSON response --- composer.json | 3 ++- composer.lock | 50 +++++++++++++++++++++++++++++++----- views/webmention-details.php | 12 +++++++-- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 7f1f15d..0a986bf 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ "j4mie/idiorm": "1.5.*", "p3k/caterpillar": "0.1.*", "predis/predis": "1.*", - "michelf/php-markdown": "1.6.*" + "michelf/php-markdown": "1.6.*", + "camspiers/json-pretty": "1.0.*" }, "require-dev": { "phpunit/phpunit": "*" diff --git a/composer.lock b/composer.lock index 436e58e..2457919 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "fe88436a4cf4b629d33a4969c34cefa5", - "content-hash": "40f23b807dfa9bbd43f7542fa5c41faa", + "hash": "a8d37c97d0b911b03141113fb4cd1322", + "content-hash": "5b9ec8fe80d7a02cfbb56463f40efb9c", "packages": [ { "name": "barnabywalters/mf-cleaner", @@ -47,6 +47,42 @@ "description": "Cleans up microformats2 array structures", "time": "2014-10-06 23:11:15" }, + { + "name": "camspiers/json-pretty", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/camspiers/json-pretty.git", + "reference": "73c0bd55ca966f31f79d690a4b0aabaf98ad5d94" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/camspiers/json-pretty/zipball/73c0bd55ca966f31f79d690a4b0aabaf98ad5d94", + "reference": "73c0bd55ca966f31f79d690a4b0aabaf98ad5d94", + "shasum": "" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Camspiers": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cam Spiers", + "email": "cameron@heyday.co.nz" + } + ], + "description": "Provides support for json pretty printing", + "time": "2015-09-17 16:05:48" + }, { "name": "firebase/php-jwt", "version": "v3.0.0", @@ -177,16 +213,16 @@ }, { "name": "indieweb/mention-client", - "version": "1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/indieweb/mention-client-php.git", - "reference": "28115f604eb0c0d88a4b46a11771823af27e9e58" + "reference": "0f2cd135c8fb2b848b10915950b1756a8a1e8614" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/indieweb/mention-client-php/zipball/28115f604eb0c0d88a4b46a11771823af27e9e58", - "reference": "28115f604eb0c0d88a4b46a11771823af27e9e58", + "url": "https://api.github.com/repos/indieweb/mention-client-php/zipball/0f2cd135c8fb2b848b10915950b1756a8a1e8614", + "reference": "0f2cd135c8fb2b848b10915950b1756a8a1e8614", "shasum": "" }, "require": { @@ -215,7 +251,7 @@ ], "description": "Client library for sending webmention and pingback notifications", "homepage": "https://github.com/indieweb/mention-client-php", - "time": "2015-12-22 23:40:11" + "time": "2015-12-24 20:00:09" }, { "name": "indieweb/representative-h-card", diff --git a/views/webmention-details.php b/views/webmention-details.php index 0860f96..0364971 100644 --- a/views/webmention-details.php +++ b/views/webmention-details.php @@ -73,7 +73,7 @@

Logs

- +
@@ -90,7 +90,15 @@
Date
-
e($status->raw_response) ?>
+
raw_response);
+              if($json) {
+                $pretty = new Camspiers\JsonPretty\JsonPretty;
+                echo $this->e($pretty->prettify($json, null, "  "));
+              } else {
+                echo $this->e($status->raw_response);
+              }
+            ?>