From 6c69dd89af3f7c65528d4b398ac9a137f6c40b31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?s=C3=B8renpeter?=
Date: Mon, 27 Nov 2023 08:24:41 +0100
Subject: [PATCH] Webmention endpoint and mention.txt feed added
---
index.php | 4 +++-
libs/twtxt.php | 1 +
partials/header.php | 2 +-
partials/timeline.php | 4 ++--
private/.htaccess | 1 +
views/webmention_endpoint.php | 40 ++++++++++++++++++++++++++++++++++
webmention.png | Bin 0 -> 8685 bytes
7 files changed, 48 insertions(+), 4 deletions(-)
create mode 100644 private/.htaccess
create mode 100644 views/webmention_endpoint.php
create mode 100644 webmention.png
diff --git a/index.php b/index.php
index 8ab3ed3..bddbf4d 100644
--- a/index.php
+++ b/index.php
@@ -34,9 +34,11 @@ $routes = [
'/login' => 'login.php',
'/logout' => 'logout.php',
'/profile' => 'profile.php',
+ '/profile' => 'profile.php',
//'/profile/([a-zA-Z0-9_-]+)' => 'profile.php',
'/conv/([a-zA-Z0-9]{7})' => 'conv.php', // matches only twtHash of exactly 7 alphanumeric characters
'/post/([a-zA-Z0-9]{7})' => 'post.php', // matches only twtHash of exactly 7 alphanumeric characters
+ '/webmention' => 'webmention_endpoint.php',
];
// Loop through the defined routes and try to match the request URI
@@ -64,4 +66,4 @@ echo "Oops! Page not found.
";
/* Credit:
- PHP FOR BEGINNERS #4 - Create a dynamic Router: https://www.youtube.com/watch?v=eaHBK2XJ5Io
- https://chat.openai.com/c/3082a22a-d70e-4740-891c-9872f5da2180
-*/
\ No newline at end of file
+*/
diff --git a/libs/twtxt.php b/libs/twtxt.php
index e915166..dea66b5 100644
--- a/libs/twtxt.php
+++ b/libs/twtxt.php
@@ -253,6 +253,7 @@ function replaceMentionsFromTwt(string $twtString): string {
//$replacement = '@$1';
$replacement = '@$1';
+ $replacement .= ''; // Adds a hidden link direcly to the twtxt.txt of the mentioned target
#$twtString = '@';
diff --git a/partials/header.php b/partials/header.php
index e1109bd..45a17a9 100644
--- a/partials/header.php
+++ b/partials/header.php
@@ -8,6 +8,7 @@ $profile = getTwtsFromTwtxtString($config['public_txt_url']);
+
= $title ?>
@@ -19,7 +20,6 @@ $profile = getTwtsFromTwtxtString($config['public_txt_url']);
= $profile->nick ?>@= parse_url($profile->mainURL, PHP_URL_HOST); ?>
-