From e0588a6113ff6b3c1000fa6c82629f81fb5e05b5 Mon Sep 17 00:00:00 2001 From: winter Date: Sat, 15 Mar 2025 18:53:29 +0000 Subject: [refactor] move some templates to subdirs --- templates/actor/atom.php | 51 ++++++++++++++++++ templates/actor/avatar.php | 5 ++ templates/actor/profile.php | 83 ++++++++++++++++++++++++++++++ templates/actor/profile_block_button.php | 9 ++++ templates/actor/profile_editable.php | 40 ++++++++++++++ templates/actor/profile_follow_button.php | 20 +++++++ templates/actor/profile_page.php | 52 +++++++++++++++++++ templates/actor/profile_pending_follow.php | 21 ++++++++ templates/actor/profile_reset_avatar.php | 3 ++ templates/actor/rss.php | 46 +++++++++++++++++ 10 files changed, 330 insertions(+) create mode 100644 templates/actor/atom.php create mode 100644 templates/actor/avatar.php create mode 100644 templates/actor/profile.php create mode 100644 templates/actor/profile_block_button.php create mode 100644 templates/actor/profile_editable.php create mode 100644 templates/actor/profile_follow_button.php create mode 100644 templates/actor/profile_page.php create mode 100644 templates/actor/profile_pending_follow.php create mode 100644 templates/actor/profile_reset_avatar.php create mode 100644 templates/actor/rss.php (limited to 'templates/actor') diff --git a/templates/actor/atom.php b/templates/actor/atom.php new file mode 100644 index 0000000..8bd40fb --- /dev/null +++ b/templates/actor/atom.php @@ -0,0 +1,51 @@ +id/feed/$lang/feed.atom"); +$actorPage = path_to_uri("/@/$actor->handle"); + +echo ''; +?> + + + + <?= htmlspecialchars($actor->displayName) ?> — <?= GlobalSettings::getInstance()->get('instance.name') ?> + + created->format(DateTime::ATOM) ?> + + displayName) ?> + + + + + Digitigrade + avatar)): ?> + avatar ?> + + displayName) ?> + + + privacy->scope != NotePrivacyScope::PUBLIC || $note->inReplyTo != null) { + continue; + } + ?> + + id") ?> + <![CDATA[<?= htmlspecialchars(substr($note->plainContent, 0, 50), double_encode: false) ?>]]> + modified ?? $note->created)->format(DateTime::ATOM) ?> + handle/note/$note->id") ?>" /> + getBestContentAsHtml() ?>]]> + attachments as $file): ?> + + + + + \ No newline at end of file diff --git a/templates/actor/avatar.php b/templates/actor/avatar.php new file mode 100644 index 0000000..16b529b --- /dev/null +++ b/templates/actor/avatar.php @@ -0,0 +1,5 @@ +avatar)): ?> + + + + \ No newline at end of file diff --git a/templates/actor/profile.php b/templates/actor/profile.php new file mode 100644 index 0000000..be27c86 --- /dev/null +++ b/templates/actor/profile.php @@ -0,0 +1,83 @@ + +
+
+ + + + + $actor]); ?> + + + + +
+
displayName) ?>
+
pronouns) ?>
+
@getFullHandle() ?>
+
created->format('Y-m-d')) ?> +
+
+ +
+ + isLocal && isset($actor->homepage)): ?> +
  • + + + + +
  • + + getBool('profile.rssEnabled')): ?> + +
  • + id/feed/$lang/feed.rss" ?>" target="_blank" type="application/rss+xml"> + + + +
  • +
  • + id/feed/$lang/feed.atom" ?>" target="_blank" type="application/atom+xml"> + + + +
  • + + actor != $actor): ?> +
  • $user, 'actor' => $actor]) ?>
  • + + +
    + +
    + + bio) && $actor->bio != '') { ?> +
    bio) ?>
    + __('user.profile.bio.placeholder')]); + } ?> + + id != $user->actor->id): ?> +
    + followsPending($user->actor)) + call_template('actor/profile_pending_follow', ['subject' => $actor, 'object' => $user->actor]); ?> + follows($user->actor)): ?> + + + $actor, 'user' => $user]); ?> +
    + id == $user->actor->id): ?> +
    + +
    + + +
    \ No newline at end of file diff --git a/templates/actor/profile_block_button.php b/templates/actor/profile_block_button.php new file mode 100644 index 0000000..1b71613 --- /dev/null +++ b/templates/actor/profile_block_button.php @@ -0,0 +1,9 @@ +actor->blocks($actor); +$action = $blocks ? 'unblock' : 'block'; +?> + \ No newline at end of file diff --git a/templates/actor/profile_editable.php b/templates/actor/profile_editable.php new file mode 100644 index 0000000..fc969bd --- /dev/null +++ b/templates/actor/profile_editable.php @@ -0,0 +1,40 @@ +
    +
    + $actor]); ?> +
    +
    +
    + + +
    +
    + + +
    +
    +
    @getFullHandle() ?>
    +
    created->format('Y-m-d')) ?>
    +
    +
    + +
    + + + +
    + +
    + + +
    + +
    + + +
    +
    \ 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' +}; +?> + \ No newline at end of file diff --git a/templates/actor/profile_page.php b/templates/actor/profile_page.php new file mode 100644 index 0000000..9c11dd6 --- /dev/null +++ b/templates/actor/profile_page.php @@ -0,0 +1,52 @@ + "$actor->displayName - @" . $actor->getFullHandle(), + 'renderTitleHeading' => false, + 'ogTitle' => $actor->displayName, + 'ogDesc' => $actor->bio, + 'ogImage' => $actor->avatar ?? path_to_uri('/static/default-avatar.png'), + 'ogType' => 'profile', + 'ogHandle' => '@' . $actor->getFullHandle(true), + 'headLinks' => ($actorUser != null && (new UserSettings($actorUser))->getBool('profile.rssEnabled')) ? [ + [ + 'rel' => 'alternate', + 'type' => 'application/rss+xml', + 'href' => "/actor/$actor->id/feed/$lang/feed.rss", + 'title' => __('user.profile.feed.rss') + ], + [ + 'rel' => 'alternate', + 'type' => 'application/atom+xml', + 'href' => "/actor/$actor->id/feed/$lang/feed.atom", + 'title' => __('user.profile.feed.atom') + ] + ] : [] +], function () use ($actor) { + $user = UserAccount::findByCurrentSession(); + + call_template('actor/profile', ['actor' => $actor]); + echo '
    '; + $notes = Note::findAllWithAuthor($actor, 20); + if (count($notes) == 0) { + call_template('placeholder_text', ['message' => __('user.notes.placeholder')]); + } elseif ($user != null && $user->actor->blocks($actor)) { + call_template('placeholder_text', ['message' => __('user.profile.notesHidden')]); + } else { + foreach ($notes as $n) { + if ($n->isViewableBy($user)) + call_template('note/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/actor/profile_pending_follow.php b/templates/actor/profile_pending_follow.php new file mode 100644 index 0000000..2f49fcd --- /dev/null +++ b/templates/actor/profile_pending_follow.php @@ -0,0 +1,21 @@ + + +
    + +
    + + + +
    + + + +
    + + \ No newline at end of file diff --git a/templates/actor/profile_reset_avatar.php b/templates/actor/profile_reset_avatar.php new file mode 100644 index 0000000..86a3507 --- /dev/null +++ b/templates/actor/profile_reset_avatar.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/templates/actor/rss.php b/templates/actor/rss.php new file mode 100644 index 0000000..03fc4f5 --- /dev/null +++ b/templates/actor/rss.php @@ -0,0 +1,46 @@ +'; +?> + + + + <?= htmlspecialchars($actor->displayName) ?> — <?= GlobalSettings::getInstance()->get('instance.name') ?> + + handle") ?> + displayName)) ?> + + + avatar)): ?> + + avatar ?> + + + + privacy->scope != NotePrivacyScope::PUBLIC || $note->inReplyTo != null) { + continue; + } + ?> + + handle/note/$note->id") ?> + id") ?> + <![CDATA[<?= htmlspecialchars(substr($note->plainContent, 0, 50), double_encode: false) ?>]]> + getBestContentAsHtml() ?>]]> + created->format(DateTime::RSS) ?> + attachments as $file): ?> + + + + + + \ No newline at end of file -- cgit v1.3