aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Digitigrade/Model/Note.php9
-rw-r--r--Digitigrade/Timeline/LocalTimeline.php20
-rw-r--r--routes/public_timelines.php (renamed from routes/global_timeline.php)6
-rw-r--r--static/default-avatar.svg57
-rw-r--r--static/style.css58
-rw-r--r--templates/alertbox.php3
-rw-r--r--templates/global_timeline.php4
-rw-r--r--templates/local_timeline.php10
-rw-r--r--templates/note.php7
-rw-r--r--templates/skeleton.php7
10 files changed, 169 insertions, 12 deletions
diff --git a/Digitigrade/Model/Note.php b/Digitigrade/Model/Note.php
index 9d73a89..8dbec90 100644
--- a/Digitigrade/Model/Note.php
+++ b/Digitigrade/Model/Note.php
@@ -124,6 +124,15 @@ class Note extends PushableModel {
return array_unique($instances);
}
+ /**
+ * Gets this note's formatted content in the given mimetype or null if there isn't one
+ * @param string $mimetype content type to return
+ * @return ?string the marked up content
+ */
+ public function getFormattedContent(string $mimetype): ?string {
+ return array_filter($this->formattedContent, fn($item) => $item['mimetype'] == $mimetype)[0]['body'] ?? null;
+ }
+
public function jsonSerialize(): array {
if ($this->deleted) {
return [
diff --git a/Digitigrade/Timeline/LocalTimeline.php b/Digitigrade/Timeline/LocalTimeline.php
new file mode 100644
index 0000000..e4594af
--- /dev/null
+++ b/Digitigrade/Timeline/LocalTimeline.php
@@ -0,0 +1,20 @@
+<?php
+namespace Digitigrade\Timeline;
+
+use Digitigrade\Db;
+use Digitigrade\Timeline;
+
+class LocalTimeline extends Timeline {
+ protected function getNoteIds(int $limit, int $offset): array {
+ $db = Db::getInstance()->getPdo();
+ $stmt = $db->prepare(<<<END
+ SELECT note.id FROM note
+ LEFT JOIN note_privacy ON note_privacy.note_id = note.id
+ LEFT JOIN actor ON note.author = actor.id
+ WHERE note_privacy.scope = 'public' AND note_privacy.indexable = true AND actor.is_local = true
+ ORDER BY note.created DESC LIMIT ? OFFSET ?
+ END);
+ $stmt->execute([$limit, $offset]);
+ return $stmt->fetchAll(\PDO::FETCH_COLUMN, 0);
+ }
+} \ No newline at end of file
diff --git a/routes/global_timeline.php b/routes/public_timelines.php
index 654d2c7..2d40328 100644
--- a/routes/global_timeline.php
+++ b/routes/public_timelines.php
@@ -2,8 +2,14 @@
use Digitigrade\Router;
use Digitigrade\Timeline\GlobalTimeline;
+use Digitigrade\Timeline\LocalTimeline;
Router::getInstance()->mount('/feed/global', function (array $args) {
$notes = (new GlobalTimeline())->getNotes();
render_template('global_timeline', ['notes' => $notes]);
+});
+
+Router::getInstance()->mount('/feed/local', function (array $args) {
+ $notes = (new LocalTimeline())->getNotes();
+ render_template('local_timeline', ['notes' => $notes]);
}); \ No newline at end of file
diff --git a/static/default-avatar.svg b/static/default-avatar.svg
new file mode 100644
index 0000000..5d734a9
--- /dev/null
+++ b/static/default-avatar.svg
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ width="64"
+ height="64"
+ viewBox="0 0 64 64"
+ version="1.1"
+ id="svg1"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <defs
+ id="defs1" />
+ <g
+ id="layer1">
+ <g
+ id="g7"
+ transform="matrix(0.81915204,-0.61997856,0.57357644,0.88542115,-9.8389023,27.187623)">
+ <ellipse
+ style="opacity:1;fill:#341e55;fill-opacity:0.271113;stroke-width:1.07054"
+ id="path3"
+ cx="-7.422678"
+ cy="25.878199"
+ rx="6.7873225"
+ ry="8.2171621"
+ transform="matrix(0.63285055,-0.77427397,0.72122314,0.69270281,0,0)" />
+ <ellipse
+ style="opacity:1;fill:#341e55;fill-opacity:0.271113;stroke-width:1.07172"
+ id="path4"
+ cx="25.941027"
+ cy="20.172144"
+ rx="5.8635988"
+ ry="8.2372408"
+ transform="matrix(0.97464087,-0.22377484,0.12154217,0.99258627,0,0)" />
+ <ellipse
+ style="opacity:1;fill:#341e55;fill-opacity:0.271113;stroke-width:1.07161"
+ id="path5"
+ cx="43.196301"
+ cy="19.089205"
+ rx="5.8324995"
+ ry="8.2224894"
+ transform="matrix(0.99865107,-0.05192343,-0.05003473,0.99874748,0,0)" />
+ <ellipse
+ style="opacity:1;fill:#341e55;fill-opacity:0.271113;stroke-width:0.994231"
+ id="path6"
+ cx="62.002583"
+ cy="37.127773"
+ rx="6.58569"
+ ry="7.9303436"
+ transform="matrix(0.98583265,-0.16773191,-0.15120581,0.9885023,0,0)" />
+ <path
+ style="opacity:1;fill:#341e55;fill-opacity:0.271113;stroke-width:1.06883"
+ d="M 35.091789,26.612588 C 21.38302,26.75655 21.00167,31.399568 19.422233,37.866324 c -1.378975,5.645992 -1.597634,10.395818 3.631793,11.03401 5.229427,0.638192 5.585526,-3.294926 11.300259,-3.592055 5.714733,-0.29713 5.443755,4.454819 10.279299,4.203403 4.835543,-0.251418 3.554548,-9.06409 2.291899,-13.644155 -1.205836,-4.373989 -5.245485,-9.483724 -11.833694,-9.254939 z"
+ id="path7" />
+ </g>
+ </g>
+</svg>
diff --git a/static/style.css b/static/style.css
index 3ea07c0..d8a8ff8 100644
--- a/static/style.css
+++ b/static/style.css
@@ -1,10 +1,13 @@
+@import url(https://fonts.bunny.net/css?family=dm-sans:400,400i,800,800i);
+
html,
body {
- background: white;
- color: black;
+ background: #fdf5ff;
+ color: #0f070f;
margin: 0;
padding: 0;
- font-family: sans-serif;
+ font-family: "DM Sans", sans-serif;
+ font-size: 12pt;
display: flex;
flex-direction: column;
align-items: center;
@@ -16,11 +19,15 @@ header {
padding: 16px;
margin-bottom: 8px;
display: flex;
+ flex-direction: column;
+ align-items: center;
width: 100vw;
box-sizing: border-box;
- *:not(:last-child) {
- margin-right: 8px;
+ nav {
+ width: min(800px, 100vw);
+ display: grid;
+ grid-template-columns: 1fr max-content 1fr;
}
}
@@ -28,14 +35,34 @@ header {
font-weight: bold;
}
+nav {
+ ul {
+ list-style: none;
+ display: inline;
+ margin: 0;
+ margin-left: 8px;
+ padding: 0;
+ > li {
+ display: inline;
+ > a {
+ border-radius: 4px;
+ background: #fff3;
+ padding: 4px 8px;
+ color: white;
+ text-decoration: none;
+ }
+ }
+ }
+}
+
main {
width: min(800px, 100vw);
}
article.note {
- background: #eee;
- color: black;
- border-radius: 16px;
+ background: #fee4;
+ border: 1px solid #3b005e44;
+ border-radius: 8px;
margin: 16px;
padding: 16px;
display: grid;
@@ -51,3 +78,18 @@ article.note {
font-weight: bold;
}
}
+
+.alertbox {
+ border: 1px solid;
+ border-radius: 8px;
+ margin: 16px;
+ padding: 16px;
+ &.info {
+ border-color: #23f4;
+ background: #5673ff44;
+ }
+ p {
+ margin: 0;
+ padding: 0;
+ }
+}
diff --git a/templates/alertbox.php b/templates/alertbox.php
new file mode 100644
index 0000000..5d1f607
--- /dev/null
+++ b/templates/alertbox.php
@@ -0,0 +1,3 @@
+<div class="alertbox <?= $variety ?>">
+ <p><?= $message ?></p>
+</div> \ No newline at end of file
diff --git a/templates/global_timeline.php b/templates/global_timeline.php
index dbecd7b..cdaac5e 100644
--- a/templates/global_timeline.php
+++ b/templates/global_timeline.php
@@ -1,5 +1,9 @@
<?php call_template('skeleton', ['pageTitle' => 'Global timeline'], function () {
global $notes;
+ call_template('alertbox', [
+ 'variety' => 'info',
+ 'message' => 'This timeline shows all known public indexable notes'
+ ]);
foreach ($notes as $n) {
call_template('note', ['note' => $n]);
}
diff --git a/templates/local_timeline.php b/templates/local_timeline.php
new file mode 100644
index 0000000..a4624b5
--- /dev/null
+++ b/templates/local_timeline.php
@@ -0,0 +1,10 @@
+<?php call_template('skeleton', ['pageTitle' => 'Local timeline'], function () {
+ global $notes;
+ call_template('alertbox', [
+ 'variety' => 'info',
+ 'message' => 'This timeline shows all public indexable notes posted by users on this server'
+ ]);
+ foreach ($notes as $n) {
+ call_template('note', ['note' => $n]);
+ }
+}); \ No newline at end of file
diff --git a/templates/note.php b/templates/note.php
index c3ec9fd..93a22fd 100644
--- a/templates/note.php
+++ b/templates/note.php
@@ -1,11 +1,14 @@
<article class="note">
- <img class="authorAvatar" src="<?= $note->author->avatar ?>">
+ <picture>
+ <source srcset="<?= $note->author->avatar ?>">
+ <img class="authorAvatar" src="/static/default-avatar.svg">
+ </picture>
<div>
<a class="authorName" <?= isset($note->author->homepage) ? 'href="' . $note->author->homepage . '"' : '' ?>>
<?= $note->author->displayName ?>
</a>
<div class="postContent">
- <?= $note->plainContent ?>
+ <?= $note->getFormattedContent('text/html') ?? htmlspecialchars($note->plainContent) ?>
</div>
</div>
</article> \ No newline at end of file
diff --git a/templates/skeleton.php b/templates/skeleton.php
index d1e08e0..5e181b6 100644
--- a/templates/skeleton.php
+++ b/templates/skeleton.php
@@ -8,9 +8,12 @@
<body>
<header>
- <span id="siteTitle">Digitigrade???????</span>
<nav>
- <span>navigation links go here i suppose?</span>
+ <ul>
+ <li><a href="/feed/global">Global</a></li>
+ <li><a href="/feed/local">Local</a></li>
+ </ul>
+ <span id="siteTitle">Digitigrade</span>
</nav>
</header>
<main>