Skip to content

Commit cfe36df

Browse files
authored
allow customizing HestiaCP with js/php (hestiacp#2747)
* allow customizing HestiaCP with js/php make a folder where everything that loads init.js will load additional .js/.php files, allowing people to customize their HestiaCP control panels. I must admit, I have not studied the HestiaCP plugin system, and if it turns out that the plugin system is superior to this folder, please tell me about it :) I couldn't really find documentation on the plugin system * code-breaking typos * make CI run again (CI is bugging out) * simplify code i think the only thing htmlentities did was to encode "+" characters, which isn't required when using RAWurlencode, and im not even sure it was actually required with normal urlencode. * DirectoryIterator isn't static-callable ick * make CI run again (i think it's bugging out?)
1 parent 351c0cf commit cfe36df

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

web/js/custom_scripts/README.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.js and .php files placed in this directory will automatically be included in scripts loading init.js.
2+
3+
subfolders will be ignored (recursive file loading is not supported. you're free to create sub-folders, but they will not be invoked automatically.)
4+
5+
These custom files will perist across HestiaCP upgrades.
6+
7+
This directory is not meant for HestiaCP development, but meant for people wantng to customize their own HestiaCP control panel.
8+
9+
Warning: modifications to this README.txt may be lost during HestiaCP upgrades.

web/templates/includes/end_js.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
<script src="/js/init.js?<?=JS_LATEST_UPDATE?>"></script>
88
<script src="/js/i18n.js.php?<?=JS_LATEST_UPDATE?>"></script>
99
<script src="/js/templates.js?<?=JS_LATEST_UPDATE?>"></script>
10+
<?php foreach(new DirectoryIterator($_SERVER['HESTIA'].'/web/js/custom_scripts') as $customScript){
11+
if($customScript->getExtension() === 'js'){
12+
echo '<script src="/js/custom_scripts/'.rawurlencode($customScript->getBasename()).'"></script>';
13+
} elseif($customScript->getExtension() === "php"){
14+
require_once($customScript->getPathname());
15+
}
16+
} ?>
1017
<script>
1118
$(function() {
1219
hover_menu();
@@ -43,4 +50,3 @@
4350
<?php
4451
unset($_SESSION['error_msg']);
4552
endif;
46-
?>

web/templates/pages/list_server_info.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
<script src="/js/init.js?<?=JS_LATEST_UPDATE?>"></script>
1616
<script src="/js/i18n.js.php?<?=JS_LATEST_UPDATE?>"></script>
1717
<script src="/js/templates.js?<?=JS_LATEST_UPDATE?>"></script>
18+
<?php foreach(new DirectoryIterator($_SERVER['HESTIA'].'/web/js/custom_scripts') as $customScript){
19+
if($customScript->getExtension() === 'js'){
20+
echo '<script src="/js/custom_scripts/'.rawurlencode($customScript->getBasename()).'"></script>';
21+
} elseif($customScript->getExtension() === "php"){
22+
require_once($customScript->getPathname());
23+
}
24+
} ?>
1825
</head>
1926

2027
<body>

web/templates/pages/list_weblog.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
<script src="/js/init.js?<?=JS_LATEST_UPDATE?>"></script>
1616
<script src="/js/i18n.js.php?<?=JS_LATEST_UPDATE?>"></script>
1717
<script src="/js/templates.js?<?=JS_LATEST_UPDATE?>"></script>
18+
<?php foreach(new DirectoryIterator($_SERVER['HESTIA'].'/web/js/custom_scripts') as $customScript){
19+
if($customScript->getExtension() === 'js'){
20+
echo '<script src="/js/custom_scripts/'.rawurlencode($customScript->getBasename()).'"></script>';
21+
} elseif($customScript->getExtension() === "php"){
22+
require_once($customScript->getPathname());
23+
}
24+
} ?>
1825
</head>
1926

2027
<body>

0 commit comments

Comments
 (0)