aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/note.php11
-rw-r--r--templates/note_link_preview.php23
2 files changed, 34 insertions, 0 deletions
diff --git a/templates/note.php b/templates/note.php
index 81f7e38..4cdcd94 100644
--- a/templates/note.php
+++ b/templates/note.php
@@ -5,6 +5,8 @@ use Digitigrade\Model\NotePrivacyScope;
use Digitigrade\Model\UserAccount;
use Digitigrade\UserSettings;
+const MAX_PREVIEW_CARDS = 1;
+
$user = UserAccount::findByCurrentSession();
$prefs = $user ? new UserSettings($user) : null;
$interKinds = [];
@@ -89,6 +91,15 @@ if ($user != null) {
</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; ?>
diff --git a/templates/note_link_preview.php b/templates/note_link_preview.php
new file mode 100644
index 0000000..81431b1
--- /dev/null
+++ b/templates/note_link_preview.php
@@ -0,0 +1,23 @@
+<?php
+$siteName = hostname_from_uri($preview->url);
+if ($preview->siteName != $siteName) {
+ $siteName = htmlspecialchars($preview->siteName) . ' &bullet; ' . $siteName;
+}
+?>
+
+<a class="linkPreview style-<?= htmlspecialchars($preview->style) ?>" href="<?= htmlspecialchars($preview->url) ?>"
+ target="_blank" rel="noreferrer nofollow">
+
+ <?php if ($preview->style == 'text' || !isset($preview->imageUrl)): ?>
+ <div></div>
+ <?php else: ?>
+ <img src="<?= htmlspecialchars($preview->imageUrl) ?>">
+ <?php endif; ?>
+
+ <div class="info">
+ <span class="siteName"><?= $siteName ?></span>
+ <span class="title"><?= htmlspecialchars($preview->title) ?></span>
+ <span class="description"><?= htmlspecialchars($preview->description) ?></span>
+ </div>
+
+</a> \ No newline at end of file