diff --git a/.gitignore b/.gitignore index 7d2b023..e2c887c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ /public/signature/cover_url.txt /public/signature/np.json /public/signature/signature.png - +.DS_Store +/.debug diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..19f950d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/index"] + path = lib/index + url = https://github.com/flashwave/index.git diff --git a/lib/fmcolour.php b/lib/fmcolour.php deleted file mode 100644 index 12a5d4f..0000000 --- a/lib/fmcolour.php +++ /dev/null @@ -1,28 +0,0 @@ -raw = $raw; - } - - public function hasColour(): bool { - return $this->raw !== null; - } - - public function getRaw(): int { - return $this->raw ?? 0; - } - - public function getRed(): int { return ($this->getRaw() >> 16) & 0xFF; } - public function getGreen(): int { return ($this->getRaw() >> 8) & 0xFF; } - public function getBlue(): int { return $this->getRaw() & 0xFF; } - - public function getHex(): string { return str_pad(dechex($this->getRaw()), 6, '0'); } - - public function getCSS(): string { - if(!$this->hasColour()) - return 'inherit'; - return '#' . $this->getHex(); - } -} diff --git a/lib/fmlanguage.php b/lib/fmlanguage.php deleted file mode 100644 index 39fbcfe..0000000 --- a/lib/fmlanguage.php +++ /dev/null @@ -1,14 +0,0 @@ - $val) - $lang->{$prop} = $val; - return $lang; - } -} diff --git a/lib/fmproject.php b/lib/fmproject.php deleted file mode 100644 index 1f50a37..0000000 --- a/lib/fmproject.php +++ /dev/null @@ -1,170 +0,0 @@ -project_id < 1 ? -1 : $this->project_id; - } - - public function getName(): string { - return $this->project_name; - } - public function getCleanName(): string { - return $this->project_name_clean ?? str_replace(' ', '-', trim(strtolower($this->getName()))); - } - - public function getSummary(): string { - return $this->project_summary ?? ''; - } - public function getDescription(): string { - return $this->project_description ?? ''; - } - public function getDescriptionLines(): array { - $linesRaw = array_reverse(explode("\n", $this->getDescription())); - $lines = []; - while(($line = array_pop($linesRaw)) !== false) { - $line = trim($line); - if(!empty($line)) - $lines[] = $line; - } - return $lines; - } - - public function getOrder(): int { - return $this->project_order; - } - public function getType(): string { - return $this->project_type; - } - public function isProject(): bool { - return $this->getType() === self::TYPE_PROJECT; - } - public function isTool(): bool { - return $this->getType() === self::TYPE_TOOL; - } - - public function isFeatured(): bool { - return boolval($this->project_featured); - } - - // TODO: INHERIT LANGUAGE COLOUR - public function hasColour(): bool { - return $this->project_colour !== null; - } - public function getColour(): FmColour { - return new FmColour($this->project_colour); - } - - public function hasHomepage(): bool { - return !empty($this->project_homepage); - } - public function getHomepage(): string { - return $this->project_homepage ?? ''; - } - - public function hasRepository(): bool { - return !empty($this->project_repository); - } - public function getRepository(): string { - return $this->project_repository ?? ''; - } - - public function hasForum(): bool { - return !empty($this->project_forum); - } - public function getForum(): string { - return $this->project_forum ?? ''; - } - - public function getCreatedTime(): DateTime { - return new DateTime('@' . ($this->project_created ?? 0)); - } - - public function isDeleted(): bool { - return $this->project_deleted !== null; - } - public function getDeletedTime(): DateTime { - return new DateTime('@' . ($this->project_deleted ?? 0)); - } - - public function isArchived(): bool { - return $this->project_archived !== null; - } - public function getArchivedTime(): DateTime { - return new DateTime('@' . ($this->project_archived ?? 0)); - } - - public function getLinks(): array { - $links = []; - if($this->hasHomepage()) - $links[] = FmProjectLink::create('homepage', 'Homepage', $this->getHomepage()); - if($this->hasRepository()) - $links[] = FmProjectLink::create('repository', 'Source', $this->getRepository()); - if($this->hasForum()) - $links[] = FmProjectLink::create('forum', 'Discussion', $this->getForum()); - return $links; - } - - public function getLanguages(): array { - return $this->languages ?? []; - } - - private function transformLanguages(): void { - if(empty($this->languages)) - return; - foreach($this->languages as &$lang) - if($lang instanceof stdClass) - $lang = FmLanguage::fromStdClass($lang); - } - - public static function byFeatured(): array { - return cache_output('projects-featured-noconvert', 300, function() { - $projects = json_decode(file_get_contents('https://flash.moe/2020/projects.php?dump_that_shit&noconvert&rf')); - - foreach($projects as &$project) { - $projRaw = (array)$project; - $project = new static; - foreach($projRaw as $prop => $val) - $project->{$prop} = $val; - $project->transformLanguages(); - } - - return $projects; - }); - } - - public static function all(): array { - return cache_output('projects-noconvert', 300, function() { - $projects = json_decode(file_get_contents('https://flash.moe/2020/projects.php?dump_that_shit&noconvert')); - - foreach($projects as &$project) { - $projRaw = (array)$project; - $project = new static; - foreach($projRaw as $prop => $val) - $project->{$prop} = $val; - $project->transformLanguages(); - } - - return $projects; - }); - } -} diff --git a/lib/fmprojectlink.php b/lib/fmprojectlink.php deleted file mode 100644 index 485bc67..0000000 --- a/lib/fmprojectlink.php +++ /dev/null @@ -1,24 +0,0 @@ -className; - } - public function getText(): string { - return $this->text; - } - public function getUrl(): string { - return $this->url; - } - - public static function create(string $class, string $text, string $url): self { - $link = new static; - $link->className = $class; - $this->text = $text; - $this->url = $url; - return $link; - } -} diff --git a/lib/index b/lib/index new file mode 160000 index 0000000..74c0e6f --- /dev/null +++ b/lib/index @@ -0,0 +1 @@ +Subproject commit 74c0e6f17c21af3669345e38598ada1d37675ad4 diff --git a/makai.php b/makai.php new file mode 100644 index 0000000..89aa8db --- /dev/null +++ b/makai.php @@ -0,0 +1,23 @@ + '/projects', diff --git a/pages/projects.php b/pages/projects.php index 044a005..2fc481c 100644 --- a/pages/projects.php +++ b/pages/projects.php @@ -1,4 +1,6 @@