Skip to content

Commit 0341dbd

Browse files
committed
Add very basic cache busting
1 parent 1eb76c4 commit 0341dbd

File tree

11 files changed

+133
-74
lines changed

11 files changed

+133
-74
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1414
### Changed
1515
* Adjusted exception handler behavior to log more stack information for PDO exceptions while not exposing credentials.
1616

17+
### Added
18+
* Very basic cache busting until asset management can be changed to make use of better systems.
19+
1720
## v0.7.0 (Derelict Dermodactylus)
1821
### Fixed
1922
* `[rc.2]` — Fixes bad API behavior on `/user` routes.

app/Providers/AppServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Pterodactyl\Models\Server;
99
use Pterodactyl\Models\Subuser;
1010
use Illuminate\Support\Facades\Schema;
11+
use Igaster\LaravelTheme\Facades\Theme;
1112
use Illuminate\Support\ServiceProvider;
1213
use Pterodactyl\Observers\UserObserver;
1314
use Pterodactyl\Observers\ServerObserver;
@@ -28,6 +29,7 @@ public function boot()
2829

2930
View::share('appVersion', $this->versionData()['version'] ?? 'undefined');
3031
View::share('appIsGit', $this->versionData()['is_git'] ?? false);
32+
Theme::setSetting('cache-version', md5($this->versionData()['version'] ?? 'undefined'));
3133
}
3234

3335
/**

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"fideloper/proxy": "^3.3",
2323
"guzzlehttp/guzzle": "^6.3",
2424
"hashids/hashids": "^2.0",
25-
"igaster/laravel-theme": "^1.16",
25+
"igaster/laravel-theme": "^2.0.6",
2626
"laracasts/utilities": "^3.0",
2727
"laravel/framework": "5.5.*",
2828
"laravel/tinker": "^1.0",

composer.lock

Lines changed: 22 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/app.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
/*
204204
* Additional Dependencies
205205
*/
206-
igaster\laravelTheme\themeServiceProvider::class,
206+
Igaster\LaravelTheme\themeServiceProvider::class,
207207
Prologue\Alerts\AlertsServiceProvider::class,
208208
Lord\Laroute\LarouteServiceProvider::class,
209209
],
@@ -253,7 +253,7 @@
253253
'Schema' => Illuminate\Support\Facades\Schema::class,
254254
'Session' => Illuminate\Support\Facades\Session::class,
255255
'Storage' => Illuminate\Support\Facades\Storage::class,
256-
'Theme' => igaster\laravelTheme\Facades\Theme::class,
256+
'Theme' => Igaster\LaravelTheme\Facades\Theme::class,
257257
'URL' => Illuminate\Support\Facades\URL::class,
258258
'Validator' => Illuminate\Support\Facades\Validator::class,
259259
'View' => Illuminate\Support\Facades\View::class,

config/themes.php

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,57 @@
22

33
return [
44
'enabled' => true,
5+
6+
/*
7+
|--------------------------------------------------------------------------
8+
| Root path where theme Views will be located.
9+
| Can be outside default views path e.g.: resources/themes
10+
| Leave it null if you will put your themes in the default views folder
11+
| (as defined in config\views.php)
12+
|--------------------------------------------------------------------------
13+
*/
514
'themes_path' => realpath(base_path('resources/themes')),
15+
16+
/*
17+
|--------------------------------------------------------------------------
18+
| Set behavior if an asset is not found in a Theme hierarchy.
19+
| Available options: THROW_EXCEPTION | LOG_ERROR | IGNORE
20+
|--------------------------------------------------------------------------
21+
*/
622
'asset_not_found' => 'LOG_ERROR',
7-
'active' => env('APP_THEME', 'pterodactyl'),
823

24+
/*
25+
|--------------------------------------------------------------------------
26+
| Do we want a theme activated by default? Can be set at runtime with:
27+
| Theme::set('theme-name');
28+
|--------------------------------------------------------------------------
29+
*/
30+
'default' => env('APP_THEME', 'pterodactyl'),
31+
32+
/*
33+
|--------------------------------------------------------------------------
34+
| Cache theme.json configuration files that are located in each theme's folder
35+
| in order to avoid searching theme settings in the filesystem for each request
36+
|--------------------------------------------------------------------------
37+
*/
38+
'cache' => true,
39+
40+
/*
41+
|--------------------------------------------------------------------------
42+
| Define available themes. Format:
43+
|
44+
| 'theme-name' => [
45+
| 'extends' => 'theme-to-extend', // optional
46+
| 'views-path' => 'path-to-views', // defaults to: resources/views/theme-name
47+
| 'asset-path' => 'path-to-assets', // defaults to: public/theme-name
48+
|
49+
| // You can add your own custom keys
50+
| // Use Theme::getSetting('key') & Theme::setSetting('key', 'value') to access them
51+
| 'key' => 'value',
52+
| ],
53+
|
54+
|--------------------------------------------------------------------------
55+
*/
956
'themes' => [
1057
'pterodactyl' => [
1158
'extends' => null,

public/js/laroute.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/themes/pterodactyl/layouts/admin.blade.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
@include('layouts.scripts')
2525

2626
@section('scripts')
27-
{!! Theme::css('vendor/select2/select2.min.css') !!}
28-
{!! Theme::css('vendor/bootstrap/bootstrap.min.css') !!}
29-
{!! Theme::css('vendor/adminlte/admin.min.css') !!}
30-
{!! Theme::css('vendor/adminlte/colors/skin-blue.min.css') !!}
31-
{!! Theme::css('vendor/sweetalert/sweetalert.min.css') !!}
32-
{!! Theme::css('vendor/animate/animate.min.css') !!}
33-
{!! Theme::css('css/pterodactyl.css') !!}
27+
{!! Theme::css('vendor/select2/select2.min.css?t={cache-version}') !!}
28+
{!! Theme::css('vendor/bootstrap/bootstrap.min.css?t={cache-version}') !!}
29+
{!! Theme::css('vendor/adminlte/admin.min.css?t={cache-version}') !!}
30+
{!! Theme::css('vendor/adminlte/colors/skin-blue.min.css?t={cache-version}') !!}
31+
{!! Theme::css('vendor/sweetalert/sweetalert.min.css?t={cache-version}') !!}
32+
{!! Theme::css('vendor/animate/animate.min.css?t={cache-version}') !!}
33+
{!! Theme::css('css/pterodactyl.css?t={cache-version}') !!}
3434
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
3535
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
3636

@@ -171,17 +171,17 @@
171171
{!! Theme::js('js/keyboard.polyfill.js') !!}
172172
<script>keyboardeventKeyPolyfill.polyfill();</script>
173173

174-
{!! Theme::js('js/laroute.js') !!}
175-
{!! Theme::js('vendor/jquery/jquery.min.js') !!}
176-
{!! Theme::js('vendor/sweetalert/sweetalert.min.js') !!}
177-
{!! Theme::js('vendor/bootstrap/bootstrap.min.js') !!}
178-
{!! Theme::js('vendor/slimscroll/jquery.slimscroll.min.js') !!}
179-
{!! Theme::js('vendor/adminlte/app.min.js') !!}
180-
{!! Theme::js('vendor/socketio/socket.io.v203.min.js') !!}
181-
{!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js') !!}
182-
{!! Theme::js('vendor/select2/select2.full.min.js') !!}
183-
{!! Theme::js('js/admin/functions.js') !!}
184-
{!! Theme::js('js/autocomplete.js') !!}
174+
{!! Theme::js('js/laroute.js?t={cache-version}') !!}
175+
{!! Theme::js('vendor/jquery/jquery.min.js?t={cache-version}') !!}
176+
{!! Theme::js('vendor/sweetalert/sweetalert.min.js?t={cache-version}') !!}
177+
{!! Theme::js('vendor/bootstrap/bootstrap.min.js?t={cache-version}') !!}
178+
{!! Theme::js('vendor/slimscroll/jquery.slimscroll.min.js?t={cache-version}') !!}
179+
{!! Theme::js('vendor/adminlte/app.min.js?t={cache-version}') !!}
180+
{!! Theme::js('vendor/socketio/socket.io.v203.min.js?t={cache-version}') !!}
181+
{!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js?t={cache-version}') !!}
182+
{!! Theme::js('vendor/select2/select2.full.min.js?t={cache-version}') !!}
183+
{!! Theme::js('js/admin/functions.js?t={cache-version}') !!}
184+
{!! Theme::js('js/autocomplete.js?t={cache-version}') !!}
185185

186186
@if(Auth::user()->root_admin)
187187
<script>

resources/themes/pterodactyl/layouts/auth.blade.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
<meta name="theme-color" content="#367fa9">
2222

2323
@section('scripts')
24-
{!! Theme::css('vendor/bootstrap/bootstrap.min.css') !!}
25-
{!! Theme::css('vendor/adminlte/admin.min.css') !!}
26-
{!! Theme::css('css/pterodactyl.css') !!}
24+
{!! Theme::css('vendor/bootstrap/bootstrap.min.css?t={cache-version}') !!}
25+
{!! Theme::css('vendor/adminlte/admin.min.css?t={cache-version}') !!}
26+
{!! Theme::css('css/pterodactyl.css?t={cache-version}') !!}
2727
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
2828
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
2929

@@ -50,17 +50,17 @@
5050
<strong><i class="fa fa-fw fa-clock-o"></i></strong> {{ round(microtime(true) - LARAVEL_START, 3) }}s
5151
</div>
5252

53-
{!! Theme::js('vendor/jquery/jquery.min.js') !!}
54-
{!! Theme::js('vendor/bootstrap/bootstrap.min.js') !!}
55-
{!! Theme::js('js/autocomplete.js') !!}
56-
{!! Theme::js('vendor/particlesjs/particles.min.js') !!}
53+
{!! Theme::js('vendor/jquery/jquery.min.js?t={cache-version}') !!}
54+
{!! Theme::js('vendor/bootstrap/bootstrap.min.js?t={cache-version}') !!}
55+
{!! Theme::js('js/autocomplete.js?t={cache-version}') !!}
56+
{!! Theme::js('vendor/particlesjs/particles.min.js?t={cache-version}') !!}
5757
<script type="text/javascript">
5858
/* particlesJS.load(@dom-id, @path-json, @callback (optional)); */
5959
$(function () {
60-
particlesJS.load('particles-js', '{!! Theme::url('vendor/particlesjs/particles.json') !!}', function() {});
60+
particlesJS.load('particles-js', '{!! Theme::url('vendor/particlesjs/particles.json?t={cache-version}') !!}', function() {});
6161
})
6262
</script>
6363

64-
@if(config('pterodactyl.lang.in_context')) {!! Theme::js('vendor/phraseapp/phraseapp.js') !!} @endif
64+
@if(config('pterodactyl.lang.in_context')) {!! Theme::js('vendor/phraseapp/phraseapp.js?t={cache-version}') !!} @endif
6565
</body>
6666
</html>

resources/themes/pterodactyl/layouts/error.blade.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
<meta name="theme-color" content="#367fa9">
2323

2424
@section('scripts')
25-
{!! Theme::css('vendor/bootstrap/bootstrap.min.css') !!}
26-
{!! Theme::css('vendor/adminlte/admin.min.css') !!}
27-
{!! Theme::css('vendor/adminlte/colors/skin-blue.min.css') !!}
28-
{!! Theme::css('vendor/sweetalert/sweetalert.min.css') !!}
29-
{!! Theme::css('css/pterodactyl.css') !!}
25+
{!! Theme::css('vendor/bootstrap/bootstrap.min.css?t={cache-version}') !!}
26+
{!! Theme::css('vendor/adminlte/admin.min.css?t={cache-version}') !!}
27+
{!! Theme::css('vendor/adminlte/colors/skin-blue.min.css?t={cache-version}') !!}
28+
{!! Theme::css('vendor/sweetalert/sweetalert.min.css?t={cache-version}') !!}
29+
{!! Theme::css('css/pterodactyl.css?t={cache-version}') !!}
3030
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
3131
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
3232

@@ -60,11 +60,11 @@
6060
</footer>
6161
</div>
6262
@section('footer-scripts')
63-
{!! Theme::js('js/laroute.js') !!}
64-
{!! Theme::js('vendor/jquery/jquery.min.js') !!}
65-
{!! Theme::js('vendor/bootstrap/bootstrap.min.js') !!}
66-
{!! Theme::js('vendor/slimscroll/jquery.slimscroll.min.js') !!}
67-
{!! Theme::js('vendor/adminlte/app.min.js') !!}
63+
{!! Theme::js('js/laroute.js?t={cache-version}') !!}
64+
{!! Theme::js('vendor/jquery/jquery.min.js?t={cache-version}') !!}
65+
{!! Theme::js('vendor/bootstrap/bootstrap.min.js?t={cache-version}') !!}
66+
{!! Theme::js('vendor/slimscroll/jquery.slimscroll.min.js?t={cache-version}') !!}
67+
{!! Theme::js('vendor/adminlte/app.min.js?t={cache-version}') !!}
6868
@show
6969
</body>
7070
</html>

0 commit comments

Comments
 (0)