From 13cec3d0fc257d0e65c9a1c06bfc71648722a506 Mon Sep 17 00:00:00 2001 From: Bradley Taunt Date: Fri, 2 Feb 2024 13:05:54 -0500 Subject: Initial commit for cgit platform --- _phpetite/phpetite.php | 109 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 _phpetite/phpetite.php (limited to '_phpetite/phpetite.php') diff --git a/_phpetite/phpetite.php b/_phpetite/phpetite.php new file mode 100644 index 0000000..9090480 --- /dev/null +++ b/_phpetite/phpetite.php @@ -0,0 +1,109 @@ +, with date-and-title as #id. + +// !!! +/////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// DO NOT TOUCH anything below here unless you know what you're doing. +// Most basic use cases won't need to change anything here. +// +/////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// !!! + +// Include custom site configurations +include($_SERVER['DOCUMENT_ROOT'].'_phpetite/_config.php'); +include($_SERVER['DOCUMENT_ROOT'].'_phpetite/system.php'); + + +// $site_info takes all page content from /content/_pages/home-content.md +$site_info = '
' . $parsedown->text(file_get_contents('content/_pages/home-content.md')) .'
'; + +$cssFiles = array( + "style.css" +); + +$updated_date = date("F j, Y"); +$base_64_favicon = base64_encode(file_get_contents($site_icon)); + +$buffer = ""; +foreach ($cssFiles as $cssFile) { + $buffer .= file_get_contents($cssFile); +} +$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); +$buffer = str_replace(': ', ':', $buffer); +$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer); + +// Decide whether or not to display the site info on homepage +if ($site_info != '') { + $show_site_info = $site_info . '
'; +} else { + $show_site_info = ''; +} + +$html = << + + + + + $site_title + + + + + + + + + + + +
+

+ $site_title +

+
+
+ $posts + $pages +
+ $show_site_info + +
+
+ + + +EOD; + +if ($images_to_base64 == true) { + $dom = new DOMDocument(); + libxml_use_internal_errors(true); + $dom->loadHTML(html_entity_decode($html, ENT_QUOTES | ENT_HTML5, 'UTF-8')); + libxml_clear_errors(); + $post_images = $dom->getElementsByTagName('img'); + foreach ($post_images as $image) { + $src = $image->getAttribute('src'); + $type = pathinfo($src, PATHINFO_EXTENSION); + $data = file_get_contents($src); + $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data); + $image->setAttribute("src", $base64); + } + + $html = $dom->saveHTML(); + echo $html; +} else { + echo $html; +} + +?> \ No newline at end of file -- cgit v1.2.3-54-g00ecf