55 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<!DOCTYPE html>
 | 
						|
<html>
 | 
						|
	<head>
 | 
						|
		<?php include $_SERVER['DOCUMENT_ROOT'].'/src/common-meta.php';?>
 | 
						|
		<link rel="shortcut icon" href="/favicon.ico" />
 | 
						|
		<title>9iron - Posts</title>
 | 
						|
	</head>
 | 
						|
	<body>
 | 
						|
		<?php include $_SERVER['DOCUMENT_ROOT'].'/src/common-header.php';?>
 | 
						|
		<div class="content">
 | 
						|
			<div class="section">
 | 
						|
				<h1>Posts</h1>
 | 
						|
				<p>Included is a list of all blog posts I've written here, latest first. I try to post as frequently as I can make an excuse to.</p>
 | 
						|
				<p>It's also got a <a href="/feed">feed</a> if you want it.</p>
 | 
						|
				<dl>
 | 
						|
				<?php
 | 
						|
					$dir = $_SERVER['DOCUMENT_ROOT']."/posts/";
 | 
						|
					$posts = scandir($dir, 1);
 | 
						|
					$ignore = array("index.php", "feed.php", ".", "..");
 | 
						|
					$extensions = array(".php", ".html", ".htm");
 | 
						|
					foreach ($posts as &$post) {
 | 
						|
						// See if it's a blacklisted file
 | 
						|
						if (in_array($post, $ignore)) {
 | 
						|
							continue;
 | 
						|
						}
 | 
						|
						$postlocation = $_SERVER['DOCUMENT_ROOT']."/posts/".$post;
 | 
						|
						$posturl = "/posts/".$post;
 | 
						|
						// Get the title
 | 
						|
						$title = "Title not available";
 | 
						|
						$summary = "Summary not available";
 | 
						|
						$dom = new DOMDocument();
 | 
						|
						if ($dom->loadHTMLFile($postlocation)) {
 | 
						|
							$xpath_section = new DOMXpath($dom);
 | 
						|
							$list = $dom->getElementsByTagName("title");
 | 
						|
							if ($list->length > 0) {
 | 
						|
								$title = $list->item(0)->textContent;
 | 
						|
							}
 | 
						|
							$list = $xpath_section->query('//div[@class="section"]//p');
 | 
						|
							if ($list->length > 0) {
 | 
						|
								$summary = $list->item(0)->nodeValue;
 | 
						|
							}
 | 
						|
						}
 | 
						|
						// Produce a list item
 | 
						|
						$post = str_replace($extensions, "", $post);
 | 
						|
						$title = str_replace("9iron - ", "", $title);
 | 
						|
						echo "<a href=\"$posturl\"><div class=\"subcontainer\"><h3>$post: $title</h3><p>$summary</p></div></a>";
 | 
						|
					}
 | 
						|
				?>
 | 
						|
				</dl>
 | 
						|
			</div>
 | 
						|
		</div>
 | 
						|
		<?php include $_SERVER['DOCUMENT_ROOT'].'/src/common-footer.php';?>
 | 
						|
	</body>
 | 
						|
</html>
 |