Skip to content

Commit

Permalink
Include prettify.js
Browse files Browse the repository at this point in the history
This makes sure whoops still works without internet.
  • Loading branch information
jonasdt authored and denis-sokolov committed Oct 15, 2017
1 parent 9e7c2ea commit ad2bd7d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/Whoops/Handler/PrettyPageHandler.php
Expand Up @@ -168,6 +168,7 @@ public function handle()
$templateFile = $this->getResource("views/layout.html.php");
$cssFile = $this->getResource("css/whoops.base.css");
$zeptoFile = $this->getResource("js/zepto.min.js");
$prettifyFile = $this->getResource("js/prettify.min.js");
$clipboard = $this->getResource("js/clipboard.min.js");
$jsFile = $this->getResource("js/whoops.base.js");

Expand All @@ -186,6 +187,7 @@ public function handle()
// @todo: Asset compiler
"stylesheet" => file_get_contents($cssFile),
"zepto" => file_get_contents($zeptoFile),
"prettify" => file_get_contents($prettifyFile),
"clipboard" => file_get_contents($clipboard),
"javascript" => file_get_contents($jsFile),

Expand Down
28 changes: 28 additions & 0 deletions src/Whoops/Resources/js/prettify.min.js

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

20 changes: 2 additions & 18 deletions src/Whoops/Resources/js/whoops.base.js
@@ -1,17 +1,4 @@
Zepto(function($) {

// a jQuery.getScript() equivalent to asyncronously load javascript files
// credits to http://stackoverflow.com/a/8812950/1597388
var getScript = function(src, func) {
var script = document.createElement('script');
script.async = 'async';
script.src = src;
if (func) {
script.onload = func;
}
document.getElementsByTagName('head')[0].appendChild( script );
};

var $leftPanel = $('.left-panel');
var $frameContainer = $('.frames-container');
var $appFramesTab = $('#application-frames-tab');
Expand All @@ -31,11 +18,6 @@ Zepto(function($) {
$header.removeClass('header-expand');
});

// load prettify asyncronously to speed up page rendering
getScript('//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.js', function () {
renderCurrentCodeblock();
});

/*
* add prettyprint classes to our current active codeblock
* run prettyPrint() to highlight the active code
Expand All @@ -59,6 +41,8 @@ Zepto(function($) {

}

renderCurrentCodeblock();

/*
* Highlight the active and neighboring lines for the current frame
* Adjust the offset to make sure that line is veritcally centered
Expand Down
1 change: 1 addition & 0 deletions src/Whoops/Resources/views/layout.html.php
Expand Up @@ -24,6 +24,7 @@
</div>
</div>

<script><?php echo $prettify ?></script>
<script><?php echo $zepto ?></script>
<script><?php echo $clipboard ?></script>
<script><?php echo $javascript ?></script>
Expand Down

0 comments on commit ad2bd7d

Please sign in to comment.