diff options
Diffstat (limited to 'templates')
| -rw-r--r-- | templates/note/note.php | 5 | ||||
| -rw-r--r-- | templates/pages/editable.php | 39 | ||||
| -rw-r--r-- | templates/pages/page.php | 23 | ||||
| -rw-r--r-- | templates/pages/page_item.php | 55 |
4 files changed, 97 insertions, 25 deletions
diff --git a/templates/note/note.php b/templates/note/note.php index 0d48272..94f4895 100644 --- a/templates/note/note.php +++ b/templates/note/note.php @@ -113,8 +113,7 @@ if ($user != null) { ]); ?> <div class="right"> - <?php call_template('menu_button', [], function () { - global $note; + <?php call_template('menu_button', [], function () use ($note) { $user = UserAccount::findByCurrentSession(); ?> <li> @@ -128,7 +127,7 @@ if ($user != null) { <span><?= __('action.share') ?></span> </button> </li> - <?php if ($note->author->isLocal && ($note->author == $user?->actor || $user?->isAdmin)): ?> + <?php if ($note->author->isLocal && ($note->author == $user?->actor || $user?->isAdmin) && !$note->hasPage()): ?> <li> <button hx-get="/fragment/note/<?= $note->id ?>/edit" hx-target="closest .note" hx-swap="outerHTML"> <span class="material-symbols edit-outline"></span> diff --git a/templates/pages/editable.php b/templates/pages/editable.php new file mode 100644 index 0000000..67c97ca --- /dev/null +++ b/templates/pages/editable.php @@ -0,0 +1,39 @@ +<article> + <form class="pageEditForm nobackground" hx-post="/fragment/page/<?= $note->id ?>/edit" hx-target="closest article" + hx-swap="outerHTML"> + <div class="row"> + <label for="pageTitle"><?= __('note.page.new.title.label') ?></label> + <input type="text" id="pageTitle" name="title" value="<?= htmlspecialchars($page->title) ?>" required> + </div> + + <div class="row"> + <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> + + <div class="row"> + <label for="pageBody"><?= __('note.page.new.body.label') ?></label> + <textarea id="pageBody" name="body" required><?= $page->content['text/markdown'] ?></textarea> + </div> + + <div class="row actionButtons"> + <button type="button" class="secondary" hx-get="/fragment/page/<?= $note->id ?>" hx-target="closest article" + hx-swap="outerHTML"><?= __('form.discardChanges') ?></button> + <button type="submit" class="primary"><?= __('form.saveChanges') ?></button> + </div> + </form> +</article>
\ No newline at end of file diff --git a/templates/pages/page.php b/templates/pages/page.php index 97cea6d..4babb9d 100644 --- a/templates/pages/page.php +++ b/templates/pages/page.php @@ -13,27 +13,6 @@ call_template('skeleton', [ 'ogHandle' => '@' . $note->author->getFullHandle(true) ], 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> + <?php call_template('pages/page_item', ['note' => $note, 'page' => $page]); ?> </div> <?php });
\ No newline at end of file diff --git a/templates/pages/page_item.php b/templates/pages/page_item.php new file mode 100644 index 0000000..201a2f9 --- /dev/null +++ b/templates/pages/page_item.php @@ -0,0 +1,55 @@ +<?php + +use Digitigrade\Model\UserAccount; + +/** @var \Digitigrade\Model\Note $note */ +/** @var \Digitigrade\Page $page */ + +?> +<article lang="<?= htmlspecialchars($note->language) ?>"> + <div class="pageHeader"> + <div> + <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; ?> + </div> + <div class="pageActions"> + <?php call_template('menu_button', [], function () use ($note, $page) { + $user = UserAccount::findByCurrentSession(); + if ($note->author->isLocal && ($note->author == $user?->actor || $user?->isAdmin)) { ?> + <li> + <button hx-get="/fragment/page/<?= $note->id ?>/edit" hx-target="closest article" hx-swap="outerHTML"> + <span class="material-symbols edit-outline"></span> + <span><?= __('note.action.edit') ?></span> + </button> + </li> + <li> + <button hx-delete="/fragment/note/<?= $note->id ?>" + hx-confirm="<?= __('note.action.delete.confirmation') ?>" hx-target="closest article" + hx-swap="delete" _="on htmx:afterOnLoad go back"> + <span class="material-symbols delete-outline"></span> + <span><?= __('note.action.delete') ?></span> + </button> + </li> + <?php } + }); ?> + </div> + </div> + <hr> + <div class="pageContent"> + <?= $page->getBestContentAsHtml() ?> + </div> +</article>
\ No newline at end of file |
