Skip to content

Commit 186ec32

Browse files
committed
Update footer and releases
1 parent 4251b0e commit 186ec32

5 files changed

Lines changed: 116 additions & 30 deletions

File tree

app/Console/Commands/UpgradeCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
class UpgradeCommand extends Command
1111
{
12-
protected const DEFAULT_URL = 'https://github.com/pterodactyl/panel/releases/%s/panel.tar.gz';
13-
1412
protected $signature = 'p:upgrade
1513
{--user= : The user that PHP runs under. All files will be owned by this user.}
1614
{--group= : The group that PHP runs under. All files will be owned by this group.}
@@ -190,6 +188,11 @@ protected function getUrl(): string
190188
return $this->option('url');
191189
}
192190

193-
return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v' . $this->option('release') : 'latest/download');
191+
$repo = config('pterodactyl.cdn.panel_repo', 'jackh54/panel');
192+
$path = $this->option('release')
193+
? 'download/v' . ltrim((string) $this->option('release'), 'vV')
194+
: 'latest/download';
195+
196+
return sprintf('https://github.com/%s/releases/%s/panel.tar.gz', $repo, $path);
194197
}
195198
}

app/Services/Helpers/SoftwareVersionService.php

Lines changed: 89 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,37 @@ public function __construct(
2525
}
2626

2727
/**
28-
* Get the latest version of the panel from the CDN servers.
28+
* Get the latest version of the panel from GitHub releases.
2929
*/
3030
public function getPanel(): string
3131
{
3232
return Arr::get(self::$result, 'panel') ?? 'error';
3333
}
3434

35+
/**
36+
* Get the URL to the latest panel release page.
37+
*/
38+
public function getPanelUrl(): string
39+
{
40+
$fallback = sprintf(
41+
'https://github.com/%s/releases/latest',
42+
config('pterodactyl.cdn.panel_repo', 'jackh54/panel')
43+
);
44+
45+
return Arr::get(self::$result, 'panel_url') ?? $fallback;
46+
}
47+
48+
/**
49+
* Get the URL to the panel GitHub repository.
50+
*/
51+
public function getGitHub(): string
52+
{
53+
return sprintf(
54+
'https://github.com/%s',
55+
config('pterodactyl.cdn.panel_repo', 'jackh54/panel')
56+
);
57+
}
58+
3559
/**
3660
* Get the latest version of the daemon from the CDN servers.
3761
*/
@@ -65,7 +89,12 @@ public function isLatestPanel(): bool
6589
return true;
6690
}
6791

68-
return version_compare(config('app.version'), $this->getPanel()) >= 0;
92+
$latest = $this->getPanel();
93+
if ($latest === 'error') {
94+
return true;
95+
}
96+
97+
return version_compare(config('app.version'), $latest) >= 0;
6998
}
7099

71100
/**
@@ -81,22 +110,72 @@ public function isLatestDaemon(string $version): bool
81110
}
82111

83112
/**
84-
* Keeps the versioning cache up-to-date with the latest results from the CDN.
113+
* Keeps the versioning cache up-to-date with the latest results from GitHub / CDN.
85114
*/
86115
protected function cacheVersionData(): array
87116
{
88117
return $this->cache->remember(self::VERSION_CACHE_KEY, CarbonImmutable::now()->addMinutes(config('pterodactyl.cdn.cache_time', 60)), function () {
89-
try {
90-
$response = $this->client->request('GET', config('pterodactyl.cdn.url'));
118+
$data = $this->fetchCdnData();
119+
$panel = $this->fetchPanelReleaseData();
91120

92-
if ($response->getStatusCode() === 200) {
93-
return json_decode($response->getBody(), true);
94-
}
121+
return array_merge($data, $panel);
122+
});
123+
}
95124

125+
/**
126+
* Fetch Wings / community metadata from the official CDN.
127+
*/
128+
protected function fetchCdnData(): array
129+
{
130+
try {
131+
$response = $this->client->request('GET', config('pterodactyl.cdn.url'));
132+
133+
if ($response->getStatusCode() === 200) {
134+
$data = json_decode($response->getBody(), true) ?? [];
135+
// Panel version comes from this fork's GitHub releases, not upstream CDN.
136+
unset($data['panel']);
137+
138+
return $data;
139+
}
140+
141+
throw new CdnVersionFetchingException();
142+
} catch (\Exception) {
143+
return [];
144+
}
145+
}
146+
147+
/**
148+
* Fetch the latest panel version from this fork's GitHub releases.
149+
*/
150+
protected function fetchPanelReleaseData(): array
151+
{
152+
$repo = config('pterodactyl.cdn.panel_repo', 'jackh54/panel');
153+
154+
try {
155+
$response = $this->client->request('GET', "https://api.github.com/repos/{$repo}/releases/latest", [
156+
'headers' => [
157+
'Accept' => 'application/vnd.github+json',
158+
'User-Agent' => config('app.name', 'PandaScript') . '-Panel',
159+
],
160+
]);
161+
162+
if ($response->getStatusCode() !== 200) {
96163
throw new CdnVersionFetchingException();
97-
} catch (\Exception) {
164+
}
165+
166+
$json = json_decode($response->getBody(), true) ?? [];
167+
$tag = Arr::get($json, 'tag_name');
168+
169+
if (!$tag) {
98170
return [];
99171
}
100-
});
172+
173+
return [
174+
'panel' => ltrim($tag, 'vV'),
175+
'panel_url' => Arr::get($json, 'html_url') ?? "https://github.com/{$repo}/releases/latest",
176+
];
177+
} catch (\Exception) {
178+
return [];
179+
}
101180
}
102181
}

config/pterodactyl.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@
9292

9393
'cdn' => [
9494
'cache_time' => 60,
95+
// Official CDN still used for Wings / community links.
9596
'url' => 'https://cdn.pterodactyl.io/releases/latest.json',
97+
// Panel version checks against this fork's GitHub releases.
98+
'panel_repo' => env('PANEL_GITHUB_REPO', 'jackh54/panel'),
9699
],
97100

98101
/*

resources/scripts/components/elements/PageContentBlock.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ const PageContentBlock: React.FC<PageContentBlockProps> = ({ title, showFlashKey
3232
{children}
3333
</ContentContainer>
3434
<ContentContainer css={tw`mb-4`}>
35-
<p css={tw`text-center text-neutral-500 text-xs`}>
35+
<div css={tw`text-center text-neutral-500 text-xs`}>
3636
{links.length > 0 && (
37-
<>
37+
<p css={tw`m-0`}>
3838
{links.map((link, index) => (
3939
<React.Fragment key={link.url + link.label}>
4040
{index > 0 && <span css={tw`mx-2 text-neutral-600`}>·</span>}
@@ -48,19 +48,20 @@ const PageContentBlock: React.FC<PageContentBlockProps> = ({ title, showFlashKey
4848
</a>
4949
</React.Fragment>
5050
))}
51-
<span css={tw`mx-2 text-neutral-600`}>·</span>
52-
</>
51+
</p>
5352
)}
54-
<a
55-
rel={'noopener nofollow noreferrer'}
56-
href={companyUrl}
57-
target={'_blank'}
58-
css={tw`no-underline text-neutral-500 hover:text-neutral-300`}
59-
>
60-
{company}
61-
</a>
62-
&nbsp;&copy; {new Date().getFullYear()}
63-
</p>
53+
<p css={[tw`m-0`, links.length > 0 && tw`mt-2`]}>
54+
<a
55+
rel={'noopener nofollow noreferrer'}
56+
href={companyUrl}
57+
target={'_blank'}
58+
css={tw`no-underline text-neutral-500 hover:text-neutral-300`}
59+
>
60+
{company}
61+
</a>
62+
&nbsp;&copy; {new Date().getFullYear()}
63+
</p>
64+
</div>
6465
</ContentContainer>
6566
</>
6667
</CSSTransition>

resources/views/admin/index.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
</div>
2828
<div class="box-body">
2929
@if ($version->isLatestPanel())
30-
You are running Pterodactyl Panel version <code>{{ config('app.version') }}</code>. Your panel is up-to-date!
30+
You are running {{ config('app.name') }} Panel version <code>{{ config('app.version') }}</code>. Your panel is up-to-date!
3131
@else
32-
Your panel is <strong>not up-to-date!</strong> The latest version is <a href="https://github.com/Pterodactyl/Panel/releases/v{{ $version->getPanel() }}" target="_blank"><code>{{ $version->getPanel() }}</code></a> and you are currently running version <code>{{ config('app.version') }}</code>. You can find instructions on how to update your panel <a href="https://pterodactyl.io/panel/1.0/updating.html">here</a>.
32+
Your panel is <strong>not up-to-date!</strong> The latest version is <a href="{{ $version->getPanelUrl() }}" target="_blank" rel="noopener noreferrer"><code>{{ $version->getPanel() }}</code></a> and you are currently running version <code>{{ config('app.version') }}</code>. Download <code>panel.tar.gz</code> from <a href="{{ $version->getPanelUrl() }}" target="_blank" rel="noopener noreferrer">GitHub Releases</a>, or run <code>./update.sh</code> on the server.
3333
@endif
3434
</div>
3535
</div>
@@ -44,7 +44,7 @@
4444
</div>
4545
<div class="clearfix visible-xs-block">&nbsp;</div>
4646
<div class="col-xs-6 col-sm-3 text-center">
47-
<a href="https://github.com/pterodactyl/panel"><button class="btn btn-primary" style="width:100%;"><i class="fa fa-fw fa-support"></i> GitHub</button></a>
47+
<a href="{{ $version->getGitHub() }}"><button class="btn btn-primary" style="width:100%;"><i class="fa fa-fw fa-support"></i> GitHub</button></a>
4848
</div>
4949
<div class="col-xs-6 col-sm-3 text-center">
5050
<a href="{{ $version->getDonations() }}"><button class="btn btn-success" style="width:100%;"><i class="fa fa-fw fa-money"></i> Support the Project</button></a>

0 commit comments

Comments
 (0)