diff options
| -rw-r--r-- | Digitigrade/Model/Interaction.php | 2 | ||||
| -rw-r--r-- | locale/en_GB.json | 2 | ||||
| -rw-r--r-- | routes/actor_profile_fragment.php | 7 | ||||
| -rw-r--r-- | routes/note_fragment.php | 2 | ||||
| -rw-r--r-- | static/default-avatar.png | bin | 0 -> 8960 bytes | |||
| -rw-r--r-- | static/default-avatar.svg | 57 | ||||
| -rw-r--r-- | static/form.css | 30 | ||||
| -rw-r--r-- | static/notifications.css | 1 | ||||
| -rw-r--r-- | templates/actor_avatar.php | 2 | ||||
| -rw-r--r-- | templates/actor_profile_editable.php | 3 | ||||
| -rw-r--r-- | templates/actor_profile_reset_avatar.php | 3 | ||||
| -rw-r--r-- | templates/mobilepane_left.php | 4 | ||||
| -rw-r--r-- | templates/skeleton.php | 2 | ||||
| -rw-r--r-- | templates/write_note_form.php | 9 |
14 files changed, 60 insertions, 64 deletions
diff --git a/Digitigrade/Model/Interaction.php b/Digitigrade/Model/Interaction.php index cf2be01..883bf6c 100644 --- a/Digitigrade/Model/Interaction.php +++ b/Digitigrade/Model/Interaction.php @@ -72,7 +72,7 @@ class Interaction extends PushableModel implements Notifyable { return $this->target->plainContent; } public function getNotificationImageUrl(): ?string { - return $this->author->avatar; + return $this->author->avatar ?? '/static/default-avatar.png'; } public function getNotificationImageLink(): ?string { return '/@/' . $this->author->getFullHandle(); diff --git a/locale/en_GB.json b/locale/en_GB.json index fa98b49..084ecb1 100644 --- a/locale/en_GB.json +++ b/locale/en_GB.json @@ -12,6 +12,8 @@ "user.profile.pendingFollowsYou": "Wants to follow you", "user.profile.displayName": "Display name", "user.profile.changeAvatar": "Choose a new avatar image", + "user.profile.resetAvatar": "Reset avatar", + "user.profile.avatarReset": "Avatar reset!", "user.profile.bio": "Bio", "user.notes.placeholder": "This user hasn't posted anything yet.", "timeline.global": "Global timeline", diff --git a/routes/actor_profile_fragment.php b/routes/actor_profile_fragment.php index 0a07924..0a2a881 100644 --- a/routes/actor_profile_fragment.php +++ b/routes/actor_profile_fragment.php @@ -70,4 +70,11 @@ Router::getInstance()->mount('/fragment/profile', function (array $args) { } else { render_template('actor_profile_editable', ['actor' => $actor]); } +}); + +Router::getInstance()->mount('/fragment/profile/resetAvatar', function (array $args) { + $user = UserAccount::requireByCurrentSession(); + $user->actor->avatar = null; + $user->actor->save(); + render_template('actor_profile_reset_avatar', ['reset' => true]); });
\ No newline at end of file diff --git a/routes/note_fragment.php b/routes/note_fragment.php index 5fe979a..02399e6 100644 --- a/routes/note_fragment.php +++ b/routes/note_fragment.php @@ -84,5 +84,5 @@ Router::getInstance()->mount('/fragment/note', function (array $args) { $note->processTimelineAdditions(); $note->processNotifications(); } - render_template('write_note_form'); + render_template('write_note_form', ['actor' => $author->actor]); });
\ No newline at end of file diff --git a/static/default-avatar.png b/static/default-avatar.png Binary files differnew file mode 100644 index 0000000..3d920e5 --- /dev/null +++ b/static/default-avatar.png diff --git a/static/default-avatar.svg b/static/default-avatar.svg deleted file mode 100644 index 5d734a9..0000000 --- a/static/default-avatar.svg +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> - -<svg - width="64" - height="64" - viewBox="0 0 64 64" - version="1.1" - id="svg1" - xmlns="http://www.w3.org/2000/svg" - xmlns:svg="http://www.w3.org/2000/svg"> - <defs - id="defs1" /> - <g - id="layer1"> - <g - id="g7" - transform="matrix(0.81915204,-0.61997856,0.57357644,0.88542115,-9.8389023,27.187623)"> - <ellipse - style="opacity:1;fill:#341e55;fill-opacity:0.271113;stroke-width:1.07054" - id="path3" - cx="-7.422678" - cy="25.878199" - rx="6.7873225" - ry="8.2171621" - transform="matrix(0.63285055,-0.77427397,0.72122314,0.69270281,0,0)" /> - <ellipse - style="opacity:1;fill:#341e55;fill-opacity:0.271113;stroke-width:1.07172" - id="path4" - cx="25.941027" - cy="20.172144" - rx="5.8635988" - ry="8.2372408" - transform="matrix(0.97464087,-0.22377484,0.12154217,0.99258627,0,0)" /> - <ellipse - style="opacity:1;fill:#341e55;fill-opacity:0.271113;stroke-width:1.07161" - id="path5" - cx="43.196301" - cy="19.089205" - rx="5.8324995" - ry="8.2224894" - transform="matrix(0.99865107,-0.05192343,-0.05003473,0.99874748,0,0)" /> - <ellipse - style="opacity:1;fill:#341e55;fill-opacity:0.271113;stroke-width:0.994231" - id="path6" - cx="62.002583" - cy="37.127773" - rx="6.58569" - ry="7.9303436" - transform="matrix(0.98583265,-0.16773191,-0.15120581,0.9885023,0,0)" /> - <path - style="opacity:1;fill:#341e55;fill-opacity:0.271113;stroke-width:1.06883" - d="M 35.091789,26.612588 C 21.38302,26.75655 21.00167,31.399568 19.422233,37.866324 c -1.378975,5.645992 -1.597634,10.395818 3.631793,11.03401 5.229427,0.638192 5.585526,-3.294926 11.300259,-3.592055 5.714733,-0.29713 5.443755,4.454819 10.279299,4.203403 4.835543,-0.251418 3.554548,-9.06409 2.291899,-13.644155 -1.205836,-4.373989 -5.245485,-9.483724 -11.833694,-9.254939 z" - id="path7" /> - </g> - </g> -</svg> diff --git a/static/form.css b/static/form.css index 00a4366..c7a1873 100644 --- a/static/form.css +++ b/static/form.css @@ -32,7 +32,7 @@ form { textarea { resize: vertical; } - button { + button:not(.inline) { width: 100%; } .error { @@ -60,6 +60,34 @@ form { &#writeNoteForm { max-width: 100%; + + .miniProfile { + display: grid; + grid-template-columns: max-content 1fr; + margin-bottom: var(--spacing-double); + gap: var(--spacing-double); + + img.avatar { + border-radius: var(--border-radius); + width: var(--avatar-size); + aspect-ratio: 1; + display: block; + } + .basicInfo { + display: grid; + grid-auto-flow: row; + align-content: start; + .displayName { + font-size: var(--font-big-size); + font-weight: bold; + text-decoration: none; + color: inherit; + &:hover { + text-decoration: underline; + } + } + } + } } &.settings { diff --git a/static/notifications.css b/static/notifications.css index 98a8fbb..272e3e6 100644 --- a/static/notifications.css +++ b/static/notifications.css @@ -39,6 +39,7 @@ width: var(--avatar-size); border-radius: var(--border-radius); aspect-ratio: 1; + display: block; } .notifContent { display: grid; diff --git a/templates/actor_avatar.php b/templates/actor_avatar.php index 439072b..16b529b 100644 --- a/templates/actor_avatar.php +++ b/templates/actor_avatar.php @@ -1,5 +1,5 @@ <?php if (isset($actor->avatar)): ?> <img class="avatar" src="<?= $actor->avatar ?>"> <?php else: ?> - <img class="avatar" src="/static/default-avatar.svg"> + <img class="avatar" src="/static/default-avatar.png"> <?php endif; ?>
\ No newline at end of file diff --git a/templates/actor_profile_editable.php b/templates/actor_profile_editable.php index 2c0ef5c..1370e53 100644 --- a/templates/actor_profile_editable.php +++ b/templates/actor_profile_editable.php @@ -14,7 +14,8 @@ <div class="row"> <label for="profileAvatar"><?= __('user.profile.changeAvatar') ?></label> - <input type="file" id="profileAvatar" name="avatar" accept="image/*"> + <input style="display: inline-block" type="file" id="profileAvatar" name="avatar" accept="image/*"> + <?php call_template('actor_profile_reset_avatar'); ?> </div> <div class="row"> 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 @@ +<button type="button" class="secondary inline" hx-post="/fragment/profile/resetAvatar" <?= ($reset ?? false) ? 'disabled' : '' ?>> + <?= __(($reset ?? false) ? 'user.profile.avatarReset' : 'user.profile.resetAvatar') ?> +</button>
\ No newline at end of file diff --git a/templates/mobilepane_left.php b/templates/mobilepane_left.php index f71279c..daab401 100644 --- a/templates/mobilepane_left.php +++ b/templates/mobilepane_left.php @@ -1,6 +1,8 @@ <?php use Digitigrade\GlobalSettings; +use Digitigrade\Model\UserAccount; +$user = UserAccount::requireByCurrentSession(); $settings = GlobalSettings::getInstance(); ?> <!DOCTYPE html> @@ -29,7 +31,7 @@ $settings = GlobalSettings::getInstance(); ]; call_template('navigation_links', ['links' => $links]); - call_template('write_note_form'); + call_template('write_note_form', ['actor' => $user->actor]); call_template('left_side_navigation'); ?> <p class="versionInfo"><?= sprintf(__('version'), get_version()) ?></p> diff --git a/templates/skeleton.php b/templates/skeleton.php index f7670c0..afe7321 100644 --- a/templates/skeleton.php +++ b/templates/skeleton.php @@ -59,7 +59,7 @@ $settings = GlobalSettings::getInstance(); <section id="leftPane"> <?php if ($user != null) { - call_template('write_note_form'); + call_template('write_note_form', ['actor' => $user->actor]); } call_template('left_side_navigation'); ?> diff --git a/templates/write_note_form.php b/templates/write_note_form.php index 2d50896..914c48b 100644 --- a/templates/write_note_form.php +++ b/templates/write_note_form.php @@ -1,5 +1,14 @@ <form id="writeNoteForm" action="/todo" method="post" hx-post="/fragment/note" hx-swap="outerHTML" hx-disabled-elt="find button" _="on submit wait 1s then trigger update on #liveTimelineUpdater"> + <div class="row miniProfile"> + <a href="/@/<?= $actor->handle ?>"> + <?php call_template('actor_avatar', ['actor' => $actor]); ?> + </a> + <div class="basicInfo"> + <a class="displayName" href="/@/<?= $actor->handle ?>"><?= $actor->displayName ?></a> + <div class="handle">@<?= $actor->handle ?></div> + </div> + </div> <div class="row"> <label for="noteContent"><?= __('writeNote.label') ?></label> <textarea name="content" id="noteContent" required autocomplete="off"></textarea> |
