From 4d7f8450d9a842e2f69754ccaa4202710328dcb7 Mon Sep 17 00:00:00 2001
From: winter
Date: Tue, 14 Jan 2025 20:44:49 +0000
Subject: add (un)follow button to profile
also other stuff i forgot what exactly
---
templates/actor_profile.php | 14 ++++++++++++++
templates/actor_profile_follow_button.php | 20 ++++++++++++++++++++
templates/actor_profile_page.php | 13 +++++++++----
templates/login_form.php | 2 +-
templates/placeholder_text.php | 13 ++++++++++++-
templates/reply_button.php | 6 +++---
templates/reply_form.php | 2 +-
templates/write_note_form.php | 2 +-
8 files changed, 61 insertions(+), 11 deletions(-)
create mode 100644 templates/actor_profile_follow_button.php
(limited to 'templates')
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 @@
+
$actor]); ?>
@@ -18,4 +23,13 @@
__('user.profile.bio.placeholder')]);
} ?>
+
+ id != $user->actor->id): ?>
+
+ follows($user->actor)): ?>
+ = __('user.profile.followsYou') ?>
+
+ $actor, 'user' => $user]); ?>
+
+
\ 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 @@
+actor, $actor);
+$state = match ($relation?->status) {
+ null => $actor->requestToFollow ? 'request' : 'normal',
+ FollowRelationStatus::PENDING => 'pending',
+ FollowRelationStatus::ACTIVE => 'active'
+};
+?>
+
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'
+ }) ?>
+
\ 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 '
';
- $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 @@
= __('login.rememberMe') ?>
- = __('login.action') ?>
+ = __('login.action') ?>
= __('login.failed') ?>
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 @@
-= $message ?? __('placeholder') ?>
\ No newline at end of file
+
+= $text ?>
\ 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 @@
1 ? 'reply_all' : 'reply';
-$id = "interactButton-reply-$note->id"
- ?>
+$icon = $note->countReplies() > 0 ? 'reply_all' : 'reply';
+$id = "interactButton-reply-$note->id";
+?>
= $icon ?>
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 @@
- = __('writeReply.action') ?>
+ = __('writeReply.action') ?>
\ 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 @@
- = __('writeNote.action') ?>
+ = __('writeNote.action') ?>
\ No newline at end of file
--
cgit v1.3