Compare commits

..

5 Commits

@ -59,9 +59,11 @@ clean:
-rm -r output/*.html 2>/dev/null || true
# Build everything from scratch and test functionality.
test: FLAGS = --verbose
test: clean all open server
# Build everything from scratch and test functionality on LAN.
test: FLAGS = --verbose
test-lan: clean all open lan-server
# -- Aliases --

@ -330,7 +330,7 @@ footer {
max-width: 100%;
text-align: center;
padding-top: var(--body-margin);
padding-bottom: var(--body-margin);
padding-inline: var(--body-margin);
}

@ -1,5 +1,4 @@
<?php
include_once "$PROJECT_ROOT/languages/language_flags.php";
$WEEK_SECONDS = 604800;
@ -131,6 +130,33 @@
}, $details);
}
/**
* Sorts Community rooms in-place by the given string property.
* @param \CommunityRoom[] $rooms Rooms to sort by given key.
* @param string $key String property of CommunityRoom to sort by.
*/
public static function sort_rooms_str(array &$rooms, string $key) {
usort($rooms, function(\CommunityRoom $a, \CommunityRoom $b) use ($key) {
return strcmp(
$a->$key,
$b->$key
);
});
}
/**
* Sorts Community rooms in-place by their server's public key.
* @param \CommunityRoom[] $rooms Rooms to sort by server pubkey.
*/
public static function sort_rooms_by_pubkey(array &$rooms) {
usort($rooms, function(\CommunityRoom $a, \CommunityRoom $b) {
return strcmp(
$a->server->get_pubkey(),
$b->server->get_pubkey()
);
});
}
/**
* Returns array of staff Session IDs.
* @return string[]

@ -9,15 +9,15 @@
// Once handlers are attached in JS, this check ceases to be useful.
function column_sortable($id) {
// Join URL contents are not guaranteed to have visible text.
return $id != "qr" && $id != "preview" && $id != "join_url";
return $id != "qr_code" && $id != "preview" && $id != "join_url";
}
function sort_onclick($colno) {
global $TABLE_COLUMNS;
$column = $TABLE_COLUMNS[$colno];
$name = isset($column['name_long']) ? $column['name_long'] : $column['name'];
if (!column_sortable($column['id'])) return " title='Column: $name'";
return " title='Click to sort by $name'";
if (!column_sortable($column['id'])) return " title='$name'";
return " title='Click to sort by $name'.";
}
// Note: Changing the names displayed requires updating
@ -30,9 +30,9 @@
['id' => "description", 'name' => "About", 'name_long' => "Description"],
['id' => "users", 'name' => "#", 'name_long' => "Weekly Active Users"],
['id' => "preview", 'name' => "Preview"],
['id' => "qr_code", 'name' => "QR"],
['id' => "qr_code", 'name' => "QR", 'name_long' => "QR Code (for use in-app)"],
['id' => "server_icon", 'name' => "Host", 'name_long' => "Server host"],
['id' => "join_url", 'name' => "URL", 'name_long' => "In-app Join URL"],
['id' => "join_url", 'name' => "URL", 'name_long' => "Join URL (for use in-app)"],
];
?>
@ -70,15 +70,24 @@
data-hostname="<?=$hostname?>"
>
<td class="td_identifier" itemprop="identifier"><?=$id?></td>
<td class="td_language"><?=$language?></td>
<td class="td_name" title="'<?=$room->name?>' preview" itemprop="name">
<a href="<?=$room->get_preview_url()?>" target="_blank" rel="noopener noreferrer">
<?=$room->name?>
<td class="td_language" title="Language flag for '<?=$name?>'"><?=$language?></td>
<td class="td_name" title="Click here to preview '<?=$name?>'" itemprop="name">
<a href="<?=$preview_link?>" target="_blank" rel="noopener noreferrer">
<?=$name?>
</a>
</td>
<td class="td_description" itemprop="description"><?=$desc?></td>
<td class="td_users"><?=$users?></td>
<td
class="td_description"
title="Description for '<?=$name?>':
<?=$desc?>"
itemprop="description"
><?=$desc?></td>
<td
class="td_users"
title="'<?=$name?>' has around <?=$users?> weekly active users."
><?=$users?></td>
<td class="td_preview" itemprop="url">
<a href="<?=$preview_link?>" target="_blank" rel="noopener noreferrer nofollow">
<span class="protocol-indicator"></span>
@ -89,11 +98,12 @@
class="qr-code-icon"
src="qrcode-solid.svg"
alt="Pictogram of a QR code"
title="Click here to view the QR Code for '<?=$name?>'"
>
</td>
<td class="td_server_icon"
data-sort-by="<?=$pubkey?>"
title="<?=$hostname?> (<?=$pubkey?>)"
title="Host: <?=$hostname?> (<?=$pubkey?>)"
item="image"
>
<div class="td_server_icon-circle" style="background-color: <?=$icon_color?>">
@ -104,7 +114,11 @@
<div class="join_url_container" data-url="<?=$join_link?>">
<a class="join_url show-from-w5" title="<?=$join_link?>"
><?=truncate($join_link, 32)?></a>
<a class="noscript" href="<?=$join_link?>" rel="external nofollow"
<a
class="noscript"
title="Copy this link to join '<?=$name?>'."
href="<?=$join_link?>"
rel="external nofollow"
>Copy link</a>
</div>
</td>

@ -16,6 +16,10 @@
// List all rooms from the cached servers.
$rooms = CommunityServer::enumerate_rooms($servers);
// Sort rooms by name and then host.
CommunityRoom::sort_rooms_str($rooms, 'name');
CommunityRoom::sort_rooms_by_pubkey($rooms);
// Set the last-updated timestamp
// to the time the server data file was last modified.
$timestamp = filemtime($ROOMS_FILE);

Loading…
Cancel
Save