Skip to content

Commit

Permalink
add resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Recca Tsai committed Feb 17, 2016
1 parent ac31649 commit 47a2468
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
15 changes: 7 additions & 8 deletions resources/views/panel.blade.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
<style>
{!! $style !!}
{!! $resources['style'] !!}
</style>

<textarea id="editor"></textarea>
<div id="shell"></div>
<div id="panel-shell"></div>

<script type="text/javascript">
if (!window.jQuery) {
{!! $jquery !!}
{!! $resources['jquery'] !!}
}
if (!window.jQuery.fn.mousewheel) {
{!! $mousewheel !!}
{!! $resources['mousewheel'] !!}
}
{!! $terminal !!}
{!! $resources['terminal'] !!}
{!! $script !!}
{!! $resources['app'] !!}
</script>

<script>
(function() {
{!! $script !!}
new Term("#shell", $.extend({!! $options !!}, {
new Term("#panel-shell", $.extend({!! $options !!}, {
editor: "#editor"
}));
})();
Expand Down
19 changes: 12 additions & 7 deletions src/Http/Controllers/TerminalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,22 @@ public function index(ApplicationContract $app, Filesystem $filesystem, $panel =
],
]);

$resourcePath = __DIR__.'/../../../public/';
$resources = [];
$resources['style'] = $filesystem->get($resourcePath.'css/app.css');
$resources['app'] = $filesystem->get($resourcePath.'js/app.js');

if ($panel === true) {
$style = $filesystem->get(public_path('vendor/terminal/css/app.css'));
$jquery = $filesystem->get(public_path('vendor/terminal/js/jquery.min.js'));
$mousewheel = $filesystem->get(public_path('vendor/terminal/js/jquery.mousewheel.min.js'));
$terminal = $filesystem->get(public_path('vendor/terminal/js/terminal.js'));
$script = $filesystem->get(public_path('vendor/terminal/js/app.js'));
$resources['jquery'] = $filesystem->get($resourcePath.'js/jquery.min.js');
$resources['mousewheel'] = $filesystem->get($resourcePath.'js/jquery.mousewheel.min.js');
$resources['terminal'] = $filesystem->get($resourcePath.'js/terminal.js');

return view('terminal::panel', compact('options', 'style', 'jquery', 'mousewheel', 'terminal', 'script'));
return view('terminal::panel', compact('options', 'resources'));
}

return view('terminal::index', compact('options'));
$resources['plugins'] = $filesystem->get($resourcePath.'js/plugins.js');

return view('terminal::index', compact('options', 'resources'));
}

/**
Expand Down
9 changes: 6 additions & 3 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class ServiceProvider extends BaseServiceProvider
*/
public function boot(Request $request, ConfigContract $config)
{
$this->handlePublishes();
if ($this->app->runningInConsole() === true) {
$this->handlePublishes();
}

if ($config->get('app.debug') === true ||
in_array(
$request->getClientIp(),
Expand Down Expand Up @@ -56,10 +59,10 @@ public function registerRoutes(Router $router)
{
if ($this->app->routesAreCached() === false) {
$prefix = 'terminal';
// $middleware = (version_compare($this->app->version(), 5.2, '>=') === true) ? ['web'] : [];
$middleware = (version_compare($this->app->version(), 5.2, '>=') === true) ? ['web'] : [];
$router->group([
'as' => 'terminal::',
// 'middleware' => $middleware,
'middleware' => $middleware,
'namespace' => $this->namespace,
'prefix' => $prefix,
], function () {
Expand Down

0 comments on commit 47a2468

Please sign in to comment.