Files
ponlork_1st/includes/jupyter_config_reference.php
2026-01-29 14:31:48 +07:00

64 lines
3.3 KiB
PHP

<?php
// includes/jupyter_config_reference.php
// Shared reference panel outlining Jupyter configuration values.
$jupyterDefaults = dsp_jupyter_defaults();
$resolvedBaseUrl = dsp_jupyter_base_url();
$resolvedToken = dsp_jupyter_token();
$resolvedPort = dsp_jupyter_port();
$envOverrides = dsp_jupyter_env_overrides();
$workspaceRoot = $workspaceRelativeDir ?? $jupyterDefaults['workspace_root'];
$workspaceBaseMessage = $workspaceRoot;
if (!empty($_SESSION['person_id'])) {
$workspaceBaseMessage = sprintf('%s/user_%d', rtrim($jupyterDefaults['workspace_root'], '/'), (int) $_SESSION['person_id']);
}
// Determine relative path back to the application root for links.
$currentScript = $_SERVER['PHP_SELF'] ?? '';
$scriptDir = trim(dirname($currentScript), '/');
$segmentCount = $scriptDir === '' ? 0 : substr_count($scriptDir, '/') + 1;
$rootPrefix = $segmentCount ? str_repeat('../', $segmentCount) : '';
$installConfigHref = $rootPrefix . 'install_config.php#r-in-jupyter-service';
?>
<section class="mb-4">
<div class="card shadow-sm border-0">
<div class="card-body">
<h2 class="h5 mb-3 text-secondary">Jupyter Service Reference</h2>
<p class="text-muted">
Configuration guidance (defaults, overrides, and security notes) now lives on the
<a href="<?= htmlspecialchars($installConfigHref, ENT_QUOTES, 'UTF-8') ?>">Install &amp; Configuration</a>
page under <em>R in JupyterHub Service</em>.
</p>
<p class="text-muted mb-4">
Use the snapshot below to confirm how this environment is currently resolving the notebook endpoint.
</p>
<dl class="row mb-4">
<dt class="col-sm-4 text-muted small text-uppercase">Notebook Base URL</dt>
<dd class="col-sm-8 mb-3"><code><?= htmlspecialchars($resolvedBaseUrl) ?></code></dd>
<dt class="col-sm-4 text-muted small text-uppercase">Published Port</dt>
<dd class="col-sm-8 mb-3"><code><?= htmlspecialchars($resolvedPort) ?></code></dd>
<dt class="col-sm-4 text-muted small text-uppercase">Authentication Token</dt>
<dd class="col-sm-8 mb-3"><code><?= htmlspecialchars($resolvedToken) ?></code></dd>
<dt class="col-sm-4 text-muted small text-uppercase">Workspace Mount</dt>
<dd class="col-sm-8 mb-0"><code><?= htmlspecialchars($workspaceBaseMessage) ?></code></dd>
</dl>
<h3 class="h6 text-uppercase text-muted mb-3">Active Environment Overrides</h3>
<?php
$activeOverrides = array_filter($envOverrides, static fn($value) => $value !== null && $value !== '');
?>
<?php if ($activeOverrides): ?>
<ul class="list-unstyled small text-muted mb-0">
<?php foreach ($activeOverrides as $variable => $value): ?>
<li><code><?= htmlspecialchars($variable) ?></code>: <code><?= htmlspecialchars($value) ?></code></li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p class="text-muted small mb-0">No overrides detected; defaults from the Docker stack are in effect.</p>
<?php endif; ?>
</div>
</div>
</section>