aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates
diff options
context:
space:
mode:
authorwinter2025-03-15 18:35:59 +0000
committerwinter2025-03-15 18:52:54 +0000
commit61b122e88cc6783b4d0cf5142a22002f8e558c60 (patch)
tree847b864a93f716157456891d4526077e5f0b93f7 /templates
parentcb904ef3fb05ab106d5e5e12f6273b8117db4216 (diff)
implement pages
Diffstat (limited to 'templates')
-rw-r--r--templates/formatting_hint.php5
-rw-r--r--templates/left_side_navigation.php4
-rw-r--r--templates/note.php19
-rw-r--r--templates/note_page.php36
-rw-r--r--templates/pages_list_item.php11
-rw-r--r--templates/pages_list_page.php19
-rw-r--r--templates/pages_new_form.php26
-rw-r--r--templates/pages_new_page.php4
-rw-r--r--templates/reply_form.php6
-rw-r--r--templates/write_note_form.php6
10 files changed, 122 insertions, 14 deletions
diff --git a/templates/formatting_hint.php b/templates/formatting_hint.php
new file mode 100644
index 0000000..e7163ac
--- /dev/null
+++ b/templates/formatting_hint.php
@@ -0,0 +1,5 @@
+<span class="hint">
+ <span class="inlineIcon material-symbols markdown-outline"></span>
+ <span><?= sprintf(__('writeNote.formattingHint'),
+ '<a href="https://commonmark.org/help/" target="_blank">' . __('writeNote.formattingHint.markdown') . '</a>') ?></span>
+</span> \ No newline at end of file
diff --git a/templates/left_side_navigation.php b/templates/left_side_navigation.php
index 4cf8b55..5d7f368 100644
--- a/templates/left_side_navigation.php
+++ b/templates/left_side_navigation.php
@@ -12,6 +12,10 @@ if ($user != null) {
'label' => __('navigation.followRequests'),
'unreadCount' => FollowRelation::countWhere("object = ? AND status = 'pending'", [$user->actor->id])
], [
+ 'href' => '/pages',
+ 'icon' => 'article-outline',
+ 'label' => __('note.page.list.pageTitle')
+ ], [
'href' => '/preferences',
'icon' => 'tune',
'label' => __('preferences.pageTitle')
diff --git a/templates/note.php b/templates/note.php
index 759a7c7..c80eace 100644
--- a/templates/note.php
+++ b/templates/note.php
@@ -17,7 +17,7 @@ if ($user != null) {
$interactions = $note->getInteractionsWithAuthor($user->actor);
$interKinds = array_map(fn($inter) => $inter->kind, $interactions);
}
-$pathToSelf = '/@/' . $note->author->getFullHandle() . '/note/' . $note->id;
+$pathToSelf = $note->getLocalUiHref();
?>
<article class="note <?= ($selected ?? false) ? 'selected' : '' ?>">
@@ -36,9 +36,9 @@ $pathToSelf = '/@/' . $note->author->getFullHandle() . '/note/' . $note->id;
} ?>
</span>
<a class="timestamp" href="<?= htmlspecialchars($pathToSelf) ?>">
- <?= format_datetime($note->created, $prefs?->get('locale.timezone'))
+ <?= format_datetime($note->created)
. (isset($note->modified) && $note->modified != $note->created
- ? ' (' . format_datetime($note->modified, $prefs?->get('locale.timezone')) . ')'
+ ? ' (' . format_datetime($note->modified) . ')'
: ''
) ?>
</a>
@@ -81,7 +81,11 @@ $pathToSelf = '/@/' . $note->author->getFullHandle() . '/note/' . $note->id;
<summary><?= htmlspecialchars($note->summary) ?></summary>
<?php endif; ?>
<div class="content" lang="<?= $note->language ?>">
- <?= $note->getBestContentAsHtml() ?>
+ <?php if ($note->hasPage()): ?>
+ <?= __f('note.page.summaryMessage', htmlspecialchars($note->getPage()->title)) ?>
+ <?php else: ?>
+ <?= $note->getBestContentAsHtml() ?>
+ <?php endif; ?>
</div>
<?php if (count($note->attachments) > 0): ?>
@@ -105,6 +109,13 @@ $pathToSelf = '/@/' . $note->author->getFullHandle() . '/note/' . $note->id;
</details>
<?php endif; ?>
+ <?php if ($note->hasPage()): ?>
+ <a class="button secondary minWidth" href="<?= $note->getLocalUiHref(true) ?>">
+ <span class="material-symbols article-outline"></span>
+ <span><?= __('note.openPage') ?></span>
+ </a>
+ <?php endif; ?>
+
<div class="buttons">
<?php foreach (['like', 'dislike', 'reshare'] as $action) {
$kind = InteractionKind::from($action);
diff --git a/templates/note_page.php b/templates/note_page.php
new file mode 100644
index 0000000..647c64e
--- /dev/null
+++ b/templates/note_page.php
@@ -0,0 +1,36 @@
+<?php
+
+/** @var \Digitigrade\Model\Note $note */
+
+use Digitigrade\FormattingProvider;
+use Digitigrade\Model\UserAccount;
+use Digitigrade\UserSettings;
+
+$page = $note->getPage();
+
+call_template('skeleton', ['pageTitle' => $page->title, 'renderTitleHeading' => false], function () use ($note, $page) { ?>
+ <div class="notePage">
+ <article lang="<?= htmlspecialchars($note->language) ?>">
+ <h1><?= htmlspecialchars($page->title) ?></h1>
+ <a class="pageAuthor" href="/@/<?= htmlspecialchars($note->author->getFullHandle()) ?>">
+ <?php call_template('actor_avatar', ['actor' => $note->author]); ?>
+ <span><?= __f(
+ 'note.page.author',
+ '<span class="displayName">' . htmlspecialchars($note->author->displayName) . '</span>'
+ ) ?></span>
+ </a>
+ <div class="created">
+ <?= __f('note.page.created', format_datetime($note->created)) ?>
+ </div>
+ <?php if (isset($note->modified) && $note->modified != $note->created): ?>
+ <div class="modified">
+ <?= __f('note.page.modified', format_datetime($note->modified)) ?>
+ </div>
+ <?php endif; ?>
+ <hr>
+ <div class="pageContent">
+ <?= $page->getBestContentAsHtml() ?>
+ </div>
+ </article>
+ </div>
+<?php }); \ No newline at end of file
diff --git a/templates/pages_list_item.php b/templates/pages_list_item.php
new file mode 100644
index 0000000..7944956
--- /dev/null
+++ b/templates/pages_list_item.php
@@ -0,0 +1,11 @@
+<?php
+/** @var \Digitigrade\Model\Note $note */
+$page = $note->getPage();
+?>
+<a class="pageItem" href="<?= htmlspecialchars($note->getLocalUiHref(true)) ?>">
+ <?= call_template('actor_avatar', ['actor' => $note->author]) ?>
+ <div>
+ <div class="title"><?= htmlspecialchars($page->title) ?></div>
+ <div class="author"><?= htmlspecialchars($note->author->displayName) ?></div>
+ </div>
+</a> \ No newline at end of file
diff --git a/templates/pages_list_page.php b/templates/pages_list_page.php
new file mode 100644
index 0000000..2dd1af2
--- /dev/null
+++ b/templates/pages_list_page.php
@@ -0,0 +1,19 @@
+<?php
+
+use Digitigrade\Model\Note;
+
+call_template('skeleton', ['pageTitle' => __('note.page.list.pageTitle')], function () {
+ ?>
+ <a class="button secondary margined" href="/pages/new"><?= __('note.page.new.pageTitle') ?></a>
+ <?php
+
+ $notes = Note::findAllWithExtension(Note::EXTENSION_PAGES, 20);
+ foreach ($notes as $note) {
+ call_template('pages_list_item', ['note' => $note]);
+ }
+ if (count($notes) == 0) {
+ call_template('placeholder_text');
+ } else {
+ call_template('placeholder_text', ['count' => Note::countWithExtension(Note::EXTENSION_PAGES) - count($notes)]);
+ }
+}); \ No newline at end of file
diff --git a/templates/pages_new_form.php b/templates/pages_new_form.php
new file mode 100644
index 0000000..a8dde16
--- /dev/null
+++ b/templates/pages_new_form.php
@@ -0,0 +1,26 @@
+<form id="writePageForm" hx-post="" hx-disabled-elt="find button">
+ <div class="row">
+ <label for="newPageTitle"><?= __('note.page.new.title.label') ?></label>
+ <input type="text" id="newPageTitle" name="title" required>
+ </div>
+
+ <div class="row">
+ <label for="newPageBody"><?= __('note.page.new.body.label') ?></label>
+ <textarea id="newPageBody" name="body" required></textarea>
+ <?php call_template('formatting_hint'); ?>
+ </div>
+
+ <div class="row">
+ <label for="newPageScope"><?= __('writeNote.scope.label') ?></label>
+ <select name="scope" id="newPageScope" 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>
+
+ <div class="row">
+ <button type="submit" class="primary"><?= __('note.page.new.action') ?></button>
+ </div>
+</form> \ No newline at end of file
diff --git a/templates/pages_new_page.php b/templates/pages_new_page.php
new file mode 100644
index 0000000..e047b99
--- /dev/null
+++ b/templates/pages_new_page.php
@@ -0,0 +1,4 @@
+<?php
+call_template('skeleton', ['pageTitle' => __('note.page.new.pageTitle')], function () {
+ call_template('pages_new_form');
+}); \ No newline at end of file
diff --git a/templates/reply_form.php b/templates/reply_form.php
index 59d2d53..2d8cfc3 100644
--- a/templates/reply_form.php
+++ b/templates/reply_form.php
@@ -30,11 +30,7 @@ $selectedScope = $note->privacy->scope->value;
value="<?= $summaryText ?>" placeholder="<?= __('writeNote.summary.label') ?>">
<textarea id="replyContent-<?= $note->id ?>" name="content" required autocomplete="off"
placeholder="<?= __('writeReply.placeholder') ?>"></textarea>
- <span class="hint">
- <span class="inlineIcon material-symbols markdown-outline"></span>
- <span><?= sprintf(__('writeNote.formattingHint'),
- '<a href="https://commonmark.org/help/" target="_blank">' . __('writeNote.formattingHint.markdown') . '</a>') ?></span>
- </span>
+ <?php call_template('formatting_hint'); ?>
</div>
<details>
<summary><?= __('writeNote.moreOptions') ?></summary>
diff --git a/templates/write_note_form.php b/templates/write_note_form.php
index 1062a27..394f7ba 100644
--- a/templates/write_note_form.php
+++ b/templates/write_note_form.php
@@ -21,11 +21,7 @@
placeholder="<?= __('writeNote.summary.label') ?>">
<textarea name="content" id="noteContent" required autocomplete="off"
placeholder="<?= __('writeNote.placeholder') ?>"></textarea>
- <span class="hint">
- <span class="inlineIcon material-symbols markdown-outline"></span>
- <span><?= sprintf(__('writeNote.formattingHint'),
- '<a href="https://commonmark.org/help/" target="_blank">' . __('writeNote.formattingHint.markdown') . '</a>') ?></span>
- </span>
+ <?php call_template('formatting_hint'); ?>
</div>
<details>
<summary><?= __('writeNote.moreOptions') ?></summary>