aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/skeleton.php
diff options
context:
space:
mode:
authorwinter2025-03-16 01:49:15 +0000
committerwinter2025-03-16 01:49:15 +0000
commit23ddb01a20788da2c98c4d5bb9bd271ceff532c8 (patch)
tree50846f7741fcfb2ed37d1103405366d630281255 /templates/skeleton.php
parent145b5db9474e32ca3430fe35eaa7498d7f26ff95 (diff)
avoid loading whole page every time
but also problem introduced: mobilepanes are now no longer boosted (it was causing trouble)
Diffstat (limited to 'templates/skeleton.php')
-rw-r--r--templates/skeleton.php29
1 files changed, 22 insertions, 7 deletions
diff --git a/templates/skeleton.php b/templates/skeleton.php
index 62090bd..c9e28c5 100644
--- a/templates/skeleton.php
+++ b/templates/skeleton.php
@@ -1,16 +1,23 @@
<?php
use Digitigrade\GlobalSettings;
-use Digitigrade\Model\FollowRelation;
use Digitigrade\Model\UserAccount;
$user = UserAccount::findByCurrentSession();
$settings = GlobalSettings::getInstance();
+
+$fullTitle = $pageTitle . ' — ' . $settings->get('instance.name');
+
+$loadPartialPage = isset($_SERVER['HTTP_HX_REQUEST']);
+if ($loadPartialPage) {
+ echo '<title>' . htmlspecialchars($fullTitle) . '</title>';
+ goto skipStart;
+}
?>
<!DOCTYPE html>
<html lang="<?= get_ui_language() ?>">
<head>
- <title><?= $pageTitle ?> &mdash; <?= $settings->get('instance.name') ?></title>
+ <title><?= htmlspecialchars($fullTitle) ?></title>
<!-- metadata for link previews -->
<meta property="og:type" content="<?= $ogType ?? 'website' ?>">
<meta name="twitter:card" content="summary">
@@ -38,11 +45,13 @@ $settings = GlobalSettings::getInstance();
<?php call_template('head_tags'); ?>
</head>
-<body hx-boost="true" hx-indicator="#loadingIndicator">
+<body hx-boost="true" hx-indicator="#loadingIndicator" hx-target="#centrePane" hx-swap="outerHTML show:window:top">
<header>
- <nav>
+ <?php skipStart: ?>
+ <nav id="nav" <?= $loadPartialPage ? 'hx-swap-oob="true"' : '' ?>>
<?php if ($user != null): ?>
- <a id="leftPaneActivator" href="/mobilepane/left" class="inlineIcon material-symbols menu"></a>
+ <a id="leftPaneActivator" href="/mobilepane/left" class="inlineIcon material-symbols menu"
+ hx-boost="false"></a>
<?php else: ?>
<span id="leftPaneActivator"></span>
<?php endif; ?>
@@ -59,7 +68,8 @@ $settings = GlobalSettings::getInstance();
<img id="loadingIndicator" class="htmx-indicator" src="/static/tail-spin.svg">
<?php if ($user != null): ?>
- <a id="rightPaneActivator" href="/mobilepane/right" class="inlineIcon material-symbols notifications"></a>
+ <a id="rightPaneActivator" href="/mobilepane/right" class="inlineIcon material-symbols notifications"
+ hx-boost="false"></a>
<?php endif; ?>
<?php if ($user == null):
@@ -73,6 +83,8 @@ $settings = GlobalSettings::getInstance();
</a>
<?php endif; ?>
</nav>
+ <?php if ($loadPartialPage)
+ goto skipToMainContent; ?>
</header>
<main>
<div>
@@ -83,16 +95,19 @@ $settings = GlobalSettings::getInstance();
}
call_template('navigation/left_side');
?>
- <p class="versionInfo"><?= sprintf(__('version'), get_version()) ?></p>
+ <p class="versionInfo"><?= __f('version', get_version()) ?></p>
</section>
</div>
<div>
+ <?php skipToMainContent: ?>
<section id="centrePane">
<?php if (!isset($renderTitleHeading) || $renderTitleHeading): ?>
<h1><?= $pageTitle ?></h1>
<?php endif; ?>
<?php slot(); ?>
</section>
+ <?php if ($loadPartialPage)
+ exit; ?>
</div>
<div>
<section id="rightPane">