Better reader layout

main
Terence Eden 2024-03-03 11:08:59 +00:00
rodzic 571b6fbe7c
commit d57d0800d2
1 zmienionych plików z 26 dodań i 8 usunięć

Wyświetl plik

@ -504,7 +504,7 @@ echo <<< HTML
.h-feed > header { text-align: center; margin: 0 auto; }
.h-feed .banner { text-align: center; margin:0 auto; max-width: 650px; }
.h-feed > h1, .h-feed > h2 { margin-top: 10px; margin-bottom: 0; }
.h-feed > header > h1:has(span.p-author), h2:has(a.p-nickname) { word-break: break-all; max-width: 90%; padding-left:20px; }
.h-feed > header > h1:has(span.p-author), h2:has(a.p-nickname) { word-wrap: break-word; max-width: 90%; padding-left:20px; }
.h-feed .u-feature:first-child { margin-top: 10px; margin-bottom: -150px; max-width: 100%;}
.h-feed .u-photo { max-height: 8vw; max-width:100%; min-height: 120px; }
.h-feed .about { font-size: smaller; background-color: #F5F5F5; padding: 10px; border-top: dotted 1px #808080; border-bottom: dotted 1px #808080; }
@ -512,7 +512,7 @@ echo <<< HTML
.h-feed > ul > li { padding: 10px; border-bottom: dotted 1px #808080; }
.h-entry { padding-right: 10px; }
.h-entry time { font-weight: bold; }
.h-entry .e-content a { word-wrap: break-all; }
.h-entry .e-content a { word-wrap: break-word; }
</style>
</head>
<body>
@ -1189,7 +1189,8 @@ HTML;
// Displays the most recent 200 messages in the inbox
function read() {
global $server, $username, $directories;
global $server, $username, $realName, $directories;
$rawUsername = rawurldecode( $username );
// Get all the files in the inbox
$inbox_files = array_reverse( glob( $directories["inbox"] . "/*.json") );
@ -1232,22 +1233,37 @@ echo <<< HTML
body { margin:0; padding: 0; font-family:sans-serif; }
@media screen and (max-width: 800px) { body { width: 100%; }}
@media screen and (min-width: 799px) { body { width: 800px; margin: 0 auto; }}
address { font-style: normal; }
img { max-width: 50%; }
.h-feed { margin:auto; width: 100%; }
.h-feed > header { text-align: center; margin: 0 auto; }
.h-feed .banner { text-align: center; margin:0 auto; max-width: 650px; }
.h-feed > h1, .h-feed > h2 { margin-top: 10px; margin-bottom: 0; }
.h-feed > header > h1:has(span.p-author), h2:has(a.p-nickname) { word-break: break-all; max-width: 90%; padding-left:20px; }
.h-feed > header > h1:has(span.p-author), h2:has(a.p-nickname) { word-wrap: break-word; max-width: 90%; padding-left:20px; }
.h-feed .u-feature:first-child { margin-top: 10px; margin-bottom: -150px; max-width: 100%;}
.h-feed .u-photo { max-height: 8vw; max-width:100%; min-height: 120px; }
.h-feed .about { font-size: smaller; background-color: #F5F5F5; padding: 10px; border-top: dotted 1px #808080; border-bottom: dotted 1px #808080; }
.h-feed > ul { padding-left: 0; list-style-type: none; }
.h-feed > ul > li { padding: 10px; border-bottom: dotted 1px #808080; }
.h-entry { padding-right: 10px; }
.h-entry time { font-weight: bold; }
.h-entry .e-content a { word-wrap: break-all; }
.h-entry .e-content a { word-wrap: break-word; }
</style>
</head>
<body>
<main class="h-feed">
<header>
<div class="banner">
<img src="banner.png" alt="" class="u-feature" /><br/>
<img src="icon.png" alt="icon" class="u-photo" />
</div>
<h1>Reader view for <span class="p-name p-author">{$realName}</span></h1>
<h2><a class="p-nickname u-url" rel="author" href="https://{$server}/{$username}">@{$rawUsername}@{$server}</a></h2>
<div class="about">
<p><a href="https://gitlab.com/edent/activitypub-single-php-file/">This software is licenced under AGPL 3.0</a>.</p>
<p>This site is a basic <a href="https://www.w3.org/TR/activitypub/">ActivityPub</a> server designed to be <a href="https://shkspr.mobi/blog/2024/02/activitypub-server-in-a-single-file/">a lightweight educational tool</a>.</p>
</div>
</header>
<ul>
HTML;
@ -1308,17 +1324,19 @@ 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>";
foreach ( $object["oneOf"] as $pollOption ) {
$pollOptionName = $pollOption["name"];
$pollOptionValue = $pollOption["replies"]["totalItems"];
$pollOptionName = htmlspecialchars( $pollOption["name"] );
$pollOptionValue = htmlspecialchars( $pollOption["replies"]["totalItems"] );
$content .= "<br>{$pollOptionName}: $pollOptionValue";
}
}
if ( isset( $object["anyOf"] ) ) {
$content .= "<h3>Poll Results</h3>";
foreach ( $object["anyOf"] as $pollOption ) {
$pollOptionName = htmlspecialchars( $pollOption["name"] );
$pollOptionValue = $pollOption["replies"]["totalItems"];
$pollOptionValue = htmlspecialchars( $pollOption["replies"]["totalItems"] );
$content .= "<br>{$pollOptionName}: $pollOptionValue";
}