Make it easier to like or boost a post
rodzic
3b535e12ca
commit
0f93c3fd71
32
index.php
32
index.php
|
@ -677,12 +677,12 @@ HTML;
|
|||
// ActivityPub specification - https://www.w3.org/TR/activitystreams-vocabulary/#questions
|
||||
// Mastodon documentation - https://docs.joinmastodon.org/spec/activitypub/#Question
|
||||
if ( isset( $object["oneOf"] ) ) {
|
||||
$content .= "<h3>Poll Results</h3>";
|
||||
$content .= "<h3>Poll Results:</h3>";
|
||||
foreach ( $object["oneOf"] as $pollOption ) {
|
||||
$pollOptionName = htmlspecialchars( $pollOption["name"] );
|
||||
$pollOptionValue = htmlspecialchars( $pollOption["replies"]["totalItems"] );
|
||||
|
||||
$content .= "<br>{$pollOptionName}: $pollOptionValue";
|
||||
$content .= "{$pollOptionName}: $pollOptionValue<br>";
|
||||
}
|
||||
}
|
||||
if ( isset( $object["anyOf"] ) ) {
|
||||
|
@ -691,7 +691,7 @@ HTML;
|
|||
$pollOptionName = htmlspecialchars( $pollOption["name"] );
|
||||
$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?
|
||||
switch ( $type ) {
|
||||
case "Create":
|
||||
|
@ -732,9 +739,9 @@ HTML;
|
|||
|
||||
if ( $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 {
|
||||
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 ) {
|
||||
|
@ -760,6 +767,17 @@ die();
|
|||
// 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.
|
||||
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
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-GB">
|
||||
|
@ -793,7 +811,7 @@ echo <<< HTML
|
|||
<form action="/send" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" id="type" name="type" value="Like">
|
||||
<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>
|
||||
<input type="password" name="password" id="password" size="32"><br><br>
|
||||
<input type="submit" value="Like the message">
|
||||
|
@ -804,7 +822,7 @@ echo <<< HTML
|
|||
<form action="/send" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" id="type" name="type" value="Announce">
|
||||
<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>
|
||||
<input type="password" name="password" id="password" size="32"><br><br>
|
||||
<input type="submit" value="Boost the Message">
|
||||
|
|
Ładowanie…
Reference in New Issue