1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
<?php
/** @var \Digitigrade\Model\Note $note */
use Digitigrade\Model\Actor;
use Digitigrade\Model\InteractionKind;
use Digitigrade\Model\UserAccount;
use Digitigrade\UserSettings;
$MAX_PREVIEW_CARDS = 1;
$user = UserAccount::findByCurrentSession();
$prefs = $user ? new UserSettings($user) : null;
$interKinds = [];
if ($user != null) {
$interactions = $note->getInteractionsWithAuthor($user->actor);
$interKinds = array_map(fn($inter) => $inter->kind, $interactions);
}
?>
<article class="note <?= ($selected ?? false) ? 'selected' : '' ?>">
<a href="/@/<?= $note->author->getFullHandle() ?>">
<?php call_template('actor/avatar', ['actor' => $note->author]); ?>
</a>
<div>
<?php call_template('note/info_line', ['note' => $note]); ?>
<?php if (isset($note->inReplyTo)): ?>
<div class="replyInfo">
<span class="material-symbols reply inlineIcon"></span>
<a
href="/@/<?= htmlspecialchars($note->inReplyTo->author->getFullHandle()) ?>/note/<?= $note->inReplyTo->id ?>">
<?= __f('note.info.replyTo',
'<b>' . htmlspecialchars($note->inReplyTo->author->displayName)) . '</b>' ?>
</a>
</div>
<?php elseif (count($note->mentions) > 0): ?>
<div class="replyInfo">
<span class="material-symbols alternate-email inlineIcon"></span>
<span>
<?= __f('note.info.mentions', implode(', ', array_map(
fn(Actor $m) => '<b><a href="/@/' . htmlspecialchars($m->getFullHandle()) . '">' . htmlspecialchars($m->displayName) . '</a></b>',
$note->mentions
))) ?>
</span>
</div>
<?php endif; ?>
<?php if (isset($note->modified) && $note->modified != $note->created): ?>
<div class="modifiedInfo">
<span class="material-symbols edit-outline inlineIcon"></span>
<span><?= __f('note.info.modified', format_datetime($note->modified)) ?></span>
</div>
<?php endif; ?>
<?php if (isset($note->summary)): ?>
<details>
<summary><?= htmlspecialchars($note->summary) ?></summary>
<?php endif; ?>
<div class="content" lang="<?= $note->language ?>">
<?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): ?>
<div class="attachments">
<?php foreach ($note->attachments as $attachment) {
call_template('note/attachment', ['attachment' => $attachment]);
} ?>
</div>
<?php endif; ?>
<?php
$i = 0;
foreach ($note->getLinkPreviews() as $preview) {
call_template('note/link_preview', ['preview' => $preview]);
if (++$i > $MAX_PREVIEW_CARDS)
break;
}
?>
<?php if (isset($note->summary)): ?>
</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);
call_template('note/interaction_button', [
'action' => $action,
'note' => $note,
'active' => in_array($kind, $interKinds),
'count' => $note->countInteractionsOfKind($kind),
'disabled' => !$note->isInteractibleBy($action, $user)
]);
}
call_template('note/reply_button', [
'note' => $note,
'count' => $note->countReplies(),
'disabled' => !$note->isInteractibleBy('reply', $user)
]);
?>
<div class="right">
<?php call_template('menu_button', [], function () use ($note) {
$user = UserAccount::findByCurrentSession();
?>
<li>
<button data-share-url="<?= htmlspecialchars($note->uri) ?>" _="
on click
set url to my @data-share-url
js(url)
navigator.share({ url: url })
end" type="button">
<span class="material-symbols share"></span>
<span><?= __('action.share') ?></span>
</button>
</li>
<li>
<button data-share-url="<?= htmlspecialchars(substr_replace($note->uri, 'web+pawpub', 0, 5)) ?>" _="
on click
set url to my @data-share-url
js(url)
navigator.share({ url: url })
end" type="button">
<span class="material-symbols share-windows"></span>
<span><?= __('action.share.web+pawpub') ?></span>
</button>
</li>
<?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>
<span><?= __('note.action.edit') ?></span>
</button>
</li>
<li>
<button hx-delete="/fragment/note/<?= $note->id ?>"
hx-confirm="<?= __('note.action.delete.confirmation') ?>" hx-target="closest .note"
hx-swap="delete">
<span class="material-symbols delete-outline"></span>
<span><?= __('note.action.delete') ?></span>
</button>
</li>
<?php endif; ?>
<?php if (!$note->author->isLocal): ?>
<li>
<a target="_blank" href="<?= htmlspecialchars($note->uri) ?>" rel="nofollow noreferrer">
<span class="material-symbols open-in-new"></span>
<span><?= __('note.openRemote') ?></span>
</a>
</li>
<?php endif; ?>
<?php }); ?>
</div>
</div>
<?php call_template('note/reply_form', ['note' => $note]); ?>
</div>
</article>
|