From 70bae6be2b2c0e61dc84e4a8c7bd5122548091d3 Mon Sep 17 00:00:00 2001 From: Mike Scott Date: Sat, 23 Mar 2019 18:30:02 +0000 Subject: [PATCH 1/4] Add root user again :-( --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 9b3dc5c..74f31e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,3 +38,5 @@ RUN php artisan optimize && php artisan migrate ADD --chown=www-data:www-data /resources /var/www/html/resources COPY --chown=www-data:www-data --from=npm /app/public/css /var/www/html/public/css COPY --chown=www-data:www-data --from=npm /app/public/js /var/www/html/public/js + +USER root \ No newline at end of file From 669a506e3f335f36f714bb51bfdf21365bb3e48a Mon Sep 17 00:00:00 2001 From: Mike Scott Date: Sat, 23 Mar 2019 18:30:50 +0000 Subject: [PATCH 2/4] Add higlight.js and angular-highlightjs dependencies --- package-lock.json | 55 +++++++++++++++++++++++++++++++++++++---------- package.json | 4 +++- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7edfa5f..2f1e5cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -181,6 +181,15 @@ "resolved": "https://registry.npmjs.org/angular/-/angular-1.7.8.tgz", "integrity": "sha512-wtef/y4COxM7ZVhddd7JtAAhyYObq9YXKar9tsW7558BImeVYteJiTxCKeJOL45lJ/+7B4wrAC49j8gTFYEthg==" }, + "angular-highlightjs": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/angular-highlightjs/-/angular-highlightjs-0.7.1.tgz", + "integrity": "sha1-1+Dh9Z203mPwBXMhimRypZ/xg/Q=", + "requires": { + "angular": "^1.0.1", + "highlight.js": ">7.0.0" + } + }, "angular-ui-router": { "version": "0.4.3", "resolved": "https://registry.npmjs.org/angular-ui-router/-/angular-ui-router-0.4.3.tgz", @@ -3348,7 +3357,8 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "optional": true }, "aproba": { "version": "1.2.0", @@ -3369,12 +3379,14 @@ "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3389,17 +3401,20 @@ "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -3516,7 +3531,8 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "optional": true }, "ini": { "version": "1.3.5", @@ -3528,6 +3544,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3542,6 +3559,7 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3549,12 +3567,14 @@ "minimist": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "optional": true }, "minipass": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3573,6 +3593,7 @@ "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3653,7 +3674,8 @@ "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3665,6 +3687,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "optional": true, "requires": { "wrappy": "1" } @@ -3750,7 +3773,8 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -3786,6 +3810,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3805,6 +3830,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3848,12 +3874,14 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "optional": true }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", + "optional": true } } }, @@ -5773,6 +5801,11 @@ "sntp": "1.x.x" } }, + "highlight.js": { + "version": "9.15.6", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.15.6.tgz", + "integrity": "sha512-zozTAWM1D6sozHo8kqhfYgsac+B+q0PmsjXeyDrYIHHcBN0zTVT66+s2GW1GZv7DbyaROdLXKdabwS/WqPyIdQ==" + }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", diff --git a/package.json b/package.json index ae16bd9..562be4b 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,12 @@ }, "dependencies": { "angular": "^1.4.5", + "angular-highlightjs": "^0.7.1", "angular-ui-router": "^0.4.2", - "bootstrap-sass": "^3.3.7", "bootstrap-notify": "^3.1.3", + "bootstrap-sass": "^3.3.7", "clipboard": "^2.0.4", + "highlight.js": "^9.15.6", "jquery": "^3.1.1", "laravel-echo": "^1.3.5", "laravel-elixir": "^4.0.0", From ce5c63b23ed0dd47e75f5c3def5806d690392d9f Mon Sep 17 00:00:00 2001 From: Mike Scott Date: Sat, 23 Mar 2019 18:31:27 +0000 Subject: [PATCH 3/4] Syntax highlighting, enable --- resources/assets/js/app.js | 10 ++++++++-- resources/assets/js/libs.js | 10 +++++++++- resources/assets/sass/app.scss | 7 +++++++ resources/views/app.php | 6 ++++-- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 5e79a00..e3840ec 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -1,6 +1,7 @@ angular .module("app", [ - 'ui.router' + 'ui.router', + 'hljs' ]) .config(['$stateProvider', '$urlRouterProvider', '$urlMatcherFactoryProvider', function ($stateProvider, $urlRouterProvider, $urlMatcherFactoryProvider) { @@ -185,7 +186,12 @@ angular $scope.setCurrentRequest = (function (request) { $scope.currentRequestIndex = request.uuid; - $scope.currentRequest = request; + $scope.currentRequest = JSON.parse(JSON.stringify(request)); + + if ($scope.formatJsonEnable) { + $scope.currentRequest.content = $scope.formatContentJson(request.content) + } + $scope.markAsRead(request.uuid); // Change the state url so it may be copied from address bar diff --git a/resources/assets/js/libs.js b/resources/assets/js/libs.js index 8a2d9a6..1362dfc 100644 --- a/resources/assets/js/libs.js +++ b/resources/assets/js/libs.js @@ -3,4 +3,12 @@ require('bootstrap-sass'); require('bootstrap-notify'); require('angular'); require('angular-ui-router'); -window.Clipboard = require('clipboard'); \ No newline at end of file +window.Clipboard = require('clipboard'); + +window.hljs = require('highlight.js/lib/highlight'); +var javascript = require('highlight.js/lib/languages/javascript'); +var xml = require('highlight.js/lib/languages/javascript'); +hljs.registerLanguage('javascript', javascript); +hljs.registerLanguage('xml', xml); + +require('angular-highlightjs'); \ No newline at end of file diff --git a/resources/assets/sass/app.scss b/resources/assets/sass/app.scss index eb7bfd6..6e9fcbb 100644 --- a/resources/assets/sass/app.scss +++ b/resources/assets/sass/app.scss @@ -1,4 +1,5 @@ @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap"; +@import "node_modules/highlight.js/styles/github"; /* * Variables @@ -217,6 +218,12 @@ code { color: #ccc; } +#req-content { + pre { + padding: 0; + } +} + /* * JSON syntax highlighting */ diff --git a/resources/views/app.php b/resources/views/app.php index 1eac4a3..f8f1790 100644 --- a/resources/views/app.php +++ b/resources/views/app.php @@ -321,9 +321,11 @@ class="btn btn-xs" ng-class="redirectUrl ? '' : 'disabled'"

(no body content)

-

+                                     hljs 
+                                     hljs-source="currentRequest.content">
+                                
                             
                         
                     

From 7cb487755c8459ebeb7fde162f47a906c2e0f317 Mon Sep 17 00:00:00 2001
From: Mike Scott 
Date: Sat, 23 Mar 2019 19:04:00 +0000
Subject: [PATCH 4/4] Add XML Formatting as well (fixes #60)

---
 package-lock.json          |  5 +++++
 package.json               |  1 +
 resources/assets/js/app.js | 11 ++++++++++-
 resources/views/app.php    |  4 ++--
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 2f1e5cf..738b64f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9363,6 +9363,11 @@
       "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz",
       "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks="
     },
+    "pretty-data": {
+      "version": "0.40.0",
+      "resolved": "https://registry.npmjs.org/pretty-data/-/pretty-data-0.40.0.tgz",
+      "integrity": "sha1-Vyqo6iNGdGerlLa1Jmpv2cj93XI="
+    },
     "pretty-hrtime": {
       "version": "1.0.3",
       "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz",
diff --git a/package.json b/package.json
index 562be4b..71d19f1 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
     "jquery": "^3.1.1",
     "laravel-echo": "^1.3.5",
     "laravel-elixir": "^4.0.0",
+    "pretty-data": "^0.40.0",
     "pusher-js": "^4.2.2"
   },
   "scripts": {
diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js
index e3840ec..63942b9 100644
--- a/resources/assets/js/app.js
+++ b/resources/assets/js/app.js
@@ -1,3 +1,5 @@
+var prettyData = require('pretty-data').pd;
+
 angular
     .module("app", [
         'ui.router',
@@ -189,7 +191,14 @@ angular
             $scope.currentRequest = JSON.parse(JSON.stringify(request));
 
             if ($scope.formatJsonEnable) {
-                $scope.currentRequest.content = $scope.formatContentJson(request.content)
+                var hloutput = hljs.highlightAuto(request.content);
+
+                if (hloutput.language === "json") {
+                    $scope.currentRequest.content = $scope.formatContentJson(request.content)
+                }
+                if (hloutput.language === "xml") {
+                    $scope.currentRequest.content = prettyData.xml(request.content);
+                }
             }
 
             $scope.markAsRead(request.uuid);
diff --git a/resources/views/app.php b/resources/views/app.php
index f8f1790..1245574 100644
--- a/resources/views/app.php
+++ b/resources/views/app.php
@@ -195,9 +195,9 @@ class="btn btn-xs" ng-class="redirectUrl ? '' : 'disabled'"
 
                                     
                                       
+                                               ga-on="click" ga-event-category="JSONFormat" ga-event-action="toggle"/> Format JSON/XML