Skip to content

Commit 801aae9

Browse files
committed
Show git version if panel is installed with git
1 parent e4c3417 commit 801aae9

File tree

5 files changed

+61
-15
lines changed

5 files changed

+61
-15
lines changed

app/Providers/AppServiceProvider.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
namespace Pterodactyl\Providers;
2626

27+
use View;
28+
use Cache;
2729
use Pterodactyl\Models;
2830
use Pterodactyl\Observers;
2931
use Illuminate\Support\ServiceProvider;
@@ -40,6 +42,9 @@ public function boot()
4042
Models\User::observe(Observers\UserObserver::class);
4143
Models\Server::observe(Observers\ServerObserver::class);
4244
Models\Subuser::observe(Observers\SubuserObserver::class);
45+
46+
View::share('appVersion', $this->versionData()['version'] ?? 'undefined');
47+
View::share('appIsGit', $this->versionData()['is_git'] ?? false);
4348
}
4449

4550
/**
@@ -57,4 +62,31 @@ public function register()
5762
$this->app->register(\DaneEveritt\LoginNotifications\NotificationServiceProvider::class);
5863
}
5964
}
65+
66+
/**
67+
* Return version information for the footer.
68+
*
69+
* @return array
70+
*/
71+
protected function versionData()
72+
{
73+
return Cache::remember('git-version', 5, function () {
74+
if (file_exists(base_path('.git/HEAD'))) {
75+
$head = explode(' ', file_get_contents(base_path('.git/HEAD')));
76+
$path = base_path('.git/' . trim($head[1]));
77+
}
78+
79+
if (isset($path) && file_exists($path)) {
80+
return [
81+
'version' => substr(file_get_contents($path), 0, 8),
82+
'is_git' => true,
83+
];
84+
}
85+
86+
return [
87+
'version' => config('app.version'),
88+
'is_git' => false,
89+
];
90+
});
91+
}
6092
}

public/themes/pterodactyl/css/pterodactyl.css

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,21 @@
2222
*/
2323
@import 'checkbox.css';
2424

25-
.login-box, .register-box {
26-
width: 40%;
27-
margin: 7% auto
28-
}
29-
30-
@media (max-width:768px) {
31-
.login-box, .register-box {
32-
width: 90%;
33-
margin-top: 20px
34-
}
35-
}
25+
.login-page {
26+
height: auto;
27+
}
28+
29+
.login-box, .register-box {
30+
width: 40%;
31+
margin: 7% auto;
32+
}
33+
34+
@media (max-width:768px) {
35+
.login-box, .register-box {
36+
width: 90%;
37+
margin-top: 20px
38+
}
39+
}
3640

3741
.weight-100 {
3842
font-weight: 100;
@@ -289,3 +293,9 @@ span[aria-labelledby="select2-pUserId-container"] {
289293
tr:hover + tr.server-description {
290294
background-color: #f5f5f5 !important;
291295
}
296+
297+
.login-corner-info {
298+
position: absolute;
299+
bottom: 5px;
300+
right: 10px;
301+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@
170170
</div>
171171
<footer class="main-footer">
172172
<div class="pull-right small text-gray" style="margin-right:10px;margin-top:-7px;">
173-
<strong><i class="fa fa-code-fork"></i></strong> {{ config('app.version') }} <br />
174-
<strong><i class="fa fa-clock-o"></i></strong> {{ round(microtime(true) - LARAVEL_START, 3) }}s
173+
<strong><i class="fa fa-fw {{ $appIsGit ? 'fa-git-square' : 'fa-code-fork' }}"></i></strong> {{ $appVersion }}<br />
174+
<strong><i class="fa fa-fw fa-clock-o"></i></strong> {{ round(microtime(true) - LARAVEL_START, 3) }}s
175175
</div>
176176
Copyright &copy; 2015 - {{ date('Y') }} <a href="https://pterodactyl.io/">Pterodactyl Software</a>.
177177
</footer>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
<p class="small text-muted">
5757
Copyright &copy; 2015 - {{ date('Y') }} <a href="https://pterodactyl.io/" target="_blank">Pterodactyl Software</a>.<br />
5858
</p>
59+
<div class="login-corner-info muted small">
60+
<strong><i class="fa fa-fw {{ $appIsGit ? 'fa-git-square' : 'fa-code-fork' }}"></i></strong> {{ $appVersion }}<br />
61+
<strong><i class="fa fa-fw fa-clock-o"></i></strong> {{ round(microtime(true) - LARAVEL_START, 3) }}s
62+
</div>
5963
</div>
6064
{!! Theme::js('vendor/jquery/jquery.min.js') !!}
6165
{!! Theme::js('vendor/bootstrap/bootstrap.min.js') !!}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ class="active"
233233
</div>
234234
<footer class="main-footer">
235235
<div class="pull-right small text-gray" style="margin-right:10px;margin-top:-7px;">
236-
<strong><i class="fa fa-code-fork"></i></strong> {{ config('app.version') }} <br />
237-
<strong><i class="fa fa-clock-o"></i></strong> {{ round(microtime(true) - LARAVEL_START, 3) }}s
236+
<strong><i class="fa fa-fw {{ $appIsGit ? 'fa-git-square' : 'fa-code-fork' }}"></i></strong> {{ $appVersion }}<br />
237+
<strong><i class="fa fa-fw fa-clock-o"></i></strong> {{ round(microtime(true) - LARAVEL_START, 3) }}s
238238
</div>
239239
Copyright &copy; 2015 - {{ date('Y') }} <a href="https://pterodactyl.io/">Pterodactyl Software</a>.
240240
</footer>

0 commit comments

Comments
 (0)