Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Syntax Highlight and automatic formatting of JSON and XML #61

Merged
merged 4 commits into from
Mar 23, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
55 changes: 44 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 8 additions & 2 deletions resources/assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
angular
.module("app", [
'ui.router'
'ui.router',
'hljs'
])
.config(['$stateProvider', '$urlRouterProvider', '$urlMatcherFactoryProvider',
function ($stateProvider, $urlRouterProvider, $urlMatcherFactoryProvider) {
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion resources/assets/js/libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ require('bootstrap-sass');
require('bootstrap-notify');
require('angular');
require('angular-ui-router');
window.Clipboard = require('clipboard');
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');
7 changes: 7 additions & 0 deletions resources/assets/sass/app.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
@import "node_modules/highlight.js/styles/github";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fredsted Are you happy with this as default style? Not sure what you wanted to use here; being able to choose would be great but added a level of complexity (plus additional preference to have somewhere)

I personally prefer a dark style


/*
* Variables
Expand Down Expand Up @@ -217,6 +218,12 @@ code {
color: #ccc;
}

#req-content {
pre {
padding: 0;
}
}

/*
* JSON syntax highlighting
*/
Expand Down
6 changes: 4 additions & 2 deletions resources/views/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,11 @@ class="btn btn-xs" ng-class="redirectUrl ? '' : 'disabled'"
<p id="noContent" ng-show="hasRequests && currentRequest.content == ''">
(no body content)</p>

<pre id="req-content"
<div id="req-content"
ng-show="hasRequests && currentRequest.content != ''"
ng-bind="formatJsonEnable ? formatContentJson(currentRequest.content) : currentRequest.content"></pre>
hljs
hljs-source="currentRequest.content">
</div>
</div>
</div>
</div>
Expand Down