diff options
| author | winter | 2025-03-20 22:17:38 +0000 |
|---|---|---|
| committer | winter | 2025-03-20 22:17:38 +0000 |
| commit | b5c4e99cb1a2e5bb5cf6d38192d677843b1acd80 (patch) | |
| tree | 3aee1e8b4961abe6e8c6b84913b04c9396b11b4e | |
| parent | c10a1ea700a94e4eff8b10985cd402943ad07859 (diff) | |
fix various htmx navigation / page reloads
also i added a UserAccount::setPassword because i felt like it
| -rw-r--r-- | Digitigrade/Model/UserAccount.php | 6 | ||||
| -rw-r--r-- | routes/preferences.php | 2 | ||||
| -rw-r--r-- | routes/user_auth.php | 4 | ||||
| -rw-r--r-- | templates/mobilepane_left.php | 29 | ||||
| -rw-r--r-- | templates/mobilepane_right.php | 9 | ||||
| -rw-r--r-- | templates/skeleton.php | 20 |
6 files changed, 39 insertions, 31 deletions
diff --git a/Digitigrade/Model/UserAccount.php b/Digitigrade/Model/UserAccount.php index 37e0c7e..a409fe8 100644 --- a/Digitigrade/Model/UserAccount.php +++ b/Digitigrade/Model/UserAccount.php @@ -16,7 +16,7 @@ class UserAccount extends Model { public static function create(string $email, #[\SensitiveParameter] string $password): self { $user = new self(); $user->email = $email; - $user->passwordHash = defaults_password_hash($password); + $user->setPassword($password); $user->actor = null; $user->save(); return $user; @@ -69,6 +69,10 @@ class UserAccount extends Model { return password_verify($attemptedPassword, $this->passwordHash); } + public function setPassword(#[\SensitiveParameter] $newPassword): void { + $this->passwordHash = defaults_password_hash($newPassword); + } + /** * Throws if this user isn't an admin. * @return self this user (so you can use it in chains) diff --git a/routes/preferences.php b/routes/preferences.php index 95e7228..8ccf74e 100644 --- a/routes/preferences.php +++ b/routes/preferences.php @@ -38,7 +38,7 @@ Router::getInstance()->mount('/fragment/changePassword', function (array $args) } elseif ($_POST['new'] != $_POST['newRepeat']) { $error = 'doesntMatch'; } else { - $user->passwordHash = defaults_password_hash($_POST['new']); + $user->setPassword($_POST['new']); $user->save(); $success = true; } diff --git a/routes/user_auth.php b/routes/user_auth.php index 49e138b..3c3b76c 100644 --- a/routes/user_auth.php +++ b/routes/user_auth.php @@ -19,7 +19,7 @@ Router::getInstance()->mount('/login', function (array $args) { // success $session = Session::create($user); $session->setCookie(isset($_POST['rememberSession'])); - throw new TemporaryRedirect('/'); + throw new TemporaryRedirect('/feed/home?fl=1'); } } @@ -37,5 +37,5 @@ Router::getInstance()->mount('/logout', function (array $args) { $session->clearCookie(); $session->remove(); } - throw new TemporaryRedirect('/'); + throw new TemporaryRedirect('/feed/global?fl=1'); });
\ No newline at end of file diff --git a/templates/mobilepane_left.php b/templates/mobilepane_left.php index 83e9e4a..6af4664 100644 --- a/templates/mobilepane_left.php +++ b/templates/mobilepane_left.php @@ -14,7 +14,7 @@ $settings = GlobalSettings::getInstance(); </head> <body> - <header> + <header id="header" hx-swap-oob="true"> <nav> <a id="leftPaneActivator" class="inlineIcon material-symbols close" _="on click go back"></a> <span></span> @@ -24,19 +24,22 @@ $settings = GlobalSettings::getInstance(); </span> </nav> </header> - <main class="mobilePane"> - <?php - $links = [ - '/feed/home' => __('timeline.home.shortName'), - '/feed/global' => __('timeline.global.shortName'), - '/feed/local' => __('timeline.local.shortName'), - ]; - call_template('navigation/header_links', ['links' => $links]); + <main class="mobilePane" id="main" hx-boost="true" hx-indicator="#loadingIndicator" hx-vals='{"fl": 1}' + hx-swap-oob="true"> + <section id="centrePane"> + <?php + $links = [ + '/feed/home' => __('timeline.home.shortName'), + '/feed/global' => __('timeline.global.shortName'), + '/feed/local' => __('timeline.local.shortName'), + ]; + call_template('navigation/header_links', ['links' => $links]); - call_template('note/write_form', ['actor' => $user->actor]); - call_template('navigation/left_side'); - ?> - <p class="versionInfo"><?= sprintf(__('version'), get_version()) ?></p> + call_template('note/write_form', ['actor' => $user->actor]); + call_template('navigation/left_side'); + ?> + <p class="versionInfo"><?= sprintf(__('version'), get_version()) ?></p> + </section> </main> </body> diff --git a/templates/mobilepane_right.php b/templates/mobilepane_right.php index 02749ac..f1cf46a 100644 --- a/templates/mobilepane_right.php +++ b/templates/mobilepane_right.php @@ -13,7 +13,7 @@ $settings = GlobalSettings::getInstance(); </head> <body> - <header> + <header id="header" hx-swap-oob="true"> <nav> <span> <img id="loadingIndicator" class="htmx-indicator" src="/static/tail-spin.svg"></span> @@ -22,8 +22,11 @@ $settings = GlobalSettings::getInstance(); <a id="rightPaneActivator" class="inlineIcon material-symbols close" _="on click go back"></a> </nav> </header> - <main class="mobilePane"> - <?php call_template('notifications_panel', ['user' => UserAccount::requireByCurrentSession()]); ?> + <main class="mobilePane" id="main" hx-boost="true" hx-indicator="#loadingIndicator" hx-vals='{"fl": 1}' + hx-swap-oob="true"> + <section id="centrePane"> + <?php call_template('notifications_panel', ['user' => UserAccount::requireByCurrentSession()]); ?> + </section> </main> </body> diff --git a/templates/skeleton.php b/templates/skeleton.php index c9e28c5..f4963da 100644 --- a/templates/skeleton.php +++ b/templates/skeleton.php @@ -7,7 +7,7 @@ $settings = GlobalSettings::getInstance(); $fullTitle = $pageTitle . ' — ' . $settings->get('instance.name'); -$loadPartialPage = isset($_SERVER['HTTP_HX_REQUEST']); +$loadPartialPage ??= isset($_SERVER['HTTP_HX_REQUEST']) && !isset($_GET['fl']); if ($loadPartialPage) { echo '<title>' . htmlspecialchars($fullTitle) . '</title>'; goto skipStart; @@ -46,12 +46,11 @@ if ($loadPartialPage) { </head> <body hx-boost="true" hx-indicator="#loadingIndicator" hx-target="#centrePane" hx-swap="outerHTML show:window:top"> - <header> - <?php skipStart: ?> - <nav id="nav" <?= $loadPartialPage ? 'hx-swap-oob="true"' : '' ?>> + <?php skipStart: ?> + <header id="header" hx-swap-oob="true"> + <nav> <?php if ($user != null): ?> - <a id="leftPaneActivator" href="/mobilepane/left" class="inlineIcon material-symbols menu" - hx-boost="false"></a> + <a id="leftPaneActivator" href="/mobilepane/left" class="inlineIcon material-symbols menu"></a> <?php else: ?> <span id="leftPaneActivator"></span> <?php endif; ?> @@ -68,8 +67,7 @@ if ($loadPartialPage) { <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" - hx-boost="false"></a> + <a id="rightPaneActivator" href="/mobilepane/right" class="inlineIcon material-symbols notifications"></a> <?php endif; ?> <?php if ($user == null): @@ -83,10 +81,10 @@ if ($loadPartialPage) { </a> <?php endif; ?> </nav> - <?php if ($loadPartialPage) - goto skipToMainContent; ?> </header> - <main> + <?php if ($loadPartialPage) + goto skipToMainContent; ?> + <main id="main" hx-swap-oob="true"> <div> <section id="leftPane"> <?php |
