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/system.php | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 _phpetite/system.php (limited to '_phpetite/system.php') diff --git a/_phpetite/system.php b/_phpetite/system.php new file mode 100644 index 0000000..10f43f8 --- /dev/null +++ b/_phpetite/system.php @@ -0,0 +1,117 @@ +getType() == 'file' && strpos($file->getFilename(),'.md') ) { + $files[] = $file->getFilename(); + } +} +rsort($files); + +foreach ($files as $file) { + + $filename_no_ext = substr($file, 0, strrpos($file, ".")); + $file_path = __DIR__.'/../content/'.$file; + $file = fopen($file_path, 'r'); + $post_title = trim(fgets($file),'#'); + $post_slug = create_slug($filename_no_ext.$post_title); + fclose($file); + + $parsedown = new ParsedownExtraPlugin(); + // Allow single line breaks + $parsedown->setBreaksEnabled(true); + // Add image dimensions, lazy loading and figures + $parsedown->imageAttributes = ['width', 'height']; + $parsedown->imageAttributes = ['loading' => 'lazy']; + $parsedown->figuresEnabled = true; + // Remove the id and #links on footnotes + $parsedown->footnoteLinkAttributes = function() {return ['href' => '#'];}; + $parsedown->footnoteReferenceAttributes = function() {return ['id' => null];}; + $parsedown->footnoteBackLinkAttributes = function() {return ['href' => '#'];}; + $parsedown->footnoteBackReferenceAttributes = function() {return ['id' => null];}; + + $toc .= '
  • '.$post_title.'
  • '; + $posts .= '
    '.$parsedown->text(file_get_contents($file_path)).'
    '; + + $rss_items .= ' + + '.trim($post_title, " \t\n\r").' + + '.substr($filename_no_ext, 0, 10).'T00:00:00+00:00 + '.$site_url.'/#'.$post_slug.' + '.htmlspecialchars($parsedown->text(file_get_contents($file_path)), ENT_XML1, 'UTF-8').' + + '; + +} + +$files_pages = []; +foreach (new DirectoryIterator(__DIR__.'/../content/_pages/') as $file_page) { + if ( $file_page->getType() == 'file' && strpos($file_page->getFilename(),'.md') ) { + $files_pages[] = $file_page->getFilename(); + } +} +rsort($files_pages); + +foreach ($files_pages as $file_page) { + + $filename_no_ext_page = substr($file_page, 0, strrpos($file_page, ".")); + $file_path_page = __DIR__.'/../content/_pages/'.$file_page; + $file_page = fopen($file_path_page, 'r'); + $page_title = trim(fgets($file_page),'# '); + $page_slug = create_slug($filename_no_ext_page); + fclose($file_page); + + $parsedown = new ParsedownExtraPlugin(); + // Allow single line breaks + $parsedown->setBreaksEnabled(true); + // Add image dimensions, lazy loading and figures + $parsedown->imageAttributes = ['width', 'height']; + $parsedown->imageAttributes = ['loading' => 'lazy']; + $parsedown->figuresEnabled = true; + // Remove the id and #links on footnotes + $parsedown->footnoteLinkAttributes = function() {return ['href' => '#'];}; + $parsedown->footnoteReferenceAttributes = function() {return ['id' => null];}; + $parsedown->footnoteBackLinkAttributes = function() {return ['href' => '#'];}; + $parsedown->footnoteBackReferenceAttributes = function() {return ['id' => null];}; + + if ($page_slug != 'home-content') { + $pages .= '
    '.$parsedown->text(file_get_contents($file_path_page)).'
    '; + } + $pages_footer .=''.trim($page_title, " \t\n\r").'/'; + +} + +?> \ No newline at end of file -- cgit v1.2.3-54-g00ecf