mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
chore: fix remaining static analysis problems
This commit is contained in:
parent
3a3eb3bc68
commit
dd31ab7fbe
6 changed files with 32 additions and 34 deletions
|
@ -3,7 +3,6 @@
|
|||
namespace App;
|
||||
|
||||
use Illuminate\Foundation\Application as IlluminateApplication;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Extends \Illuminate\Foundation\Application to override some defaults.
|
||||
|
@ -16,29 +15,4 @@ class Application extends IlluminateApplication
|
|||
* @see https://github.com/phanan/koel/releases
|
||||
*/
|
||||
public const KOEL_VERSION = 'v4.4.0';
|
||||
|
||||
/**
|
||||
* Loads a revision'ed asset file, making use of gulp-rev
|
||||
* This is a copycat of L5's Elixir, but catered to our directory structure.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function rev(string $file, ?string $manifestFile = null): string
|
||||
{
|
||||
static $manifest = null;
|
||||
|
||||
$manifestFile = $manifestFile ?: public_path('mix-manifest.json');
|
||||
|
||||
if ($manifest === null) {
|
||||
$manifest = json_decode(file_get_contents($manifestFile), true);
|
||||
}
|
||||
|
||||
if (isset($manifest[$file])) {
|
||||
return file_exists(public_path('hot'))
|
||||
? "http://localhost:8080{$manifest[$file]}"
|
||||
: static_url("{$manifest[$file]}");
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,30 @@ function static_url(?string $name = null): string
|
|||
return $cdnUrl ? $cdnUrl . '/' . trim(ltrim($name, '/')) : trim(asset($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* A copy of Laravel Mix but catered to our directory structure.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
function asset_rev(string $file, ?string $manifestFile = null): string
|
||||
{
|
||||
static $manifest = null;
|
||||
|
||||
$manifestFile = $manifestFile ?: public_path('mix-manifest.json');
|
||||
|
||||
if ($manifest === null) {
|
||||
$manifest = json_decode(file_get_contents($manifestFile), true);
|
||||
}
|
||||
|
||||
if (isset($manifest[$file])) {
|
||||
return file_exists(public_path('hot'))
|
||||
? "http://localhost:8080{$manifest[$file]}"
|
||||
: static_url($manifest[$file]);
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
|
||||
}
|
||||
|
||||
function album_cover_path(string $fileName): string
|
||||
{
|
||||
return public_path(config('koel.album_cover_dir') . $fileName);
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
<link rel="icon" href="{{ static_url('img/icon.png') }}">
|
||||
<link rel="apple-touch-icon" href="{{ static_url('img/icon.png') }}">
|
||||
|
||||
<link rel="stylesheet" href="{{ App::rev('/css/app.css') }}">
|
||||
<link rel="stylesheet" href="{{ asset_rev('/css/app.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
<noscript>It may sound funny, but Koel requires JavaScript to sing. Please enable it.</noscript>
|
||||
@include('client-js-vars')
|
||||
<script src="{{ App::rev('/js/app.js') }}"></script>
|
||||
<script src="{{ asset_rev('/js/app.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
<link rel="icon" href="{{ static_url('img/icon.png') }}">
|
||||
<link rel="apple-touch-icon" href="{{ static_url('img/icon.png') }}">
|
||||
|
||||
<link rel="stylesheet" href="{{ App::rev('/css/remote.css') }}">
|
||||
<link rel="stylesheet" href="{{ asset_rev('/css/remote.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
<noscript>It may sound funny, but Koel requires JavaScript to sing. Please enable it.</noscript>
|
||||
@include('client-js-vars')
|
||||
<script src="{{ App::rev('/js/remote/app.js') }}"></script>
|
||||
<script src="{{ asset_rev('/js/remote/app.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -34,7 +34,7 @@ class ApplicationTest extends TestCase
|
|||
$manifestFile = __DIR__ . '../../blobs/rev-manifest.json';
|
||||
config(['koel.cdn.url' => '']);
|
||||
|
||||
self::assertEquals('http://localhost/foo00.css', app()->rev('/foo.css', $manifestFile));
|
||||
self::assertEquals('http://localhost/foo00.css', asset_rev('/foo.css', $manifestFile));
|
||||
}
|
||||
|
||||
public function testApplicationAssetRevisionUrlsAreConstructedCorrectlyWhenUsingCdn(): void
|
||||
|
@ -42,6 +42,6 @@ class ApplicationTest extends TestCase
|
|||
$manifestFile = __DIR__ . '../../blobs/rev-manifest.json';
|
||||
config(['koel.cdn.url' => 'http://cdn.tld']);
|
||||
|
||||
self::assertEquals('http://cdn.tld/foo00.css', app()->rev('/foo.css', $manifestFile));
|
||||
self::assertEquals('http://cdn.tld/foo00.css', asset_rev('/foo.css', $manifestFile));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class ForceHttpsTest extends TestCase
|
|||
|
||||
$response = Mockery::mock(Response::class);
|
||||
|
||||
$next = static function () use ($response): Response {
|
||||
$next = static function () use ($response) {
|
||||
return $response;
|
||||
};
|
||||
|
||||
|
@ -53,7 +53,7 @@ class ForceHttpsTest extends TestCase
|
|||
|
||||
$response = Mockery::mock(Response::class);
|
||||
|
||||
$next = static function () use ($response): Response {
|
||||
$next = static function () use ($response) {
|
||||
return $response;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue