- FallBack tab: per-node tier inventory + active fallback card with duration, tier, handback strikes, running container status - Watchdog tab: live system health (RAM bar + thresholds, load, uptime, daemon), docker watchdog strikes + skip list + restart history, stability strikes + reboot log, resource pressure alert card, config inventory (mem limits, required, pause/stop lists) - Swapped partnership/arrs tab order; FallBack between partnership and watchdog - Plugin source tree moved from Plugin/usr/local/emhttp/plugins/varaverk/ to Plugin/unraid/ - Deployment/ conf templates added
51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
// Docs — markdown file discovery, $VAR substitution, and rendering.
|
|
// Requires parsedown or similar. Falls back to <pre> if not available.
|
|
|
|
require_once __DIR__ . '/config.php';
|
|
|
|
define('PARSEDOWN_PATH', '/usr/local/emhttp/plugins/varaverk/lib/Parsedown.php');
|
|
|
|
function vv_docs_tree(): array {
|
|
$base = SCRIPTS_DIR;
|
|
$tree = [];
|
|
$files = new RecursiveIteratorIterator(
|
|
new RecursiveDirectoryIterator($base, FilesystemIterator::SKIP_DOTS),
|
|
RecursiveIteratorIterator::SELF_FIRST
|
|
);
|
|
foreach ($files as $f) {
|
|
if ($f->isFile() && strtolower($f->getExtension()) === 'md') {
|
|
$rel = ltrim(str_replace($base, '', $f->getPathname()), '/');
|
|
$tree[] = $rel;
|
|
}
|
|
}
|
|
sort($tree);
|
|
return $tree;
|
|
}
|
|
|
|
function vv_docs_render(string $rel, array $vars): string {
|
|
$path = SCRIPTS_DIR . '/' . $rel;
|
|
if (!file_exists($path)) return '<p>File not found.</p>';
|
|
|
|
$md = file_get_contents($path);
|
|
|
|
// Substitute `$VAR_NAME` markers with live conf values
|
|
$md = preg_replace_callback('/`\$([A-Z0-9_]+)`/', function($m) use ($vars) {
|
|
$key = $m[1];
|
|
return isset($vars[$key])
|
|
? '<code class="vv-live-var">' . htmlspecialchars($vars[$key]) . '</code>'
|
|
: '<code class="vv-unknown-var">$' . htmlspecialchars($key) . '</code>';
|
|
}, $md);
|
|
|
|
// Render markdown
|
|
if (file_exists(PARSEDOWN_PATH)) {
|
|
require_once PARSEDOWN_PATH;
|
|
$pd = new Parsedown();
|
|
$pd->setSafeMode(true);
|
|
return $pd->text($md);
|
|
}
|
|
|
|
// Fallback: plain preformatted text
|
|
return '<pre>' . htmlspecialchars($md) . '</pre>';
|
|
}
|