Merge branch 'main' into community-labels
commit
31092d2529
@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M48 32C21.5 32 0 53.5 0 80v96c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48H48zm80 64v64H64V96h64zM48 288c-26.5 0-48 21.5-48 48v96c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48V336c0-26.5-21.5-48-48-48H48zm80 64v64H64V352h64zM256 80v96c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48H304c-26.5 0-48 21.5-48 48zm64 16h64v64H320V96zm32 352v32h32V448H352zm96 0H416v32h32V448zM416 288v32H352V288H256v96 96h64V384h32v32h96V352 320 288H416z"/></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path style="fill: grey;" d="M48 32C21.5 32 0 53.5 0 80v96c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48H48zm80 64v64H64V96h64zM48 288c-26.5 0-48 21.5-48 48v96c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48V336c0-26.5-21.5-48-48-48H48zm80 64v64H64V352h64zM256 80v96c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48H304c-26.5 0-48 21.5-48 48zm64 16h64v64H320V96zm32 352v32h32V448H352zm96 0H416v32h32V448zM416 288v32H352V288H256v96 96h64V384h32v32h96V352 320 288H416z"/></svg>
|
||||
|
Before Width: | Height: | Size: 725 B After Width: | Height: | Size: 745 B |
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Return local path to room invite code.
|
||||
* @param string $room_id Id of room to locate QR code for.
|
||||
*/
|
||||
function room_qr_code_path(string $room_id): string {
|
||||
global $QR_CODES;
|
||||
return "$QR_CODES/$room_id.png";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return remote path to room invite code.
|
||||
* @param string $room_id Id of room to locate QR code for.
|
||||
*/
|
||||
function room_qr_code_path_relative(string $room_id): string {
|
||||
global $QR_CODES_RELATIVE;
|
||||
return "$QR_CODES_RELATIVE/$room_id.png";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch QR invite of the given room and return its local path.
|
||||
* @param \CommunityRoom $room
|
||||
* @return string
|
||||
*/
|
||||
function room_qr_code($room): string {
|
||||
$room_id = $room->get_room_identifier();
|
||||
$png_cached = room_qr_code_path($room_id);
|
||||
if (file_exists($png_cached)) {
|
||||
return room_qr_code_path_relative($room_id);
|
||||
}
|
||||
log_debug("Fetching QR code for $room_id.");
|
||||
$png = file_get_contents($room->get_invite_url());
|
||||
file_put_contents($png_cached, $png);
|
||||
return room_qr_code_path_relative($room_id);
|
||||
}
|
||||
|
||||
file_exists($QR_CODES) or mkdir($QR_CODES, 0700);
|
||||
?>
|
||||
@ -1,46 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* @var CommunityRoom[] $rooms
|
||||
*/
|
||||
|
||||
function room_qr_code_cached($room_id) {
|
||||
global $QR_CODES;
|
||||
return "$QR_CODES/$room_id.png";
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch QR codes from SOGS server and encode them as base64
|
||||
* @param CommunityRoom $room
|
||||
*/
|
||||
function base64_qr_code($room, $size = "512x512") {
|
||||
$room_id = $room->get_room_identifier();
|
||||
$png_cached = room_qr_code_cached($room_id);
|
||||
if (file_exists($png_cached)) {
|
||||
return base64_encode(file_get_contents($png_cached));
|
||||
}
|
||||
log_debug("Fetching QR code for $room_id.");
|
||||
$png = file_get_contents($room->get_invite_url());
|
||||
file_put_contents($png_cached, $png);
|
||||
return base64_encode($png);
|
||||
}
|
||||
|
||||
file_exists($QR_CODES) or mkdir($QR_CODES, 0700);
|
||||
require_once "$PROJECT_ROOT/php/utils/room-invites.php";
|
||||
?>
|
||||
|
||||
<div id="modal-container">
|
||||
<?php foreach ($rooms as $room): ?>
|
||||
<div id="modal_<?=$room->get_room_identifier()?>" class="qr-code-modal">
|
||||
<div class="qr-code-modal-content">
|
||||
<span class="qr-code-modal-close">
|
||||
<dialog id="details-modal">
|
||||
<div id="details-modal-contents">
|
||||
<div id="details-modal-close">
|
||||
×
|
||||
</span>
|
||||
</div>
|
||||
<div id="details-modal-start">
|
||||
<h1 id="details-modal-title">
|
||||
<a
|
||||
id="details-modal-community-name"
|
||||
data-hydrate-with="name;preview_link:href"
|
||||
title="Open preview in new tab"
|
||||
></a>
|
||||
</h1>
|
||||
<p id="details-modal-description">
|
||||
<span>Description:</span>
|
||||
<span id="details-modal-description-inner" data-hydrate-with="description"></span>
|
||||
</p>
|
||||
<gap></gap>
|
||||
<div id="details-modal-room-info">
|
||||
<p>
|
||||
Language: <span data-hydrate-with="language_flag"></span>
|
||||
</p>
|
||||
<p>
|
||||
Users: <span data-hydrate-with="users"></span>
|
||||
</p>
|
||||
<p>
|
||||
Server:
|
||||
<a
|
||||
title="Open server in new tab"
|
||||
data-hydrate-with="hostname;hostname:href"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
></a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<button
|
||||
id="details-modal-copy-button"
|
||||
data-hydrate-with="join_link:data-href"
|
||||
title="Click here to copy this Community's join link"
|
||||
>
|
||||
Copy join link
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="details-modal-copy-staff-id"
|
||||
data-hydrate-with="staff:data-staff"
|
||||
title="Copy the mention for a random staff member"
|
||||
>
|
||||
Copy mod ID
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<gap></gap>
|
||||
<div id="details-modal-end">
|
||||
<img
|
||||
src="data:image/png;base64,<?=base64_qr_code($room)?>"
|
||||
alt="Community join link encoded as QR code"
|
||||
class="qr-code"
|
||||
loading="lazy"
|
||||
src=""
|
||||
id="details-modal-qr-code"
|
||||
title="Community join link encoded as QR code"
|
||||
>
|
||||
<div id="details-modal-qr-code-label">
|
||||
Scan QR code in Session to join
|
||||
<br>
|
||||
'<span data-hydrate-with="name"></span>'
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue