Make it easier to like or boost a post

merge-requests/5/head
Terence Eden 2024-03-03 15:53:58 +00:00
rodzic 3b535e12ca
commit 0f93c3fd71
1 zmienionych plików z 25 dodań i 7 usunięć

Wyświetl plik

@ -677,12 +677,12 @@ HTML;
// ActivityPub specification - https://www.w3.org/TR/activitystreams-vocabulary/#questions // ActivityPub specification - https://www.w3.org/TR/activitystreams-vocabulary/#questions
// Mastodon documentation - https://docs.joinmastodon.org/spec/activitypub/#Question // Mastodon documentation - https://docs.joinmastodon.org/spec/activitypub/#Question
if ( isset( $object["oneOf"] ) ) { if ( isset( $object["oneOf"] ) ) {
$content .= "<h3>Poll Results</h3>"; $content .= "<h3>Poll Results:</h3>";
foreach ( $object["oneOf"] as $pollOption ) { foreach ( $object["oneOf"] as $pollOption ) {
$pollOptionName = htmlspecialchars( $pollOption["name"] ); $pollOptionName = htmlspecialchars( $pollOption["name"] );
$pollOptionValue = htmlspecialchars( $pollOption["replies"]["totalItems"] ); $pollOptionValue = htmlspecialchars( $pollOption["replies"]["totalItems"] );
$content .= "<br>{$pollOptionName}: $pollOptionValue"; $content .= "{$pollOptionName}: $pollOptionValue<br>";
} }
} }
if ( isset( $object["anyOf"] ) ) { if ( isset( $object["anyOf"] ) ) {
@ -691,7 +691,7 @@ HTML;
$pollOptionName = htmlspecialchars( $pollOption["name"] ); $pollOptionName = htmlspecialchars( $pollOption["name"] );
$pollOptionValue = htmlspecialchars( $pollOption["replies"]["totalItems"] ); $pollOptionValue = htmlspecialchars( $pollOption["replies"]["totalItems"] );
$content .= "<br>{$pollOptionName}: $pollOptionValue"; $content .= "{$pollOptionName}: $pollOptionValue<br>";
} }
} }
@ -716,6 +716,13 @@ HTML;
} }
} }
// Buttons to repost or favourite a message
if ( "read" == $style ) {
$interactHTML = "<a href=\"/write?announce=$id\">🔁</a> <a href=\"/write?like=$id\"></a>";
} else {
$interactHTML = "";
}
// What sort of message is this? // What sort of message is this?
switch ( $type ) { switch ( $type ) {
case "Create": case "Create":
@ -732,9 +739,9 @@ HTML;
if ( $reply ) { if ( $reply ) {
// Highlight that this is a reply // Highlight that this is a reply
echo "<li><article class=\"h-entry\"><mark>{$timeHTML} {$actorHTML} {$verb}{$replyTo}:</mark> <blockquote class=\"e-content\">{$content}</blockquote></article></li>"; echo "<li><article class=\"h-entry\"><mark>{$timeHTML} {$actorHTML} {$verb}{$replyTo}:</mark> <blockquote class=\"e-content\">{$content}</blockquote>{$interactHTML}</article></li>";
} else { } else {
echo "<li><article class=\"h-entry\">{$timeHTML} {$actorHTML} {$verb}{$replyTo}: <blockquote class=\"e-content\">{$content}</blockquote></article></li>"; echo "<li><article class=\"h-entry\">{$timeHTML} {$actorHTML} {$verb}{$replyTo}: <blockquote class=\"e-content\">{$content}</blockquote>{$interactHTML}</article></li>";
} }
} else if ( "Like" == $type ) { } else if ( "Like" == $type ) {
@ -760,6 +767,17 @@ die();
// User Interface for Writing: // User Interface for Writing:
// This creates a basic HTML form. Type in your message and your password. It then POSTs the data to the `/send` endpoint. // This creates a basic HTML form. Type in your message and your password. It then POSTs the data to the `/send` endpoint.
function write() { function write() {
if ( isset( $_GET["announce"] ) && filter_var( $_GET["announce"], FILTER_VALIDATE_URL ) ) {
$announceURl = $_GET["announce"];
} else {
$announceURl = "";
}
if ( isset( $_GET["like"] ) && filter_var( $_GET["like"], FILTER_VALIDATE_URL ) ) {
$likeURl = $_GET["like"];
} else {
$likeURl = "";
}
echo <<< HTML echo <<< HTML
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en-GB"> <html lang="en-GB">
@ -793,7 +811,7 @@ echo <<< HTML
<form action="/send" method="post" enctype="multipart/form-data"> <form action="/send" method="post" enctype="multipart/form-data">
<input type="hidden" id="type" name="type" value="Like"> <input type="hidden" id="type" name="type" value="Like">
<label for="postURl">URl of post to like:</label> <label for="postURl">URl of post to like:</label>
<input type="url" name="postURl" id="postURl" size="32" /><br> <input type="url" name="postURl" id="postURl" size="32" value="{$likeURl}"><br>
<label for="password">Password</label><br> <label for="password">Password</label><br>
<input type="password" name="password" id="password" size="32"><br><br> <input type="password" name="password" id="password" size="32"><br><br>
<input type="submit" value="Like the message"> <input type="submit" value="Like the message">
@ -804,7 +822,7 @@ echo <<< HTML
<form action="/send" method="post" enctype="multipart/form-data"> <form action="/send" method="post" enctype="multipart/form-data">
<input type="hidden" id="type" name="type" value="Announce"> <input type="hidden" id="type" name="type" value="Announce">
<label for="postURl">URl of post to boost:</label> <label for="postURl">URl of post to boost:</label>
<input type="url" name="postURl" id="postURl" size="32" /><br> <input type="url" name="postURl" id="postURl" size="32" value="{$announceURl}"><br>
<label for="password">Password</label><br> <label for="password">Password</label><br>
<input type="password" name="password" id="password" size="32"><br><br> <input type="password" name="password" id="password" size="32"><br><br>
<input type="submit" value="Boost the Message"> <input type="submit" value="Boost the Message">