diff options
| author | winter | 2025-01-14 20:44:49 +0000 |
|---|---|---|
| committer | winter | 2025-01-14 20:44:49 +0000 |
| commit | 4d7f8450d9a842e2f69754ccaa4202710328dcb7 (patch) | |
| tree | 60e90ff7ebbf069e04faf665d68861970eaee000 /templates | |
| parent | 0f427b4b6f75134b2c25b7e5f8a515be2cec97f5 (diff) | |
add (un)follow button to profile
also other stuff i forgot what exactly
Diffstat (limited to 'templates')
| -rw-r--r-- | templates/actor_profile.php | 14 | ||||
| -rw-r--r-- | templates/actor_profile_follow_button.php | 20 | ||||
| -rw-r--r-- | templates/actor_profile_page.php | 13 | ||||
| -rw-r--r-- | templates/login_form.php | 2 | ||||
| -rw-r--r-- | templates/placeholder_text.php | 13 | ||||
| -rw-r--r-- | templates/reply_button.php | 6 | ||||
| -rw-r--r-- | templates/reply_form.php | 2 | ||||
| -rw-r--r-- | templates/write_note_form.php | 2 |
8 files changed, 61 insertions, 11 deletions
diff --git a/templates/actor_profile.php b/templates/actor_profile.php index 8a97bd8..c480d21 100644 --- a/templates/actor_profile.php +++ b/templates/actor_profile.php @@ -1,3 +1,8 @@ +<?php +use Digitigrade\Model\UserAccount; + +$user = UserAccount::findByCurrentSession(); +?> <div class="fullProfile"> <div class="basicInfo"> <?php call_template('actor_avatar', ['actor' => $actor]); ?> @@ -18,4 +23,13 @@ <?php } else { call_template('placeholder_text', ['message' => __('user.profile.bio.placeholder')]); } ?> + + <?php if (isset($user) && $actor->id != $user->actor->id): ?> + <div class="followInfo"> + <?php if ($actor->follows($user->actor)): ?> + <?= __('user.profile.followsYou') ?> + <?php endif; ?> + <?php call_template('actor_profile_follow_button', ['actor' => $actor, 'user' => $user]); ?> + </div> + <?php endif; ?> </div>
\ No newline at end of file diff --git a/templates/actor_profile_follow_button.php b/templates/actor_profile_follow_button.php new file mode 100644 index 0000000..e2b314d --- /dev/null +++ b/templates/actor_profile_follow_button.php @@ -0,0 +1,20 @@ +<?php +use Digitigrade\Model\FollowRelation; +use Digitigrade\Model\FollowRelationStatus; + +$relation = FollowRelation::findByActors($user->actor, $actor); +$state = match ($relation?->status) { + null => $actor->requestToFollow ? 'request' : 'normal', + FollowRelationStatus::PENDING => 'pending', + FollowRelationStatus::ACTIVE => 'active' +}; +?> +<button class="<?= $state == 'active' ? 'secondary' : 'primary' ?>" + hx-post="/fragment/actor/<?= $actor->id ?>/followButton" hx-swap="outerHTML" <?= $state == 'pending' ? 'disabled' : '' ?> hx-disabled-elt="this"> + <?= __(match ($state) { + 'active' => 'user.profile.unfollow.action', + 'pending' => 'user.profile.follow.pending', + 'request' => 'user.profile.requestToFollow.action', + 'normal' => 'user.profile.follow.action' + }) ?> +</button>
\ No newline at end of file diff --git a/templates/actor_profile_page.php b/templates/actor_profile_page.php index e7d28b7..649069d 100644 --- a/templates/actor_profile_page.php +++ b/templates/actor_profile_page.php @@ -9,11 +9,16 @@ call_template('skeleton', [ global $actor; call_template('actor_profile', ['actor' => $actor]); echo '<hr>'; - $notes = Note::findAllWithAuthor($actor, 50); + $notes = Note::findAllWithAuthor($actor, 20); if (count($notes) == 0) { call_template('placeholder_text', ['message' => __('user.notes.placeholder')]); - } - foreach ($notes as $n) { - call_template('note', ['note' => $n]); + } else { + foreach ($notes as $n) { + call_template('note', ['note' => $n]); + } + $countNotShown = Note::countWithAuthor($actor) - count($notes); + if ($countNotShown >= 0) { + call_template('placeholder_text', ['count' => $countNotShown]); + } } });
\ No newline at end of file diff --git a/templates/login_form.php b/templates/login_form.php index 2c32164..74bb823 100644 --- a/templates/login_form.php +++ b/templates/login_form.php @@ -12,7 +12,7 @@ <label for="rememberMeInput"><?= __('login.rememberMe') ?></label> </div> <div class="row"> - <button><?= __('login.action') ?></button> + <button class="primary"><?= __('login.action') ?></button> </div> <?php if ($failed ?? false): ?> <p class="error"><?= __('login.failed') ?></p> diff --git a/templates/placeholder_text.php b/templates/placeholder_text.php index f529de9..2fc3d3d 100644 --- a/templates/placeholder_text.php +++ b/templates/placeholder_text.php @@ -1 +1,12 @@ -<p class="placeholder"><?= $message ?? __('placeholder') ?></p>
\ No newline at end of file +<?php +$text = __('placeholder'); +if (isset($message)) { + $text = $message; +} elseif (isset($count)) { + if ($count == 0) + $text = __('placeholder.noMoreItems'); + else + $text = sprintf(__('placeholder.moreItems'), $count); +} +?> +<p class="placeholder"><?= $text ?></p>
\ No newline at end of file diff --git a/templates/reply_button.php b/templates/reply_button.php index aeaeabd..4162d23 100644 --- a/templates/reply_button.php +++ b/templates/reply_button.php @@ -1,9 +1,9 @@ <?php use Digitigrade\Model\Note; -$icon = count(Note::findAllInThread($note, 2)) > 1 ? 'reply_all' : 'reply'; -$id = "interactButton-reply-$note->id" - ?> +$icon = $note->countReplies() > 0 ? 'reply_all' : 'reply'; +$id = "interactButton-reply-$note->id"; +?> <div class="interactButtonContainer reply"> <button title="<?= __('note.action.reply') ?>" class="icon material-symbols-outlined reply" id="<?= $id ?>" _="on click send toggle to [me, next .noteReplyForm] on toggle toggle .active on closest <div/>"><?= $icon ?></button> diff --git a/templates/reply_form.php b/templates/reply_form.php index 84d8121..f96eb5a 100644 --- a/templates/reply_form.php +++ b/templates/reply_form.php @@ -6,6 +6,6 @@ <textarea id="replyContent-<?= $note->id ?>" name="content" required></textarea> </div> <div class="row"> - <button><?= __('writeReply.action') ?></button> + <button class="primary"><?= __('writeReply.action') ?></button> </div> </form>
\ No newline at end of file diff --git a/templates/write_note_form.php b/templates/write_note_form.php index 38a9993..9b7c61c 100644 --- a/templates/write_note_form.php +++ b/templates/write_note_form.php @@ -4,6 +4,6 @@ <textarea name="content" id="noteContent" required></textarea> </div> <div class="row"> - <button><?= __('writeNote.action') ?></button> + <button class="primary"><?= __('writeNote.action') ?></button> </div> </form>
\ No newline at end of file |
