aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Digitigrade/Model/StorageObject.php31
-rw-r--r--locale/en_GB.json1
-rw-r--r--routes/note_fragment.php2
-rw-r--r--static/form.css14
-rw-r--r--static/misc.css17
-rw-r--r--static/note.css1
-rw-r--r--templates/write_note_form.php40
7 files changed, 87 insertions, 19 deletions
diff --git a/Digitigrade/Model/StorageObject.php b/Digitigrade/Model/StorageObject.php
index 28c77aa..9d4bc1a 100644
--- a/Digitigrade/Model/StorageObject.php
+++ b/Digitigrade/Model/StorageObject.php
@@ -108,4 +108,35 @@ class StorageObject extends Model {
}
return path_to_uri("/storage/$this->oid");
}
+
+ /**
+ * @return bool if this object is a supported image file
+ */
+ public function isImage(): bool {
+ return in_array($this->mimetype, [
+ 'image/apng',
+ 'image/avif',
+ 'image/gif',
+ 'image/jpeg',
+ 'image/png',
+ 'image/svg+xml',
+ 'image/webp',
+ ]);
+ }
+
+ /**
+ * @return bool if this object is a supported audio file
+ */
+ public function isAudio(): bool {
+ // TODO: be a bit more careful about what counts as supported
+ return str_starts_with($this->mimetype, 'audio/');
+ }
+
+ /**
+ * @return bool if this object is a supported video file
+ */
+ public function isVideo(): bool {
+ // TODO: be a bit more careful about what counts as supported
+ return str_starts_with($this->mimetype, 'video/');
+ }
} \ No newline at end of file
diff --git a/locale/en_GB.json b/locale/en_GB.json
index b0c6598..ddb3a19 100644
--- a/locale/en_GB.json
+++ b/locale/en_GB.json
@@ -76,6 +76,7 @@
"writeNote.summary.label": "Content warning (optional)",
"writeNote.scope.label": "Visibility",
"writeNote.action": "Post",
+ "writeNote.moreOptions": "More options",
"writeNote.mentions.label": "Mentioned users",
"writeNote.mentions.add.action": "Add a mention",
"writeNote.mentions.placeholder": "someone@social.example",
diff --git a/routes/note_fragment.php b/routes/note_fragment.php
index 916fc8d..21a5369 100644
--- a/routes/note_fragment.php
+++ b/routes/note_fragment.php
@@ -147,7 +147,7 @@ Router::getInstance()->mount('/fragment/note/attachmentPill', function (array $a
// store the file and return a pill for it
// TODO: allow other providers
$obj = StorageObject::createFromUpload(FilesystemStorage::class, $_FILES['file']);
- $type = str_starts_with($obj->mimetype, 'image/') ? 'image' : 'file';
+ $type = $obj->isImage() ? 'image' : 'file';
render_template('attachment_pill', [
'type' => $type,
'oid' => $obj->oid,
diff --git a/static/form.css b/static/form.css
index b82240e..8bcefde 100644
--- a/static/form.css
+++ b/static/form.css
@@ -77,6 +77,20 @@ form:not(.nopanel) {
}
}
+ details {
+ summary {
+ border-radius: var(--border-radius);
+ margin-bottom: var(--spacing-single);
+ padding: var(--spacing-single) var(--spacing-double);
+ background-color: var(--clr-secondary);
+ font-weight: bold;
+ cursor: pointer;
+ }
+ &[open] summary {
+ margin-bottom: var(--spacing-single);
+ }
+ }
+
.miniProfile {
display: grid;
grid-template-columns: max-content 1fr;
diff --git a/static/misc.css b/static/misc.css
index d9a491c..ab2ba35 100644
--- a/static/misc.css
+++ b/static/misc.css
@@ -143,6 +143,23 @@ pre {
}
}
+summary {
+ display: flex;
+ align-items: center;
+ gap: var(--spacing-single);
+
+ &::before {
+ display: inline-block;
+ width: 1em;
+ aspect-ratio: 1;
+ content: "";
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='m15 19l-1.425-1.4l4.6-4.6H2v-2h16.175L13.6 6.4L15 5l7 7z'/%3E%3C/svg%3E");
+ }
+}
+details[open] > summary::before {
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M9 19v-2h6.6L4 5.4L5.4 4L17 15.6V9h2v10z'/%3E%3C/svg%3E");
+}
+
[hidden] {
display: none !important;
}
diff --git a/static/note.css b/static/note.css
index c9b02d0..bc1e2ec 100644
--- a/static/note.css
+++ b/static/note.css
@@ -61,6 +61,7 @@ article.note {
padding: var(--spacing-single) var(--spacing-double);
background: var(--clr-warning-background);
margin: var(--spacing-single) 0;
+ cursor: pointer;
}
details[open] > summary {
margin-bottom: var(--spacing-half);
diff --git a/templates/write_note_form.php b/templates/write_note_form.php
index 82964c5..9294a7c 100644
--- a/templates/write_note_form.php
+++ b/templates/write_note_form.php
@@ -4,7 +4,8 @@
</form>
<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">
+ hx-disabled-elt="find button" _="on submit wait 1s then trigger update on #liveTimelineUpdater"
+ <?= ($_SERVER['REQUEST_METHOD'] == 'GET') ? 'hx-preserve' : '' ?>>
<div class="row miniProfile">
<a href="/@/<?= $actor->handle ?>">
<?php call_template('actor_avatar', ['actor' => $actor]); ?>
@@ -21,23 +22,26 @@
<textarea name="content" id="noteContent" required autocomplete="off"
placeholder="<?= __('writeNote.placeholder') ?>"></textarea>
</div>
- <div class="row">
- <label class="standalone"><?= __('writeNote.mentions.label') ?></label>
- <?php call_template('user_mention_pill'); ?>
- </div>
- <div class="row">
- <label class="standalone"><?= __('writeNote.attachments.label') ?></label>
- <?php call_template('attachment_pill'); ?>
- </div>
- <div class="row">
- <label for="noteScope"><?= __('writeNote.scope.label') ?></label>
- <select name="scope" id="noteScope" required autocomplete="off">
- <option value="none"><?= __('note.privacy.scope.none') ?></option>
- <option value="mutuals"><?= __('note.privacy.scope.mutuals') ?></option>
- <option value="followers"><?= __('note.privacy.scope.followers') ?></option>
- <option value="public" selected><?= __('note.privacy.scope.public') ?></option>
- </select>
- </div>
+ <details>
+ <summary><?= __('writeNote.moreOptions') ?></summary>
+ <div class="row">
+ <label class="standalone"><?= __('writeNote.mentions.label') ?></label>
+ <?php call_template('user_mention_pill'); ?>
+ </div>
+ <div class="row">
+ <label class="standalone"><?= __('writeNote.attachments.label') ?></label>
+ <?php call_template('attachment_pill'); ?>
+ </div>
+ <div class="row">
+ <label for="noteScope"><?= __('writeNote.scope.label') ?></label>
+ <select name="scope" id="noteScope" required autocomplete="off">
+ <option value="none"><?= __('note.privacy.scope.none') ?></option>
+ <option value="mutuals"><?= __('note.privacy.scope.mutuals') ?></option>
+ <option value="followers"><?= __('note.privacy.scope.followers') ?></option>
+ <option value="public" selected><?= __('note.privacy.scope.public') ?></option>
+ </select>
+ </div>
+ </details>
<div class="row">
<button class="primary"><?= __('writeNote.action') ?></button>
</div>