From 6c65601cc4781a4fac00f4ae2a7a8def24c28e72 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Wed, 31 May 2023 21:36:23 -0500 Subject: formatting --- index.php | 187 ++++++++++++++++++++++---------------------- src/View/class-template.php | 15 ++-- templates/template.html | 50 ++++++------ 3 files changed, 126 insertions(+), 126 deletions(-) diff --git a/index.php b/index.php index a61df1e..28a2cfe 100644 --- a/index.php +++ b/index.php @@ -1,115 +1,116 @@ - * @param string $api_url The API endpoint to use for extraction - * @param string $inline_title The

title to use in the HTML - * @return string $html_output The formatted HTML result of stories from the API - */ +* Extract a set of stories from Hacker News API and format in HTML +* +* @access public +* @author cmc +* @param string $api_url The API endpoint to use for extraction +* @param string $inline_title The

title to use in the HTML +* @return string $html_output The formatted HTML result of stories from the API +*/ function get_stories($api_url, $inline_title) { - $response_raw = file_get_contents($api_url); + $response_raw = file_get_contents($api_url); $response = json_decode($response_raw, true); $html_output = '

' . $inline_title . '

'; @@ -130,23 +131,23 @@ function get_stories($api_url, $inline_title) { } /** - * Send formatted HTML results to the user via a template - * - * @access public - * @author cmc - * @param string $page_url Canoncial URL for HTML header - * @param string $page_description Page description for HTML header - * @param string $page_title Page title for HTML header - * @param string $page_content Page content to display in
- */ +* Send formatted HTML results to the user via a template +* +* @access public +* @author cmc +* @param string $page_url Canoncial URL for HTML header +* @param string $page_description Page description for HTML header +* @param string $page_title Page title for HTML header +* @param string $page_content Page content to display in
+*/ function echo_html(string $page_url, string $page_description, string $page_title, string $page_content) { include_once 'src/View/class-template.php'; $template = new HN\View\Template( - $page_url, - $page_description, - $page_title, - $page_content + $page_url, + $page_description, + $page_title, + $page_content ); $template->echo_template(); diff --git a/src/View/class-template.php b/src/View/class-template.php index ea75648..ddcb1fa 100644 --- a/src/View/class-template.php +++ b/src/View/class-template.php @@ -3,14 +3,13 @@ namespace HN\View; /** - * Template View - * - * @author cmc - */ +* Template View +* +* @author cmc +*/ class Template { - public function __construct(string $canonical_url, string $page_description, string $page_title, string $content_col) - { + public function __construct(string $canonical_url, string $page_description, string $page_title, string $content_col) { $this->canonical_url = $canonical_url; $this->description = $page_description; $this->title = $page_title; @@ -18,8 +17,7 @@ class Template $this->current_year = date("Y"); } - public function echo_template() - { + public function echo_template() { // Get the template file $template_file = 'templates/template.html'; $page = file_get_contents($template_file); @@ -37,3 +35,4 @@ class Template } // EOF + diff --git a/templates/template.html b/templates/template.html index 9cf7c2a..bceb26f 100644 --- a/templates/template.html +++ b/templates/template.html @@ -2,35 +2,35 @@ - {page_title} - - - - - - - - + {page_title} + + + + + + + + -
- - {content} -
+
+ + {content} +
-
-

Contact

-

Source Code

-

Copyright © 2023 - {current_year}

-
+ -- cgit v1.2.3-70-g09d2