Skip to content

Commit

Permalink
Load javascript assets via URL. Fixes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed Sep 18, 2019
1 parent 36b5472 commit bd3e661
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `ignition` will be documented in this file

## 1.6.7 - 2019-09-18

- Load javascript assets via URL. Fixes #16

## 1.6.6 - 2019-09-16

- Prevent undefined index exception in `TestCommand`
Expand Down
3 changes: 2 additions & 1 deletion resources/views/errorPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<?php endforeach; ?>

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css">

<script src="/<?=$housekeepingEndpoint?>/assets"></script>
</head>
<body class="scrollbar-lg">

Expand All @@ -40,7 +42,6 @@

<div id="app"></div>

<script><?= $getAssetContents('ignition.js') ?></script>
<script>
window.Ignition = window.ignite(window.data);
</script>
Expand Down
8 changes: 0 additions & 8 deletions src/ErrorPage/ErrorPageViewModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,6 @@ public function jsonEncode($data): string
return json_encode($data, JSON_PARTIAL_OUTPUT_ON_ERROR | $jsonOptions);
}

public function getAssetContents(string $asset): string
{
$assetPath = __DIR__."/../../resources/compiled/{$asset}";

return file_get_contents($assetPath);
}

public function styles(): array
{
return array_keys(Ignition::styles());
Expand Down Expand Up @@ -158,7 +151,6 @@ public function toArray(): array
'scripts' => $this->scripts(),
'tabs' => $this->tabs(),
'jsonEncode' => Closure::fromCallable([$this, 'jsonEncode']),
'getAssetContents' => Closure::fromCallable([$this, 'getAssetContents']),
];
}
}
11 changes: 11 additions & 0 deletions src/Http/Controllers/IgnitionAssetsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Facade\Ignition\Http\Controllers;

class IgnitionAssetsController
{
public function __invoke()
{
return file_get_contents(__DIR__.'/../../../resources/compiled/ignition.js');
}
}
2 changes: 2 additions & 0 deletions src/IgnitionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use Illuminate\View\Engines\PhpEngine as LaravelPhpEngine;
use Facade\Ignition\Http\Controllers\HealthCheckController;
use Facade\Ignition\Http\Controllers\ShareReportController;
use Facade\Ignition\Http\Controllers\IgnitionAssetsController;
use Facade\Ignition\Http\Controllers\ExecuteSolutionController;
use Facade\Ignition\SolutionProviders\SolutionProviderRepository;
use Facade\Ignition\SolutionProviders\ViewNotFoundSolutionProvider;
Expand Down Expand Up @@ -128,6 +129,7 @@ protected function registerHousekeepingRoutes()
Route::post('execute-solution', ExecuteSolutionController::class);
Route::post('share-report', ShareReportController::class);

Route::get('assets', IgnitionAssetsController::class);
Route::get('scripts/{script}', ScriptController::class);
Route::get('styles/{style}', StyleController::class);
});
Expand Down

0 comments on commit bd3e661

Please sign in to comment.