-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
66 lines (64 loc) · 2.24 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
// https://getkirby.com/docs/guide/plugins/plugin-setup-composer#support-for-plugin-installation-without-composer
@include_once __DIR__ . '/vendor/autoload.php';
Kirby::plugin('leobard/deploy-yourself', [
'routes' => function () {
return [
[
/**
* Note: this route is for documentation purposes for you reading this code.
* If installed according to the README.md,
* the deploy-yourself-hook.php would be called directly
* but if not, then this is an untested fallback
*/
'pattern' => 'deploy-yourself/hook',
'method' => 'GET|POST',
'action' => function () {
$kirby = kirby();
$deploy_yourself = new Leobard\DeployYourself\DeployYourself(
kirby_root_config_path: $kirby->root('config'),
get_parameters: $kirby->request()->get()
);
return $deploy_yourself->hook();
}
]
];
},
'areas' => [
'deployyourself' => [
'label' => 'Deploy yourself',
'icon' => 'sitemap',
'menu' => true,
'link' => 'deploy-yourself/index',
'views' => [
[
'pattern' => 'deploy-yourself/(:all)',
'action' => function ($file) {
$data = [
'component' => 'deploy-yourself',
'title' => 'Deploy yourself',
'props' => [],
];
// Security: only admins
if(kirby()->user()?->role() != 'admin') {
$data['props']['message'] = 'Only available for admins';
return $data;
}
$kirby = kirby();
$deploy_yourself = new Leobard\DeployYourself\DeployYourself(
kirby_root_config_path: $kirby->root('config'),
get_parameters: []
);
$data['props']['logfiles'] = $deploy_yourself->log_files_list();
// is a file selected?
if ('index' != $file && '' != $file) {
$data['props']['selectedfilename'] = $file;
$data['props']['selectedfilecontent'] = $deploy_yourself->log_file_load($file);
}
return $data;
}
],
],
],
],
]);