From 1d62401c897a5ba82d0def92d97d09195a6d676f Mon Sep 17 00:00:00 2001 From: Minteck <46352972+Minteck@users.noreply.github.com> Date: Thu, 1 Jul 2021 00:54:32 +0200 Subject: Fixed stuff + official logo --- _site/includes/admin/authorized.json | 4 ++ _site/includes/admin/credentials.default.json | 5 ++ _site/includes/articles/getlist.php | 93 ++++++++++++++++++++++++++- _site/includes/dom/footer.php | 3 +- _site/includes/dom/header.php | 84 ++++++++++++++++++++++-- 5 files changed, 183 insertions(+), 6 deletions(-) create mode 100644 _site/includes/admin/authorized.json create mode 100644 _site/includes/admin/credentials.default.json (limited to '_site/includes') diff --git a/_site/includes/admin/authorized.json b/_site/includes/admin/authorized.json new file mode 100644 index 0000000..72784f0 --- /dev/null +++ b/_site/includes/admin/authorized.json @@ -0,0 +1,4 @@ +[ + "antoine62", + "Minteck" +] \ No newline at end of file diff --git a/_site/includes/admin/credentials.default.json b/_site/includes/admin/credentials.default.json new file mode 100644 index 0000000..83b9e5b --- /dev/null +++ b/_site/includes/admin/credentials.default.json @@ -0,0 +1,5 @@ +{ + "id": "your client id", + "secret": "your client secret", + "token": "the personnal access token of a user that has access to the repository" +} \ No newline at end of file diff --git a/_site/includes/articles/getlist.php b/_site/includes/articles/getlist.php index e82a192..8018472 100644 --- a/_site/includes/articles/getlist.php +++ b/_site/includes/articles/getlist.php @@ -22,7 +22,8 @@ function getArticlesList($ordered = true) { "title" => $id, "author" => "Blogchain", "cover" => null, - "extract" => "" + "extract" => "", + "admin" => false ]; $list[$id]["id"] = $id; @@ -84,6 +85,96 @@ function getArticlesList($ordered = true) { } else { $list[$id]["content"]["mini"] = $list[$id]["content"]["clean"]; } + if (strlen($list[$id]["content"]["clean"]) > 500) { + $list[$id]["content"]["little"] = substr($list[$id]["content"]["clean"], 0, 500) . "…"; + } else { + $list[$id]["content"]["little"] = $list[$id]["content"]["clean"]; + } + } + } + + $files = scandir($_SERVER['DOCUMENT_ROOT'] . "/../_posts/_drafts"); + + foreach ($files as $file) { + if (is_file($_SERVER['DOCUMENT_ROOT'] . "/../_posts/_drafts/" . $file) && $file !== "_template.md" && $file !== ".gitkeep") { + $content = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../_posts/_drafts/" . $file); + $lines = explode("\n", $content); + $unlined = []; + + $id = substr($file, 0, -3); + $list[$id] = [ + "date" => date("Ymd"), + "title" => $id, + "author" => [ "Blogchain Authors" ], + "cover" => null, + "extract" => "", + "admin" => true + ]; + $list[$id]["id"] = $id; + + $propertiesMode = false; + $propertiesDone = false; + $cline = 0; + $upline = 0; + foreach ($lines as $line) { + if (!$propertiesDone) { + if (trim($line) === "---") { + if ($propertiesMode) { + $propertiesDone = true; + $propertiesMode = false; + $upline = $cline + 1; + } else { + $propertiesMode = true; + } + } else if ($propertiesMode) { + $parts = explode(":", $line); + $p_ins = trim($parts[0]); + array_shift($parts); + $p_data = trim(implode(":", $parts)); + + switch ($p_ins) { + case "date": + $pp_dt = DateTime::createFromFormat('Y-m-d', $p_data); + $list[$id]["date"] = $pp_dt->format("Ymd"); + break; + + case "title": + $list[$id]["title"] = $p_data; + break; + + case "author": + $list[$id]["author"] = explode("|", $p_data); + break; + + case "cover": + $list[$id]["cover"] = $p_data; + break; + } + } + } + $cline++; + } + + $i = 0; + while ($i++ < $upline) { + array_shift($lines); + } + + $text = implode("\n", $lines); + + $list[$id]["content"] = []; + $list[$id]["content"]["full"] = $Parsedown->text($text); + $list[$id]["content"]["clean"] = strip_tags($list[$id]["content"]["full"]); + if (strlen($list[$id]["content"]["clean"]) > 100) { + $list[$id]["content"]["mini"] = substr($list[$id]["content"]["clean"], 0, 100) . "…"; + } else { + $list[$id]["content"]["mini"] = $list[$id]["content"]["clean"]; + } + if (strlen($list[$id]["content"]["clean"]) > 500) { + $list[$id]["content"]["little"] = substr($list[$id]["content"]["clean"], 0, 500) . "…"; + } else { + $list[$id]["content"]["little"] = $list[$id]["content"]["clean"]; + } } } diff --git a/_site/includes/dom/footer.php b/_site/includes/dom/footer.php index 1d0fb97..2b0a1f2 100644 --- a/_site/includes/dom/footer.php +++ b/_site/includes/dom/footer.php @@ -1,4 +1,5 @@ -
+ +View RSS feed= $admin ? " (doesn't include unreleased articles)" : "" ?>