From 66c6658bac8b0e99b59e3b9f4eb285f38bcebcf5 Mon Sep 17 00:00:00 2001 From: Arno Richter Date: Wed, 16 Aug 2023 14:52:58 +0200 Subject: huge update to implement first version of activitypub support. closes #16. AP and subdir hosting are incompatible! --- templates/loginform.inc.php | 2 +- templates/postform.inc.php | 4 +++- templates/single.inc.php | 39 ++++++++++++++++++++++++++++++++++++--- templates/timeline.inc.php | 16 +++++++++++++--- 4 files changed, 53 insertions(+), 8 deletions(-) (limited to 'templates') 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'); -?> +?>

Please enter your login information.

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'); -?> +?>
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'); -?> +?>
    @@ -150,14 +173,24 @@
    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'); -?> +?>