aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorArno Richter <oelna@oelna.de>2023-08-16 14:52:58 +0200
committerArno Richter <oelna@oelna.de>2023-08-16 14:52:58 +0200
commit66c6658bac8b0e99b59e3b9f4eb285f38bcebcf5 (patch)
treefa54ab21d4c6122df124459030dd5c6af723f1af /templates
parentff2858b6ea8f586daa95e51ae21315f86cc5ded5 (diff)
downloadmicroblog-66c6658bac8b0e99b59e3b9f4eb285f38bcebcf5.tar.gz
microblog-66c6658bac8b0e99b59e3b9f4eb285f38bcebcf5.tar.bz2
microblog-66c6658bac8b0e99b59e3b9f4eb285f38bcebcf5.zip
huge update to implement first version of activitypub support. closes #16. AP and subdir hosting are incompatible!
Diffstat (limited to 'templates')
-rw-r--r--templates/loginform.inc.php2
-rw-r--r--templates/postform.inc.php4
-rw-r--r--templates/single.inc.php39
-rw-r--r--templates/timeline.inc.php16
4 files changed, 53 insertions, 8 deletions
diff --git a/templates/loginform.inc.php b/templates/loginform.inc.php
index b852de7..de155e6 100644
--- a/templates/loginform.inc.php
+++ b/templates/loginform.inc.php
@@ -21,7 +21,7 @@
$title_suffix = 'login';
require(ROOT.DS.'snippets'.DS.'header.snippet.php');
-?><body>
+?><body ontouchstart="">
<div class="wrap">
<?php require(ROOT.DS.'snippets'.DS.'nav.snippet.php'); ?>
<p>Please enter your login information.</p>
diff --git a/templates/postform.inc.php b/templates/postform.inc.php
index df7566c..59579c1 100644
--- a/templates/postform.inc.php
+++ b/templates/postform.inc.php
@@ -25,6 +25,8 @@
}
rebuild_feeds();
+
+ if($config['activitypub'] == true) activitypub_notify_followers($id);
if($config['ping'] == true) ping_microblog();
if($config['crosspost_to_twitter'] == true) {
$twitter_response = json_decode(twitter_post_status($_POST['content']), true);
@@ -42,7 +44,7 @@
$title_suffix = 'new post';
require(ROOT.DS.'snippets'.DS.'header.snippet.php');
-?><body>
+?><body ontouchstart="">
<div class="wrap">
<?php require(ROOT.DS.'snippets'.DS.'nav.snippet.php'); ?>
<?php if(isset($message['status']) && isset($message['message'])): ?>
diff --git a/templates/single.inc.php b/templates/single.inc.php
index 5514742..35c9244 100644
--- a/templates/single.inc.php
+++ b/templates/single.inc.php
@@ -7,6 +7,7 @@
if(mb_strtolower(path(1)) == 'delete') $action = 'delete';
if(mb_strtolower(path(1)) == 'undelete') $action = 'undelete';
if(mb_strtolower(path(1)) == 'edit') $action = 'edit';
+ if(mb_strtolower(path(1)) == 'json') $action = 'json';
$error = false;
if($config['logged_in']) {
@@ -18,8 +19,15 @@
if(!$result) {
$error = 'Post could not be deleted!';
} else {
+
rebuild_feeds();
+ if($config['activitypub']) {
+ // todo: send DELETE activity to followers
+ // https://www.w3.org/TR/activitypub/#delete-activity-inbox
+ activitypub_delete_post($_POST['id']);
+ }
+
header('Location: '.$config['url']);
die();
}
@@ -72,6 +80,12 @@
} else {
rebuild_feeds();
+ if($config['activitypub']) {
+ // todo: send UPDATE activity to followers
+ // https://www.w3.org/TR/activitypub/#update-activity-inbox
+ activitypub_update_post($_POST['id']);
+ }
+
header('Location: '.$config['url'].'/'.$_POST['id']);
die();
}
@@ -86,10 +100,19 @@
}
}
+ if($action == 'json') {
+
+ $json = activitypub_activity_from_post($post, true);
+
+ header('Content-Type: application/ld+json');
+ echo($json);
+ die();
+ }
+
$title_suffix = 'entry #' . $id;
require(ROOT.DS.'snippets'.DS.'header.snippet.php');
-?><body>
+?><body ontouchstart="">
<div class="wrap">
<?php require(ROOT.DS.'snippets'.DS.'nav.snippet.php'); ?>
<ul class="posts">
@@ -150,14 +173,24 @@
<?php endif; ?>
</span>
<nav class="post-meta">
- <?php if($config['logged_in']): ?><ul>
+ <ul>
+ <?php if($config['activitypub']):
+ // todo: is it possible to retrieve this at the same time as post data?
+ $post_stats = activitypub_get_post_stats('both', $post['id']);
+ ?>
+ <li class="post-likes"><a href="<?= $config['url'] ?>/<?= $post['id'] ?>/likes" title="This post has been liked <?= $post_stats['like'] ?> times in the Fediverse"><span class="amount"><?= $post_stats['like'] ?></span><span class="word">Likes</span></a></li>
+ <li class="post-boosts"><a href="<?= $config['url'] ?>/<?= $post['id'] ?>/boosts" title="This post has been announced <?= $post_stats['announce'] ?> times in the Fediverse"><span class="amount"><?= $post_stats['announce'] ?></span><span class="word">Boosts</span></a></li>
+ <?php endif; ?>
+
+ <?php if($config['logged_in']): ?>
<?php if(is_numeric($post['post_deleted'])): ?>
<li><a href="<?= $config['url'] ?>/<?= $post['id'] ?>/undelete" title="Restore">Deleted on <?= date('M d Y', $post['post_deleted']) ?></a></li>
<?php else: ?>
<li><a href="<?= $config['url'] ?>/<?= $post['id'] ?>/edit">Edit</a></li>
<li><a href="<?= $config['url'] ?>/<?= $post['id'] ?>/delete">Delete</a></li>
<?php endif; ?>
- </ul><?php endif; ?>
+ <?php endif; ?>
+ </ul>
</nav>
<div class="post-content"><?= nl2br(autolink($post['post_content'])) ?></div>
<?php if(!empty($attachments) && !empty($attachments[$post['id']])): ?>
diff --git a/templates/timeline.inc.php b/templates/timeline.inc.php
index d07776d..61a889d 100644
--- a/templates/timeline.inc.php
+++ b/templates/timeline.inc.php
@@ -23,7 +23,7 @@
$title_suffix = '';
require(ROOT.DS.'snippets'.DS.'header.snippet.php');
-?><body>
+?><body ontouchstart="">
<div class="wrap">
<?php require(ROOT.DS.'snippets'.DS.'nav.snippet.php'); ?>
<ul class="posts">
@@ -46,10 +46,20 @@
<?php endif; ?>
</a>
<nav class="post-meta">
- <?php if($config['logged_in']): ?><ul>
+ <ul>
+ <?php if($config['activitypub']):
+ // todo: is it possible to retrieve this at the same time as post data?
+ $post_stats = activitypub_get_post_stats('both', $post['id']);
+ ?>
+ <li class="post-likes"><a href="<?= $config['url'] ?>/<?= $post['id'] ?>/likes" title="This post has been liked <?= $post_stats['like'] ?> times in the Fediverse"><span class="amount"><?= $post_stats['like'] ?></span><span class="word">Likes</span></a></li>
+ <li class="post-boosts"><a href="<?= $config['url'] ?>/<?= $post['id'] ?>/boosts" title="This post has been announced <?= $post_stats['announce'] ?> times in the Fediverse"><span class="amount"><?= $post_stats['announce'] ?></span><span class="word">Boosts</span></a></li>
+ <?php endif; ?>
+
+ <?php if($config['logged_in']): ?>
<li><a href="<?= $config['url'] ?>/<?= $post['id'] ?>/edit">Edit</a></li>
<li><a href="<?= $config['url'] ?>/<?= $post['id'] ?>/delete">Delete</a></li>
- </ul><?php endif; ?>
+ <?php endif; ?>
+ </ul>
</nav>
<div class="post-content"><?= nl2br(autolink($post['post_content'])) ?></div>
<?php if(!empty($attachments) && !empty($attachments[$post['id']])): ?>