Add site redirects (#552)

* feat(redirects): add redirects to sites

* chore(style): fixed coding style issues

* style: fix php-stan docblocks

* style: pint cleanup

* tests: fixed redirect test suite

* feat: vhosts include additional configs

* fix: use exact location matching

* - add enums
- use queues
- use vhost rather than separate conf files
- vhost formatter
- cleanup

* generate docs

---------

Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com>
This commit is contained in:
Jamie Wood
2025-03-31 16:30:57 +01:00
committed by GitHub
parent 7882d2022c
commit f483f7fdca
53 changed files with 6944 additions and 4495 deletions

View File

@ -218,3 +218,36 @@ function home_path(string $user): string
return '/home/'.$user;
}
function format_nginx_config(string $config): string
{
$lines = explode("\n", trim($config));
$indent = 0;
$formattedLines = [];
foreach ($lines as $line) {
$trimmed = trim($line);
// Preserve empty lines exactly as they are
if ($trimmed === '') {
$formattedLines[] = '';
continue;
}
// If line is a closing brace, decrease indentation first
if ($trimmed === '}') {
$indent--;
}
// Apply indentation
$formattedLines[] = str_repeat(' ', max(0, $indent)).$trimmed;
// If line contains an opening brace, increase indentation
if (str_ends_with($trimmed, '{')) {
$indent++;
}
}
return implode("\n", $formattedLines)."\n";
}