From 8417e692d7b1570d097083818c55425e644d010e Mon Sep 17 00:00:00 2001 From: Ro Date: Mon, 14 Jun 2021 12:22:35 -0700 Subject: [PATCH] removed pagination from Pages API request, added API request for tags --- brain/api/v1/PagesAPI.inc.php | 15 ++++++++++++--- brain/data/Settings.inc.php | 9 +++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/brain/api/v1/PagesAPI.inc.php b/brain/api/v1/PagesAPI.inc.php index 0d7a482..2786efc 100644 --- a/brain/api/v1/PagesAPI.inc.php +++ b/brain/api/v1/PagesAPI.inc.php @@ -1,4 +1,5 @@ getContents(); switch ($task) { case "published": - $pageNum = $args["fifth"]; - $result = (new Book("../content/pages"))->getPages($pageNum, 4, $task); + //$pageNum = $args["fifth"]; not not needed but gonna keep remnant in case it becomes useful/needed + $published = filter($content, function ($item) { + return $item["published"] == true && $item["deleted"] == false; + }); + + $result = ["pages" => $published, "totalPages" => count($published)]; + //$result = (new Book("../content/pages"))->getPages($pageNum, 4, $task); break; case "single": $uuid = $args["fifth"]; $result = (new Book("../content/pages"))->findPageById($uuid); break; + case "tags": + $result = Settings::getTags(); + break; default: $result = [ "message" => "Hm, no task. That's unfortunate", diff --git a/brain/data/Settings.inc.php b/brain/data/Settings.inc.php index d76f8f4..47703be 100644 --- a/brain/data/Settings.inc.php +++ b/brain/data/Settings.inc.php @@ -5,7 +5,7 @@ use function _\remove; class Settings { private $folks; - private $tags; + private static $tags; private $themes = []; private static $settings; @@ -13,7 +13,7 @@ class Settings { //gets all settings files and converts to php objects $this->folks = json_decode(file_get_contents("../config/folks.json"), true); - $this->tags = json_decode(file_get_contents("../config/tags.json"), true); + self::$tags = json_decode(file_get_contents("../config/tags.json"), true); self::$settings = json_decode( file_get_contents("../config/settings.json"), true @@ -123,6 +123,11 @@ class Settings return self::$settings; } + public static function getTags() + { + return self::$tags; + } + public static function updateGlobalData($key, $data) { $settings = self::$settings;