Skip to content

Commit ad9fd12

Browse files
committed
2 parents 962cf3a + 9dfd2a3 commit ad9fd12

File tree

14 files changed

+252
-45
lines changed

14 files changed

+252
-45
lines changed
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
2-
title: Admin configuration
3-
description: Add configuration options to your extension's admin page
4-
author:
2+
title: Configuration options in the admin panel
3+
description: Add a few configuration options to your extension's admin page
4+
author: Emma
55
category: dev
66
thumbnail: adminconfiguration.jpeg
7-
order:
8-
unlisted: true
97
---
108

9+
::card
10+
This guide builds on the assumption that you have an admin controller set up. If you have yet to do so, check out the [custom admin controller guide](/guides/dev/admincontroller).
11+
::
12+
1113
...
Lines changed: 177 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,182 @@
11
---
2-
title: Admin controller
3-
description: Add a custom PHP controller to an extension's admin page
4-
author:
2+
title: Custom admin page controller
3+
description: Render your admin view using a custom controller
4+
author: Emma
55
category: dev
66
thumbnail: controller.jpeg
7-
order:
8-
unlisted: true
97
---
108

11-
...
9+
## Introduction
10+
11+
Using the `admin.controller` [conf.yml bind](/docs/configs/confyml#admincontroller) you can add additional logic to how your `admin.view` is rendered, as well as how additional HTTP methods are handled.
12+
13+
Admin views are always rendered through controllers. Unless you are shipping your own custom controller (which you will when following this guide), your extension will use the default one shipped by us.
14+
15+
## Create the controller
16+
17+
Create a file called `controller.php`, and bind it to `admin.controller` in your [conf.yml](/docs/configs/confyml#admincontroller) configuration.
18+
19+
```yaml [conf.yml]
20+
admin:
21+
controller: 'controller.php'
22+
```
23+
24+
Then, add the code below to your `controller.php` file.
25+
26+
```php [controller.php]
27+
<?php
28+
29+
// Define namespace. This is the namespace needed for admin controllers.
30+
// {identifier} automatically gets replaced with your extension's
31+
// identifier upon extension installation.
32+
namespace Pterodactyl\Http\Controllers\Admin\Extensions\{identifier};
33+
34+
// Import the controller class.
35+
use Pterodactyl\Http\Controllers\Controller;
36+
37+
// Register the extension-specific controller class.
38+
class {identifier}ExtensionController extends Controller {
39+
// The index() function gets called upon a GET request.
40+
public function index() {
41+
// Respond with plain text.
42+
return "hello from {identifier}'s custom controller"
43+
}
44+
}
45+
```
46+
47+
Open up your extension's admin page and it should respond with plain text.
48+
49+
![](/img/guides/hellocontroller.jpeg)
50+
51+
Alright, so with that out of the way, let's actually render our view.
52+
53+
## Rendering the admin view
54+
55+
After the `namespace` definition, import the following classes into `controller.php`. These will be used by our functions later on in the guide.
56+
57+
```php [controller.php]
58+
// Import classes needed for view rendering.
59+
use Illuminate\View\View;
60+
use Illuminate\View\Factory as ViewFactory;
61+
62+
// Import BlueprintExtensionLibrary. This is required for admin views to function.
63+
use Pterodactyl\BlueprintFramework\Libraries\ExtensionLibrary\Admin\BlueprintAdminLibrary as BlueprintExtensionLibrary;
64+
```
65+
66+
Inside of the controller's `class`, add a `__construct()` method. The `__construct()` method is automatically called on class instantiation.
67+
68+
```php [controller.php]
69+
class {identifier}ExtensionController extends Controller {
70+
public function __construct(
71+
private ViewFactory $view,
72+
private BlueprintExtensionLibrary $blueprint,
73+
) {}
74+
75+
// ..your other functions
76+
}
77+
```
78+
79+
### Update the `index()` function
80+
81+
Because we're going to be rendering a view, we should expect our response to be one too. `View` is imported from `use Illuminate\View\View;` in [this step](#rendering-the-admin-view).
82+
83+
```diff [controller.php]
84+
- public function index() {
85+
+ public function index(): View {
86+
```
87+
88+
Finally, we can return a view, instead of a plaintext response.
89+
90+
This code makes a view with `$this->view->make` (through ViewFactory) and makes the variables `$root` and `$blueprint` available to it.
91+
92+
```diff [controller.php]
93+
public function index(): View {
94+
- return "hello from {identifier}'s custom controller"
95+
+ return $this->view->make(
96+
+ 'admin.extensions.{identifier}.index', [
97+
+ 'root' => "/admin/extensions/{identifier}",
98+
+ 'blueprint' => $this->blueprint,
99+
+ ]
100+
+ );
101+
}
102+
```
103+
104+
Save your changes and visit your extension's admin page again. You should see your admin view instead of the plaintext response from earlier.
105+
106+
## Adding variables to the view
107+
108+
Through ViewFactory's `make()` function, we can define variables that we can then use in our admin view.
109+
110+
The following piece of code adds a `$foo` variable to the view, with the contents of `bar`.
111+
112+
```diff [controller.php]
113+
public function index(): View {
114+
+ $foo = 'bar'
115+
return $this->view->make(
116+
'admin.extensions.{identifier}.index', [
117+
'root' => "/admin/extensions/{identifier}",
118+
'blueprint' => $this->blueprint,
119+
+ 'foo' => $foo,
120+
]
121+
);
122+
}
123+
```
124+
125+
Then in your admin view (`admin.view` in your [conf.yml](/docs/configs/confyml#adminview-required) configuration), read out the `$foo` variable.
126+
127+
We're assuming your `admin.view` file is called `view.blade.php`, but it can be different depending on your extension configuration.
128+
129+
<!-- prettier-ignore -->
130+
```html [view.blade.php]
131+
<p>
132+
{{ $foo }}
133+
</p>
134+
```
135+
136+
Save your changes, install your extension and check out your admin view. There should be a paragraph element with 'bar' (the value of `$foo`) as it's content.
137+
138+
## Final results
139+
140+
Below is the final version of the `controller.php` file composed in the previous steps.
141+
142+
While there's nothing stopping you from copy pasting them into your extension, we still highly recommend going through the steps above. This file is solely here for comparison.
143+
144+
```php [controller.php]
145+
<?php
146+
147+
// Define namespace. This is the namespace needed for admin controllers.
148+
// {identifier} automatically gets replaced with your extension's
149+
// identifier upon extension installation.
150+
namespace Pterodactyl\Http\Controllers\Admin\Extensions\{identifier};
151+
152+
// Import classes needed for view rendering.
153+
use Illuminate\View\View;
154+
use Illuminate\View\Factory as ViewFactory;
155+
// Import the controller class.
156+
use Pterodactyl\Http\Controllers\Controller;
157+
// Import BlueprintExtensionLibrary. This is required for admin views
158+
// to function.
159+
use Pterodactyl\BlueprintFramework\Libraries\ExtensionLibrary\Admin\BlueprintAdminLibrary as BlueprintExtensionLibrary;
160+
161+
// Register the extension-specific controller class.
162+
class {identifier}ExtensionController extends Controller {
163+
public function __construct(private ViewFactory $view, private BlueprintExtensionLibrary $blueprint) {}
164+
165+
// Render page. The index() function gets called when the
166+
// /admin/extensions/{identifier} path receives a GET request.
167+
public function index(): View {
168+
// Define the $foo variable to 'bar'.
169+
$foo = 'bar';
170+
// Render the admin view, assign $root to the URL path,
171+
// $blueprint to BlueprintExtensionLibrary and $foo to the $foo
172+
// variable. These variables can be directly used within the view.
173+
return $this->view->make(
174+
'admin.extensions.{identifier}.index', [
175+
'root' => "/admin/extensions/{identifier}",
176+
'blueprint' => $this->blueprint,
177+
'foo' => $foo,
178+
]
179+
);
180+
}
181+
}
182+
```

apps/frontend/content/guides/dev/adminpage.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
---
2-
title: Admin page
3-
description: Create your extension's admin page
2+
title: Your first admin page
3+
description: Learn how to build a simple admin page for your extension
44
author: Emma
55
category: dev
66
thumbnail: adminpage.jpeg
7-
order:
8-
unlisted: false
7+
order: -1
98
---
109

1110
## Introduction
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
---
2-
title: Dashboard wrappers
3-
description: Extend the Pterodactyl client and admin dashboard within the Laravel blade wrapper
4-
author:
2+
title: Extending the user dashboard wrapper
3+
description: Extend the Pterodactyl user dashboard using the Laravel blade wrapper
4+
author: Emma
55
category: dev
66
thumbnail: dashboard.jpeg
7-
order:
8-
unlisted: true
97
---
108

119
...

apps/frontend/content/guides/dev/docker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Develop with Blueprint Docker
33
description: Set up Blueprint Docker for local development
44
author: Loki and Emma
55
category: dev
6-
thumbnail: blueprintdocker.jpg
6+
thumbnail: blueprintdockerdev.jpg
77
---
88

99
::card

apps/frontend/content/guides/dev/packaging.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
---
2-
title: Packaging extensions
3-
description: Export extensions into ".blueprint" files for distribution
2+
title: Exporting your extension
3+
description: Export extensions into "myextension.blueprint" files for distribution
44
author: Emma
55
category: dev
66
thumbnail: files.jpeg
7-
order:
87
---
98

10-
## Export your extension with the CLI
9+
## Introduction
10+
11+
Blueprint extensions are distributed with `{identifier}.blueprint` files. Users can upload these files to their Pterodactyl directory and install your extension through the Blueprint CLI.
12+
13+
## Export the extension
1114

1215
To turn your development files into a distributable `{identifier}.blueprint` file, we'll need to use Blueprint's CLI utility to package it.
1316

@@ -28,12 +31,20 @@ Blueprint can generate a temporary download link for your extension for easier e
2831
blueprint -export expose
2932
```
3033

31-
### Test your exported extension
34+
## Test the extension
3235

3336
Testing is important! You should always check if an extension still works as expected, especially when using export scripts. Install your extension, test it on your panel and finally, if all is right, distribute it.
3437

35-
## Manually export your extension
38+
```bash
39+
# Make sure to remove your extension beforehand, if it is
40+
# installed.
41+
blueprint -remove myextension
42+
43+
# Install the myextension.blueprint file once again, which
44+
# should now exist in your Pterodactyl panel.
45+
blueprint -install myextension
46+
```
3647

37-
Don't do this! Even though extensions are practically ZIP files, exporting manually can break your extension, in current and future releases of Blueprint.
48+
## That's it!
3849

39-
Our CLI does more than just archiving extensions, it excludes certain directories, runs export scripts and enforces the folder structure Blueprint expects.
50+
You can now distribute your `{identifier}.blueprint` file. There are a few marketplaces that have specific categories/tags for Blueprint extensions. If your extension is open-source, add the [blueprint-extension](https://github.com/topics/blueprint-extension) tag to your repository!

apps/frontend/content/guides/dev/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Make your very own Blueprint extension
44
author: Emma
55
category: dev
66
thumbnail: code.jpeg
7-
order: -1
7+
order: -2
88
---
99

1010
::card
50.4 KB
Loading
112 KB
Loading

apps/frontend/src/components/elements/form/Textbox.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
:wrap="props.wrap"
2222
:class="props.class"
2323
@input="resize"
24-
@click="resize"
2524
class="h-auto w-full resize-none overflow-hidden rounded-2xl border border-neutral-700 bg-gray-800/40 p-4 outline-0 transition-colors focus:bg-gray-800/60"
2625
/>
2726
</template>

0 commit comments

Comments
 (0)