Added debug page, Improved Splide galleries

Update .gitignore, composer.php, and 12 more files...
This commit is contained in:
2024-01-08 22:43:59 +01:00
parent b0fbd2199f
commit a3f8d51949
14 changed files with 273 additions and 42 deletions

1
.gitignore vendored
View File

@@ -37,6 +37,7 @@ tools/items/mc-art-viewer/nbt.js
*.url
*.sqlite
*.conf
*.pyc
# Temporary
articles/*.txt

View File

@@ -912,10 +912,10 @@ class ComposerElement {
case ComposerElementTypes::GALLERY:
if(!is_null($this->srTitle)) {
$htmlCode .= '<section class="splide border" aria-label="' . $this->srTitle . '">';
$htmlCode .= '<section class="splide border bkgd-math" aria-label="' . $this->srTitle . '">';
$htmlCode .= '<h2 id="carousel-heading">' . $this->srTitle . '</h2>';
} else {
$htmlCode .= '<section class="splide border">';
$htmlCode .= '<section class="splide border bkgd-math">';
}
$htmlCode .= '<div class="splide__track">';

View File

@@ -15,6 +15,46 @@ $default_language = "en";
$user_language = "en";
$user_uri_language = "";
$lang_compilation_date = "1970-01-01T00:00:00Z";
//$lang_compilation_date = (new DateTime('2010-12-30 23:21:46'))->format(DateTimeInterface::ATOM);
// Preparing a function for later
function process_lang_header(string $accepted_lang_header, bool $filter_unsupported = true, bool $simplify_entries = true): array {
$accepted_languages = [];
foreach(explode(",", $accepted_lang_header) as $_client_lang_entry) {
$lang_entry_parts = explode(";", $_client_lang_entry);
// Ignoring entries without a "q=<float>" part
if(count($lang_entry_parts) != 2) {
continue;
}
// Simplifying complex entries from "en-US" to "en".
// We'll ignore duplicates since it won't matter after sorting.
if($simplify_entries && strlen($lang_entry_parts[0]) > 2) {
$lang_entry_parts[0] = substr($lang_entry_parts[0], 0, 2);
}
// Only allowing supported languages
if(!in_array($lang_entry_parts[0], ["en", "fr"]) && $filter_unsupported) {
continue;
}
// Parsing the language's weight
$lang_entry_parts[1] = str_replace("q=", "", $lang_entry_parts[1]);
$lang_entry_weights = filter_var($lang_entry_parts[1], FILTER_VALIDATE_FLOAT);
if($lang_entry_weights === false || !is_float($lang_entry_weights)) {
continue;
}
// Saving it for later
$accepted_languages[] = $lang_entry_parts;
}
return $accepted_languages;
}
// Attempting to detect the language through the URI
if(str_starts_with($_SERVER['REQUEST_URI'], "/en/")) {
$user_language = "en";
@@ -24,31 +64,7 @@ if(str_starts_with($_SERVER['REQUEST_URI'], "/en/")) {
$user_uri_language = "/".$user_language;
} elseif(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
// Attempting to detect the language through the browser's headers.
$_client_languages = [];
foreach(explode(",", $_SERVER["HTTP_ACCEPT_LANGUAGE"]) as $_client_lang_entry) {
$_client_lang_entry_parts = explode(";", $_client_lang_entry);
// Ignoring "en-US" and similar entries
if(count($_client_lang_entry_parts) != 2) {
continue;
}
// Only allowing supported languages
if(!in_array($_client_lang_entry_parts[0], ["en", "fr"])) {
continue;
}
// Parsing the language's weight
$_client_lang_entry_parts[1] = str_replace("q=", "", $_client_lang_entry_parts[1]);
$_client_lang_entry_weight = filter_var($_client_lang_entry_parts[1], FILTER_VALIDATE_FLOAT);
if($_client_lang_entry_weight === false || !is_float($_client_lang_entry_weight)) {
continue;
}
// Saving it for later
$_client_languages[] = $_client_lang_entry_parts;
}
$_client_languages = process_lang_header($_SERVER['HTTP_ACCEPT_LANGUAGE']);
// Sorting based on weight and selecting the preferred one.
if(count($_client_languages) > 0) {
@@ -74,6 +90,10 @@ header("Content-Language: " . $user_language);
$lang_json = file_get_contents(realpath($dir_commons . "/strings.json"));
$lang_data = json_decode($lang_json, true);
if(array_key_exists("_compile_date", $lang_data)) {
$lang_compilation_date = $lang_data["_compile_date"];
}
// Localization functions
function localize_private(string $string_key, array $private_lang_data, bool $fallback_to_common = false,
string $fallback_prefix = "fallback.unknown") : string {

View File

@@ -1,4 +1,10 @@
{
"common.action.copy": "Copy",
"common.action.copied": "Copied"
"common.action.copied": "Copied",
"common.undefined": "Undefined",
"common.na": "N/A",
"common.yes": "Yes",
"common.no": "No"
}

View File

@@ -0,0 +1,25 @@
{
"debug.head.title": "Debugger - NibblePoker",
"debug.head.description": "TODO: description",
"debug.og.title": "NibblePoker - Debugger",
"debug.og.description": "TODO: description",
"debug.header.title": "Debugger",
"debug.tables.field": "Field",
"debug.tables.value": "Value",
"debug.host.title": "Host Configuration",
"debug.host.requested": "Requested",
"debug.host.domain": "Domain",
"debug.host.uri": "URI",
"debug.host.tld": "TLD",
"debug.host.waffle": "Waffle Mode",
"debug.host.bouneschlupp": "Bouneschlupp Mode",
"debug.lang.title": "Localization System (L10N)",
"debug.lang.compile-date": "Compilation date",
"debug.lang.default": "Default language",
"debug.lang.user": "Active language",
"debug.lang.header.raw": "Raw HTTP header",
"debug.lang.header.processed": "Processed HTTP header"
}

View File

@@ -1,4 +1,10 @@
{
"common.action.copy": "Copier",
"common.action.copied": "Copié"
"common.action.copied": "Copié",
"common.undefined": "Indéfini(e)",
"common.na": "Non-applicable",
"common.yes": "Oui",
"common.no": "Non"
}

View File

@@ -0,0 +1,25 @@
{
"debug.head.title": "Débogueur - NibblePoker",
"debug.head.description": "TODO: description",
"debug.og.title": "NibblePoker - Débogueur",
"debug.og.description": "TODO: description",
"debug.header.title": "Débogueur",
"debug.tables.field": "Champ",
"debug.tables.value": "Valeur",
"debug.host.title": "Configuration de l'hôte",
"debug.host.requested": "Demandé",
"debug.host.domain": "Domaine",
"debug.host.uri": "URI",
"debug.host.tld": "TLD",
"debug.host.waffle": "Mode gaufrier",
"debug.host.bouneschlupp": "Mode Bouneschlupp",
"debug.lang.title": "Système de localisation (L10N)",
"debug.lang.compile-date": "Date de compilation",
"debug.lang.default": "Langue par défaut",
"debug.lang.user": "Langue active",
"debug.lang.header.raw": "En-tête HTTP brut",
"debug.lang.header.processed": "En-tête HTTP traité"
}

View File

@@ -27,7 +27,8 @@ set NP_ZIP_CONTENT=
set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "about/"
set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "commons/*.php" "commons/strings.json" "commons/DOM/" "commons/content/"
set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "contact/"
set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "content/"
set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "content/*.*"
set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "content/items/"
set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "contributors/"
set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "links/"
set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "privacy/"

View File

138
debug/index.php Normal file
View File

@@ -0,0 +1,138 @@
<?php
$start_time = microtime(true);
set_include_path('../');
include_once 'commons/config.php';
include_once 'commons/langs.php';
?>
<!DOCTYPE html>
<html lang="<?php echo($user_language); ?>">
<head>
<?php include 'commons/DOM/head.php'; ?>
<title><?php print(localize('debug.head.title')); ?></title>
<meta name="description" content="<?php print(localize('debug.head.description')); ?>">
<meta property="og:title" content="<?php print(localize('debug.og.title')); ?>"/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="<?php echo($host_uri . l10n_url_abs('/debug/')); ?>"/>
<meta property="og:image" content="<?php echo($host_uri); ?>/resources/NibblePoker/images/logos/v2_opengraph_v2.png"/>
<meta property="og:image:type" content="image/png"/>
<meta property="og:description" content="<?php print(localize('debug.og.description')); ?>"/>
<?php include 'commons/DOM/head-preloads.php'; ?>
</head>
<body>
<?php
include_once 'commons/DOM/utils.php';
$SIDEBAR_IDS = ['debug'];
include 'commons/DOM/sidebar.php';
?>
<header class="w-full p-m pl-s">
<h1 class="t-size-17 t-w-500">
<i class="fad fa-user t-size-16 mr-s t-muted"></i><?php print(localize("debug.header.title")); ?>
</h1>
<?php include 'commons/DOM/header-lang.php'; ?>
</header>
<main id="main" class="rl-m border border-r-0 p-l">
<?php printMainHeader(localize("debug.host.title")); ?>
<div class="p-s pb-0">
<table class="stylish r-s border o-hidden table-p-xs table-h-p-s table-v-center">
<thead>
<tr>
<th><?php echo(localize("debug.tables.field")); ?></th>
<th><?php echo(localize("debug.tables.value")); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo(localize("debug.host.requested")); ?></td>
<td><kbd><?php echo(htmlspecialchars($_SERVER['SERVER_NAME'])); ?></kbd></td>
</tr>
<tr>
<td><?php echo(localize("debug.host.domain")); ?></td>
<td><kbd><?php echo(htmlspecialchars($host)); ?></kbd></td>
</tr>
<tr>
<td><?php echo(localize("debug.host.uri")); ?></td>
<td><kbd><?php echo(htmlspecialchars($host_uri)); ?></kbd></td>
</tr>
<tr>
<td><?php echo(localize("debug.host.tld")); ?></td>
<td><kbd><?php echo(htmlspecialchars($host_tld)); ?></kbd></td>
</tr>
<tr>
<td><?php echo(localize("debug.host.waffle")); ?></td>
<td><i><?php echo(localize($enable_bouneschlupp_mode ? "common.yes": "common.no")); ?></i></td>
</tr>
<tr>
<td><?php echo(localize("debug.host.bouneschlupp")); ?></td>
<td><i><?php echo(localize($enable_waffle_iron ? "common.yes": "common.no")); ?></i></td>
</tr>
</tbody>
</table>
</div>
<?php printMainHeader(localize("debug.lang.title")); ?>
<div class="p-s pb-0">
<table class="stylish r-s border o-hidden table-p-xs table-h-p-s table-v-center">
<thead>
<tr>
<th><?php echo(localize("debug.tables.field")); ?></th>
<th><?php echo(localize("debug.tables.value")); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo(localize("debug.lang.compile-date")); ?></td>
<td><kbd><?php echo(htmlspecialchars($lang_compilation_date)); ?></kbd></td>
</tr>
<tr>
<td><?php echo(localize("debug.lang.default")); ?></td>
<td><kbd><?php echo(htmlspecialchars($default_language)); ?></kbd></td>
</tr>
<tr>
<td><?php echo(localize("debug.lang.user")); ?></td>
<td><kbd><?php echo(htmlspecialchars($user_language)); ?></kbd></td>
</tr>
<tr>
<td><?php echo(localize("debug.lang.header.raw")); ?></td>
<td><?php
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
echo('<kbd>' . htmlspecialchars($_SERVER['HTTP_ACCEPT_LANGUAGE']) . '</kbd>');
} else {
echo('<i>' . localize("common.undefined") . '</i>');
}
?></td>
</tr>
<tr>
<td><?php echo(localize("debug.lang.header.processed")); ?></td>
<td><?php
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$_client_languages = process_lang_header($_SERVER['HTTP_ACCEPT_LANGUAGE'], false, false);
$_i_client_language = 0;
foreach($_client_languages as $_client_language) {
echo('<p' . ($_i_client_language > 0 ? ' class="mt-xs"' : '') . '>');
echo('<kbd>' . htmlspecialchars($_client_language[0]) . '</kbd>');
echo(' &#10140; ');
echo('<kbd>' . htmlspecialchars($_client_language[1]) . '</kbd>');
echo('</p>');
$_i_client_language++;
}
} else {
echo('<i>' . localize("common.na") . '</i>');
}
?></td>
</tr>
</tbody>
</table>
</div>
</main>
<?php
include 'commons/DOM/footer.php';
include 'commons/DOM/scripts.php';
?>
</body>
</html>
<?php
$end_time = microtime(true);
if($print_execution_timer) {
echo("<!-- PHP execution took " . round(($end_time - $start_time) * 1000, 2) . " ms -->");
}
?>

View File

@@ -1,10 +1,10 @@
/*
* -----------------------------------------------------------------------------
* NibblePoker.lu CSS
* Version: 0.0.3
* Copyright, 2023 Bozet Herwin
* Version: I'm not counting anymore
* Copyright, 2023-2024 Bozet Herwin
* -----------------------------------------------------------------------------
* Source: https://github.com/aziascreations/Web-NibblePoker
* Source: https://github.com/NibblePoker/Web-NibblePoker
* -----------------------------------------------------------------------------
*/
@@ -63,3 +63,4 @@
@import 'site/content'; // Uses fixed sizes and floats
@import 'site/video';
@import 'site/modal';
@import 'site/splide';

View File

@@ -62,14 +62,6 @@
}
}
// Zoom-in effect for image galleries
.splide li {
transition: all 0.20s ease-in-out;
}
.splide li:hover {
transform: scale(1.05);
}
//.align-v-t
#logo-sidebar {

View File

@@ -0,0 +1,16 @@
// NibblePoker.lu CSS - (C) 2023 Bozet Herwin
/* Splide Rules */
// Zoom-in effect for image galleries
.splide li {
transition: all 0.20s ease-in-out;
}
.splide li:hover {
transform: scale(1.05);
}
// Generic max-height rule
.splide, .splide * {
max-height: 400px;
}

View File

@@ -4,7 +4,7 @@
/* Site > Text > Commons */
p, a, h1, h2, h3, h4, h5, h6, td, th, .code, summary, label {
p, a, h1, h2, h3, h4, h5, h6, td, th, code, .code, summary, label {
color: #{$color-text-regular-normal};
}