aboutsummaryrefslogtreecommitdiff
path: root/_site/includes/articles
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-08-04 16:56:12 +0200
committerMinteck <nekostarfan@gmail.com>2021-08-04 16:56:12 +0200
commit896fa7c96856142f844d958b049d5432f511641c (patch)
treed8bbbe327939ade9bd13276c6b4c6105adf95323 /_site/includes/articles
parent7df2fb3f5ee0ac5bd89e127c86ad0c2d6de126d1 (diff)
downloadunchainedtech-896fa7c96856142f844d958b049d5432f511641c.tar.gz
unchainedtech-896fa7c96856142f844d958b049d5432f511641c.tar.bz2
unchainedtech-896fa7c96856142f844d958b049d5432f511641c.zip
v2.0
Diffstat (limited to '_site/includes/articles')
-rw-r--r--_site/includes/articles/getlist.php396
1 files changed, 203 insertions, 193 deletions
diff --git a/_site/includes/articles/getlist.php b/_site/includes/articles/getlist.php
index 8a342f1..2716e3e 100644
--- a/_site/includes/articles/getlist.php
+++ b/_site/includes/articles/getlist.php
@@ -1,194 +1,204 @@
-<?php
-
-$listGetTimeout = 0;
-
-function getArticlesList($ordered = true) {
- $listGetStart = new DateTime("now");
- global $Parsedown;
- global $listGetTimeout;
-
- $list = [];
- $files = scandir($_SERVER['DOCUMENT_ROOT'] . "/../_posts");
-
- foreach ($files as $file) {
- if (is_file($_SERVER['DOCUMENT_ROOT'] . "/../_posts/" . $file)) {
- $content = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../_posts/" . $file);
- $lines = explode("\n", $content);
- $unlined = [];
-
- $id = substr($file, 0, -3);
- $list[$id] = [
- "date" => date("Y-m-d"),
- "title" => $id,
- "author" => "UnchainedTech",
- "cover" => null,
- "extract" => "",
- "admin" => false
- ];
- $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"];
- }
- }
- }
-
- $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" => [ "UnchainedTech 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"];
- }
- }
- }
-
- $listGetEnd = new DateTime("now");
-
- $listGetTimeoutA = $listGetStart->diff($listGetEnd);
- $listGetTimeout = $listGetTimeoutA->f;
-
- if ($ordered) {
- usort($list, function($a, $b) {
- return strtoupper($a['date']) <=> strtoupper($b['date']);
- });
- $list = array_reverse($list);
- }
-
- return $list;
+<?php
+
+$listGetTimeout = 0;
+
+function getArticlesList($ordered = true) {
+ $listGetStart = new DateTime("now");
+ global $Parsedown;
+ global $listGetTimeout;
+
+ $list = [];
+ $files = scandir($_SERVER['DOCUMENT_ROOT'] . "/../_posts");
+
+ foreach ($files as $file) {
+ if (is_file($_SERVER['DOCUMENT_ROOT'] . "/../_posts/" . $file)) {
+ $content = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../_posts/" . $file);
+ $lines = explode("\n", $content);
+ $unlined = [];
+
+ $id = substr($file, 0, -3);
+ $list[$id] = [
+ "date" => date("Y-m-d"),
+ "title" => $id,
+ "author" => "UnchainedTech",
+ "cover" => null,
+ "extract" => "",
+ "admin" => false,
+ "category" => "Uncategorized"
+ ];
+ $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;
+
+ case "category":
+ $list[$id]["category"] = $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"];
+ }
+ }
+ }
+
+ $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" => [ "UnchainedTech Authors" ],
+ "cover" => null,
+ "extract" => "",
+ "admin" => true,
+ "category" => "Uncategorized"
+ ];
+ $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;
+
+ case "category":
+ $list[$id]["category"] = $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"];
+ }
+ }
+ }
+
+ $listGetEnd = new DateTime("now");
+
+ $listGetTimeoutA = $listGetStart->diff($listGetEnd);
+ $listGetTimeout = $listGetTimeoutA->f;
+
+ if ($ordered) {
+ usort($list, function($a, $b) {
+ return strtoupper($a['date']) <=> strtoupper($b['date']);
+ });
+ $list = array_reverse($list);
+ }
+
+ return $list;
} \ No newline at end of file