From daff5c7a013669c5eb8099d35d62bacd980a2914 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Mon, 25 Oct 2021 17:20:05 +0200 Subject: [PATCH] dwv21w43b --- public/assets/css/search.css | 36 ++++++++++++++++++++ src/search/Search.php | 24 ++++++++++--- src/search/templates/card_default.html | 8 +++++ src/search/templates/card_error_display.html | 4 +++ src/search/templates/default.html | 2 +- src/search/templates/result_about.html | 5 +++ 6 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 src/search/templates/card_default.html create mode 100644 src/search/templates/card_error_display.html create mode 100644 src/search/templates/result_about.html diff --git a/public/assets/css/search.css b/public/assets/css/search.css index 6a128fb..a56e400 100644 --- a/public/assets/css/search.css +++ b/public/assets/css/search.css @@ -103,6 +103,35 @@ header h1 { word-break: break-word; } +/* -- Results > Types -- */ + +.card.error { + gap: unset; +} + +.card.error p > a { + background-color: rgba(var(--palette-contrast),.1); +} + +.resultsFooter { + display: flex; + justify-content: space-between; + align-items: center; +} + +.resultsFooter svg { + width: 41px; + height: 40px; +} + +.resultsFooter svg polygon { + fill: none; + stroke: var(--swatch-contrast); + stroke-width: 1px; +} + +/* ---- */ + .button { padding: var(--padding); text-align: center; @@ -136,6 +165,13 @@ header h1 { color: var(--swatch-contrast); cursor: pointer; } + + /* ---- */ + + .resultsFooter svg:hover polygon { + fill: var(--swatch-contrast); + cursor: pointer; + } } @media (pointer: fine) { diff --git a/src/search/Search.php b/src/search/Search.php index dd614fd..d486f1f 100644 --- a/src/search/Search.php +++ b/src/search/Search.php @@ -7,22 +7,38 @@ public function __construct() { $this->query = $query; - switch($_SERVER["HTTP_CONTENT_TYPE"]) { + $mime_type = $_SERVER["HTTP_CONTENT_TYPE"] ? $_SERVER["HTTP_CONTENT_TYPE"] : $_GET["f"]; + switch($mime_type) { + case "html": case "text/html": $this->get_html(); break; default: + case "json": case "application/json": $this->get_json(); break; } } + private function get_html_template($name) { + $path = dirname(__FILE__,1)."/templates/${name}.html"; + if(!is_file($path)) { + return $this->get_html_template("card_error_display"); + } + $html = Import::file($path); + return $html; + } + private function get_html() { - header("Content-Type: text/html"); - $template = Import::file("templates/default.html"); - echo $template; + $results = [ + $this->get_html_template("card_default"), + $this->get_html_template("defaults"), + $this->get_html_template("card_default"), + $this->get_html_template("result_about") + ]; + echo implode("",$results); } private function get_json() { diff --git a/src/search/templates/card_default.html b/src/search/templates/card_default.html new file mode 100644 index 0000000..29b5117 --- /dev/null +++ b/src/search/templates/card_default.html @@ -0,0 +1,8 @@ +
+
+ +

%s

+
+

%s

+

read more

+
\ No newline at end of file diff --git a/src/search/templates/card_error_display.html b/src/search/templates/card_error_display.html new file mode 100644 index 0000000..8a599c4 --- /dev/null +++ b/src/search/templates/card_error_display.html @@ -0,0 +1,4 @@ +
+

There was a problem displaying this result

+

This is a problem on my side, sorry about that

+
\ No newline at end of file diff --git a/src/search/templates/default.html b/src/search/templates/default.html index 92d766a..29b5117 100644 --- a/src/search/templates/default.html +++ b/src/search/templates/default.html @@ -4,5 +4,5 @@

%s

%s

-

read more

+

read more

\ No newline at end of file diff --git a/src/search/templates/result_about.html b/src/search/templates/result_about.html new file mode 100644 index 0000000..e9c39ae --- /dev/null +++ b/src/search/templates/result_about.html @@ -0,0 +1,5 @@ +
+ +

showing %s/%s results (query took %s seconds)

+ +
\ No newline at end of file