Added content elements, Added test content page

Update .htaccess, content.php, and 6 more files...
This commit is contained in:
2022-04-16 18:53:29 +02:00
parent 9c98503b07
commit b212dd046c
8 changed files with 332 additions and 16 deletions

View File

@@ -39,6 +39,8 @@ RewriteRule ^en/(.*)$ /$1 [QSA]
RewriteRule ^fr/(.*)$ /$1 [QSA]
RewriteRule ^lb/(.*)$ /$1 [QSA]
# Honeypots. (Just to fuck with automated scanners, gotta love those unsolicited emails tho...)
# Sending a 404 for git and IDEs folders just in case they ever get copied to the web server,
# or if one of the honeypot files is acessed directly.
# A 404 is preferred to prevent further scanning of this folder and from raising some flags.

View File

@@ -165,19 +165,21 @@ function printErrorTextElement(string $text) : void {
}
}
function processStandardContentSubNode(mixed $elementNode) : void {
function processStandardContentSubNode(mixed $elementNode, string $prepend="", string $append="") : void {
if(array_key_exists("content", $elementNode)) {
if (array_key_exists("parts", $elementNode["content"])) {
for ($iPart = 0; $iPart < count($elementNode["content"]["parts"]); $iPart++) {
echo($prepend);
createElementNode($elementNode["content"]["parts"][$iPart]);
echo($append);
}
} else {
echo(getContentItemText($elementNode["content"], false, true));
echo($prepend.getContentItemText($elementNode["content"], false, true).$append);
}
}
}
function createElementNode(mixed $elementNode) : void {
function createElementNode(mixed $elementNode, string $prepend="", string $append="") : void {
// Checking if we actually have a JSON object.
if(!is_array($elementNode)) {
echo('<p>Not array node !</p>');
@@ -199,6 +201,23 @@ function createElementNode(mixed $elementNode) : void {
// Adding element.
echo('<div class="m-0 pt-'.($_spacerSize*5).' pb-md-'.($_spacerSize*5).'"></div>');
break;
case "hr":
// Reading and processing the modifiers.
$_modIsSubtle = false;
if(array_key_exists("modifiers", $elementNode)) {
for ($i = 0; $i < count($elementNode["modifiers"]); $i++) {
if ($elementNode["modifiers"][$i] == "subtle") {
$_modIsSubtle = true;
}
}
}
if($_modIsSubtle) {
echo('<hr class="subtle">');
} else {
echo('<div class="sidebar-divider"></div>');
}
break;
case "h1":
case "h2":
@@ -223,8 +242,20 @@ function createElementNode(mixed $elementNode) : void {
$_indentLevel = $elementNode["indent"];
}
// Reading and processing the modifiers.
$_modNoTopMargin = false;
if(array_key_exists("modifiers", $elementNode)) {
for ($i = 0; $i < count($elementNode["modifiers"]); $i++) {
switch($elementNode["modifiers"][$i]) {
case "no-top-margin":
$_modNoTopMargin = true;
break;
}
}
}
// Opening paragraph.
echo('<p'.($_indentLevel?' class="ml-md-'.($_indentLevel*5).'"':'').'>');
echo('<p class="'.($_modNoTopMargin?'mt-0 mb-10':'my-10').($_indentLevel?' ml-md-'.($_indentLevel*5):'').'">');
// Adding content.
processStandardContentSubNode($elementNode);
@@ -283,13 +314,19 @@ function createElementNode(mixed $elementNode) : void {
}
// Reading and processing the modifiers.
$_modIsCard = false;
$_modNoTopMargin = false;
$_modNoTopPadding = false;
$_modNoBottomPadding = false;
$_modNoSizePadding = false;
$_modHorizontalScroll = false;
if(array_key_exists("modifiers", $elementNode)) {
for ($i = 0; $i < count($elementNode["modifiers"]); $i++) {
switch($elementNode["modifiers"][$i]) {
case "card":
$_modIsCard = true;
$_modNoTopMargin = true;
break;
case "no-top-margin":
$_modNoTopMargin = true;
break;
@@ -302,13 +339,17 @@ function createElementNode(mixed $elementNode) : void {
case "no-side-padding":
$_modNoSizePadding = true;
break;
case "horizontal-scroll":
$_modHorizontalScroll = true;
break;
}
}
}
// Opening container.
echo('<div class="p-'.$_containerPadding.($_modNoTopMargin?'':' mt-10').
($_modNoSizePadding?' px-0':'').($_modNoBottomPadding?' pb-0':'').($_modNoTopPadding?' pt-0':'').'">');
echo('<div class="'.($_modIsCard?'card m-0 ':'').'p-'.$_containerPadding.($_modNoTopMargin?'':' mt-10').
($_modNoSizePadding?' px-0':'').($_modNoBottomPadding?' pb-0':'').($_modNoTopPadding?' pt-0':'').
($_modHorizontalScroll?' overflow-x-scroll hide-scrollbar':'').'">');
// Adding content.
processStandardContentSubNode($elementNode);
@@ -376,6 +417,7 @@ function createElementNode(mixed $elementNode) : void {
$_modStriped = false;
$_modHover = false;
$_modInnerBordered = false;
$_modOuterBordered = false;
if(array_key_exists("modifiers", $elementNode)) {
for ($i = 0; $i < count($elementNode["modifiers"]); $i++) {
switch($elementNode["modifiers"][$i]) {
@@ -391,13 +433,17 @@ function createElementNode(mixed $elementNode) : void {
case "inner-bordered":
$_modInnerBordered = true;
break;
case "outer-bordered":
$_modOuterBordered = true;
break;
}
}
}
// Preparing table.
echo('<table class="table'.($_modNoOuterPadding?" table-no-outer-padding":"").($_modStriped?" table-striped":"").
($_modHover?" table-hover":"").($_modInnerBordered?" table-inner-bordered":"").'">');
($_modHover?" table-hover":"").($_modInnerBordered?" table-inner-bordered":"").
($_modOuterBordered?' table-outer-bordered':'').'">');
// Creating "thead".
if(array_key_exists("head", $elementNode)) {
@@ -514,6 +560,23 @@ function createElementNode(mixed $elementNode) : void {
// Ending the collapse.
echo('</div></details>');
break;
case "slider":
case "glider":
case "gallery":
// Starting the gallery
echo('<div class="glider-container d-flex">');
echo('<div class="align-self-stretch font-size-40 mr-5 my-auto glider-nav" aria-label="Previous">');
echo('<i class="fad fa-angle-left"></i></div>');
echo('<div class="glider align-self-stretch flex-fill">');
// Adding content.
processStandardContentSubNode($elementNode, "<div>", "</div>");
// Ending the gallery
echo('</div><div class="align-self-stretch font-size-40 ml-5 my-auto glider-nav" aria-label="Next">');
echo('<i class="fad fa-angle-right"></i></div></div>');
break;
default:
printErrorTextElement(sprintf(localize("error.content.data.part.unknown"), $elementNode["type"]));

View File

@@ -64,10 +64,10 @@ if(!isset($SIDEBAR_ID)) {
<span class="sidebar-icon"><i class="fad fa-link"></i></span>
<?php print(localize("links.title")); ?>
</a>
<a id="sbl-about" href="<?php print(l10n_url_abs('/about/')); ?>" class="sidebar-link sidebar-link-with-icon<?php if($SIDEBAR_ID=="about"){echo(" active");} ?>">
<!--<a id="sbl-about" href="<?php print(l10n_url_abs('/about/')); ?>" class="sidebar-link sidebar-link-with-icon<?php if($SIDEBAR_ID=="about"){echo(" active");} ?>">
<span class="sidebar-icon"><i class="fad fa-user"></i></span>
<?php print(localize("about.title")); ?>
</a>
</a>-->
<a id="sbl-contact" href="<?php print(l10n_url_abs('/contact/')); ?>" class="sidebar-link sidebar-link-with-icon<?php if($SIDEBAR_ID=="contact"){echo(" active");} ?>">
<span class="sidebar-icon"><i class="fad fa-mailbox"></i></span>
<?php print(localize("contact.title")); ?>

View File

@@ -241,7 +241,7 @@ if($content_has_error) {
}
// New elements test zone. - START
// New elements test zone. - END
// Closing the content container.
@@ -272,7 +272,7 @@ if($content_has_error) {
<?php include 'footer.php'; ?>
</div>
<script src="/resources/HalfMoon/1.1.1/js/halfmoon.min.js"></script>
<script src="/resources/GliderJs/1.7.6/glider-compat.min.js"></script>
<script src="/resources/GliderJs/1.7.6/glider.min.js"></script>
<script src="/resources/Azias/js/nibblepoker.lu.js"></script>
</body>
</html>

View File

@@ -111,9 +111,7 @@
}
},
{
"type": "spacer", "size": 2
},
{"type": "spacer", "size": 2},
{
"type": "collapse",

184
content/items/test.json Normal file
View File

@@ -0,0 +1,184 @@
{
"title": {
"icon": "fad fa-debug",
"page": {"en": "Testing page", "fr": "Page de test"},
"card": {
"main": {"en": "Testing page", "fr": "Page de test"},
"sub": {"en": "How did you end up here ?", "fr": "title.card.sub.fr"}
}
},
"meta": {
"title": {"en": "Testing page", "fr": "Page de test"},
"description": {
"en": "A test page used internally when writing new content rules and/or elements.",
"fr": "Une page de test utilisé pour écrire de nouvelles règles ou éléments pour ce site."
}
},
"parts": [
{
"_": "Testing the paragraph padding and margin.",
"type": "container", "padding": 10,
"modifiers": ["no-bottom-padding", "no-top-margin"],
"content": {
"parts": [
{
"type": "paragraph", "modifiers": ["no-top-margin"],
"content": {"en": "container.p10.no-bottom-padding.no-top-margin &gt; p.no-top-margin"}
},{
"type": "paragraph", "modifiers": ["no-top-margin"],
"content": {"en": "Joe mama !"}
}
]
}
},
{"type": "hr"},
{
"_": "Testing the paragraph padding and margin.",
"type": "container", "padding": 10,
"modifiers": ["no-bottom-padding", "no-top-margin"],
"content": {
"parts": [
{
"type": "paragraph", "modifiers": ["no-top-margin"],
"content": {"en": "container.p10.no-bottom-padding.no-top-margin &gt; gallery &gt; ..."}
},{
"type": "gallery", "modifiers": [],
"content": {
"parts": [
{
"type": "paragraph", "modifiers": ["no-top-margin"],
"content": {"en": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut eget tempus nisl."}
},
{
"type": "paragraph", "modifiers": ["no-top-margin"],
"content": {"en": "Donec et sollicitudin tortor. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus."}
},
{
"type": "paragraph", "modifiers": ["no-top-margin"],
"content": {"en": "Nullam iaculis nec ex quis tincidunt. Cras mattis magna magna, id laoreet elit pharetra in. Cras lacinia tempus tincidunt."}
}
]
}
}
]
}
},
{"type": "hr"},
{
"_": "Testing tables",
"type": "container", "padding": 10,
"modifiers": ["no-bottom-padding", "no-top-margin"],
"content": {
"parts": [
{
"type": "paragraph", "modifiers": ["no-top-margin"],
"content": {"en": "container.p10.no-bottom-padding.no-top-margin &gt; table.striped.inner-bordered"}
},{
"type": "table",
"modifiers": ["striped", "inner-bordered"],
"head": [
{"en": "Column 1"}, {"en": "Column 2"}, {"en": "Column 3"}, {"en": "Column 4"}
],
"body": [
[{"en": "Data 1"}, {"en": "Data 2"}, {"en": "Data 3"}, {"en": "Data 4"}],
[{"en": "Data 5"}, {"en": "Data 6"}, {"en": "Data 7"}, {"en": "Data 8"}]
]
}
]
}
},
{"type": "hr"},
{
"_": "Testing tables",
"type": "container", "padding": 10,
"modifiers": ["no-bottom-padding", "no-top-margin"],
"content": {
"parts": [
{
"type": "paragraph", "modifiers": ["no-top-margin"],
"content": {"en": "container.p10.no-bottom-padding.no-top-margin &gt; table.striped.inner-bordered.outer-bordered"}
},{
"type": "table",
"modifiers": ["striped", "inner-bordered", "outer-bordered"],
"head": [
{"en": "Column 1"}, {"en": "Column 2"}, {"en": "Column 3"}, {"en": "Column 4"}
],
"body": [
[{"en": "Data 1"}, {"en": "Data 2"}, {"en": "Data 3"}, {"en": "Data 4"}],
[{"en": "Data 5"}, {"en": "Data 6"}, {"en": "Data 7"}, {"en": "Data 8"}]
]
}
]
}
},
{"type": "hr"},
{
"_": "Testing tables",
"type": "container", "padding": 10,
"modifiers": ["no-bottom-padding", "no-top-margin"],
"content": {
"parts": [
{
"type": "paragraph", "modifiers": ["no-top-margin"],
"content": {"en": "container.p10.no-bottom-padding.no-top-margin &gt; container.p0.card?horizontal-scroll &gt; table.striped.inner-bordered"}
},
{
"_": "Testing tables",
"type": "container", "padding": 0,
"modifiers": ["no-bottom-padding", "no-top-margin", "card"],
"content": {
"parts": [
{
"type": "table",
"modifiers": ["striped", "inner-bordered"],
"head": [
{"en": "Column 1"}, {"en": "Column 2"}, {"en": "Column 3"}, {"en": "Column 4"}
],
"body": [
[{"en": "Data 1"}, {"en": "Data 2"}, {"en": "Data 3"}, {"en": "Data 4"}],
[{"en": "Data 5"}, {"en": "Data 6"}, {"en": "Data 7"}, {"en": "Data 8"}]
]
}
]
}
},
{"type": "spacer", "size": 2},
{
"_": "Testing tables",
"type": "container", "padding": 0,
"modifiers": ["no-bottom-padding", "no-top-margin", "card", "horizontal-scroll"],
"content": {
"parts": [
{
"type": "table",
"modifiers": ["striped", "inner-bordered"],
"head": [
{"en": "Column 1"}, {"en": "Column 2"}, {"en": "Column 3"}, {"en": "Column 4"}, {"en": "Column 5"}, {"en": "Column 6"}
],
"body": [
[{"en": "Data 1"}, {"en": "Data 2"}, {"en": "Data 3"}, {"en": "Data 4"}, {"en": "Data 5"}, {"en": "Data 6"}],
[{"en": "Data 7"}, {"en": "Data 8"}, {"en": "Data 9"}, {"en": "Data 10"}, {"en": "Data 11"}, {"en": "Data 12"}]
]
}
]
}
}
]
}
},
{"type": "spacer", "size": 2}
],
"tags": ["test"]
}

View File

@@ -51,6 +51,15 @@ img.no-save {
.font-size-30 {
font-size: 3.0rem!important;
}
.font-size-30 {
font-size: 3.0rem!important;
}
.font-size-35 {
font-size: 3.5rem!important;
}
.font-size-40 {
font-size: 4.0rem!important;
}
.text-super-muted {
color: #89898A;
}
@@ -61,8 +70,8 @@ img.no-save {
align-items: stretch;
}
.py-01 {
padding-top: 0.01rem;
padding-bottom: 0.01rem;
padding-top: 0.01rem!important;
padding-bottom: 0.01rem!important;
}
.hide-scrollbar::-webkit-scrollbar {
display: none;
@@ -71,6 +80,9 @@ img.no-save {
-ms-overflow-style: none;
scrollbar-width: none;
}
.cursor-pointer {
cursor: pointer;
}
/* Unique rules */
#copyright-text {
@@ -113,6 +125,17 @@ hr, hr.dark-mde, hr.subtle {
margin-bottom: 5px;
}
/* Glider rules */
.glider {
border: var(--card-border-width) solid var(--dm-card-border-color);
box-shadow: inset 1px 0 25px 5px rgba(0, 0, 0, 0.1);
border-radius: 5px;
}
.glider-nav {
cursor: pointer;
height: 100%;
}
/* Content */
/* Content > Search */
@media (max-width: 992px) {
@@ -213,3 +236,17 @@ div.last-inner-collapse-border-fix {
code.w-full {
white-space: pre;
}
/* Temporary */
/*.glider >div {
border: 1px solid yellow;
}
.t01 > div {
border: 1px solid cyan;
}
.glider > div > * {
border: 1px solid green;
}
.glider, .t01 {
border: 1px solid deeppink !important;
}/**/

View File

@@ -23,3 +23,35 @@ if(document.getElementById('button-copy-tox-id-backup') != null) {
navigator.clipboard.writeText("01ABBD4515C8FA56231333D1022CEEE0A605F4E85F8A945365F56D196A1BBA10FB4DCE08DBE8");
});
}
// Creating the galleries from Glider.js
window.addEventListener('load', function(){
document.querySelectorAll(".glider").forEach(element => {
new Glider(element, {
slidesToShow: 1,
draggable: true,
scrollLock: true,
scrollLockDelay: 125,
rewind: true,
arrows: {
prev: element.previousSibling,
next: element.nextSibling
},
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 2,
duration: 0.25
}
},{
breakpoint: 992,
settings: {
slidesToShow: 3,
slidesToScroll: 1
}
}
]
});
});
})