From 55d5dc0a35f3c504508142875a49444b610c95b6 Mon Sep 17 00:00:00 2001 From: Shish Date: Thu, 4 Jan 2024 13:57:45 +0000 Subject: [PATCH] [themes] have themes implement head_html/body_html rather than render --- core/basepage.php | 57 ++++++++-------- core/microhtml.php | 9 +-- themes/danbooru/page.class.php | 45 ++++++------ themes/danbooru2/page.class.php | 11 +-- themes/futaba/page.class.php | 11 +-- themes/lite/page.class.php | 11 +-- themes/rule34v2/page.class.php | 117 ++++++++++++++++---------------- themes/warm/page.class.php | 11 +-- 8 files changed, 114 insertions(+), 158 deletions(-) diff --git a/core/basepage.php b/core/basepage.php index e23abbac..e991a6ff 100644 --- a/core/basepage.php +++ b/core/basepage.php @@ -6,6 +6,8 @@ namespace Shimmie2; use MicroHTML\HTMLElement; +use function MicroHTML\{emptyHTML,rawHTML,HTML,HEAD,BODY}; + require_once "core/event.php"; enum PageMode: string @@ -530,16 +532,17 @@ class BasePage */ public function render() { - $head_html = $this->head_html(); - $body_html = $this->body_html(); + $head = $this->head_html(); + $body = $this->body_html(); - print << - - $head_html - $body_html - -EOD; + print emptyHTML( + rawHTML(""), + HTML( + ["lang" => "en"], + HEAD(rawHTML($head)), + BODY(rawHTML($body)) + ) + ); } protected function head_html(): string @@ -547,10 +550,8 @@ EOD; $html_header_html = $this->get_all_html_headers(); return " - - {$this->title} - $html_header_html - + {$this->title} + $html_header_html "; } @@ -585,22 +586,20 @@ EOD; $footer_html = $this->footer_html(); $flash_html = $this->flash ? "".nl2br(html_escape(implode("\n", $this->flash)))."" : ""; return " - -
- {$this->heading} - $sub_block_html -
- -
- $flash_html - $main_block_html -
-
- $footer_html -
- +
+ {$this->heading} + $sub_block_html +
+ +
+ $flash_html + $main_block_html +
+
+ $footer_html +
"; } diff --git a/core/microhtml.php b/core/microhtml.php index c7848900..f3eb3681 100644 --- a/core/microhtml.php +++ b/core/microhtml.php @@ -6,7 +6,7 @@ namespace Shimmie2; use MicroHTML\HTMLElement; -use function MicroHTML\emptyHTML; +use function MicroHTML\{emptyHTML}; use function MicroHTML\A; use function MicroHTML\FORM; use function MicroHTML\INPUT; @@ -16,12 +16,7 @@ use function MicroHTML\PRE; use function MicroHTML\P; use function MicroHTML\SELECT; use function MicroHTML\SPAN; -use function MicroHTML\TABLE; -use function MicroHTML\THEAD; -use function MicroHTML\TFOOT; -use function MicroHTML\TR; -use function MicroHTML\TH; -use function MicroHTML\TD; +use function MicroHTML\{TABLE,THEAD,TFOOT,TR,TH,TD}; function SHM_FORM(string $target, string $method = "POST", bool $multipart = false, string $form_id = "", string $onsubmit = "", string $name = ""): HTMLElement { diff --git a/themes/danbooru/page.class.php b/themes/danbooru/page.class.php index 6ff8dba7..d0bafacc 100644 --- a/themes/danbooru/page.class.php +++ b/themes/danbooru/page.class.php @@ -50,7 +50,7 @@ Tips * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ class Page extends BasePage { - public function render() + public function body_html(): string { global $config; @@ -123,33 +123,26 @@ class Page extends BasePage } $flash_html = $this->flash ? "".nl2br(html_escape(implode("\n", $this->flash)))."" : ""; - $head_html = $this->head_html(); $footer_html = $this->footer_html(); - print << - - $head_html - -
- $title_link - - -
- $subheading - $sub_block_html - $left -
- $flash_html - $main_block_html -
-
$footer_html
- - + return << + $title_link + + + + $subheading + $sub_block_html + $left +
+ $flash_html + $main_block_html +
+
$footer_html
EOD; } diff --git a/themes/danbooru2/page.class.php b/themes/danbooru2/page.class.php index d34354a3..d714cbda 100644 --- a/themes/danbooru2/page.class.php +++ b/themes/danbooru2/page.class.php @@ -51,7 +51,7 @@ Tips class Page extends BasePage { - public function render() + public function body_html(): string { global $config; @@ -124,14 +124,9 @@ class Page extends BasePage } $flash_html = $this->flash ? "".nl2br(html_escape(implode("\n", $this->flash)))."" : ""; - $head_html = $this->head_html(); $footer_html = $this->footer_html(); - print << - - $head_html - + return << $title_link