0; $abs=preg_replace($re, '/', $abs, -1, $n)) {} /* absolute URL is ready! */ return $scheme.'://'.$abs; } } if (!function_exists('indent')) { function indent($str, $spaces) { $indentParts = array_filter(explode("\n", $str)); $indentParts = array_map(function ($indentPart) use ($spaces) { return str_repeat(' ', $spaces).$indentPart; }, $indentParts); return implode("\n", $indentParts); } } require_once 'files/Parsedown.php'; require_once 'files/spyc.php'; require_once 'files/truncate.php'; $Parsedown = new Parsedown(); if (isset($_GET['id'])) { $urlID = $_GET['id']; // Get entry ID from URL, if one exists. } if (isset($_GET['category'])) { $urlCategory = $_GET['category']; // Get category from URL if one exists. } if (isset($_GET['tag'])) { $urlTag = $_GET['tag']; // Get category from URL if one exists. } if (isset($_GET['current'])) { $currentPage = $_GET['current']; // Set the current page for pagination. } if (!empty($_POST['find'])) { $urlSearch = $_POST['find']; // Get entry search phrase from URL, if one exists. } if ($currentPage <= 0) { $currentPage = 1; } $directory = "../posts"; $imagesdirectory = "../image-uploads"; $debugImagesDirectory = $imagesdirectory; // Check to see if the Image Uploads folder exists... if not we'll create one. if(!is_dir($imagesdirectory)) { mkdir($imagesdirectory, 0755); } // Check to see if the Posts folder exists... if not we create one and populate it with a sample post. if(!is_dir($directory)) { mkdir($directory, 0755); $exampleDate = date('Y-m-d'); $sampleBlogEntryFile = $directory . '/' . $exampleDate .'_this-is-an-example-blog-post-to-get-you-started.md'; $sampleBlogEntryContent = "---\n"; $sampleBlogEntryContent .= "title: This is an example blog post to get you started\n"; $sampleBlogEntryContent .= "author: Jane Doe\n"; $sampleBlogEntryContent .= "category: Alloy\n"; $sampleBlogEntryContent .= "tags:\n"; $sampleBlogEntryContent .= " - RapidWeaver\n"; $sampleBlogEntryContent .= " - Foundry\n"; $sampleBlogEntryContent .= "---\n"; $sampleBlogEntryContent .= " \n"; $sampleBlogEntryContent .= "This Markdown file is a simple example of a blog post for Alloy. It contains some basic Markdown as well as what we call YAML at the top of the file, which will be the nerve center of your posts.\n\n"; $sampleBlogEntryContent .= "Alloy processes standard Markdown, which allows for formatting content using just plain text. You'll notice **that this text is bolded** and that _this text is italicized_. You can also easily [add links to text like so](http://elixirgraphics.com).\n\n"; $sampleBlogEntryContent .= "If you open this file in your text editor you'll see the various tags we've used to format this post as well as the YAML Front Matter section at the top of the file. For more information on formatting your content as well as the required YAML header, be sure to read through the Alloy documentation on creating posts. We also have several video tutorials, on various topics, to get you started with Alloy.\n"; file_put_contents($sampleBlogEntryFile, $sampleBlogEntryContent); $folderMissingAlert = true; } $allAuthors=array(); $categories=array(); $count = 0; $draftCount = 0; $futureCount = 0; $alloyCacheID = ""; $alloyCacheEnabled = false; // Loop through all of our Markdown files so that // we can build our posts array. In the process we'll // weed out the drafts and future posts as well. foreach (scandir($directory) as $file) { if ('.' === $file) continue; if ('..' === $file) continue; $fileExt = pathinfo($file, PATHINFO_EXTENSION); if ($fileExt = "md") { $zipArray[] = $file; } $currentFile = '../posts/' . $file; $fileContents = file_get_contents($currentFile); // Clear the file status cache clearstatcache(); // Get the file's timestamp $rawTime = filemtime($currentFile); $fileTime = date ("H:i", $rawTime); $parts = preg_split('/[\n]*[-]{3}[\n]/', $fileContents, 3); $frontMatter = spyc_load_file($parts[1]); // Parse YAML front matter. $unparsedBody = $parts[2]; $parsedEntry = $Parsedown->text($parts[2]); // Parse Markdown contents to convert to HTML. if (isset($frontMatter['summary'])) { $parsedCustomSummary = $Parsedown->text($frontMatter['summary']); } else { $parsedCustomSummary = ""; } $splitFilename = (explode("_",$file)); $originalDate = $splitFilename[0]; $mergedDateTime = $originalDate . ' ' . $fileTime; $mergedDateTime = date('Y-m-d H:i', strtotime($mergedDateTime)); $todaysDate = date("Y-m-d H:i"); $postID = (explode(".md",$splitFilename[1])); if (strtotime($mergedDateTime) <= strtotime($todaysDate)) { if ($frontMatter['draft'] != true) { $post = [ "postID" => $postID[0], "title" => $frontMatter['title'], "date" => $originalDate, "time" => $fileTime, "rawtime" => $rawTime, "author" => $frontMatter['author'], "category" => $frontMatter['category'], "postTags" => $frontMatter['tags'], "smallLabel" => $frontMatter['small-label'], "body" => $parsedEntry, "unparsedbody" => $unparsedBody, "topperImage" => $frontMatter['topper'], "topperImageAlt" => $frontMatter['topperalt'], "unparsedCustomSummary" => $frontMatter['summary'], "customSummary" => $parsedCustomSummary, "isDraft" => $frontMatter['draft'], ]; $allPosts[] = $post; if (!in_array($frontMatter['author'], $allAuthors)) { // Check to see if we have an author -- if so add it to the authors list. if ($frontMatter['author'] !="") { $allAuthors[] = $frontMatter['author']; } } if (!in_array($frontMatter['category'], $categories)) { // Check to see if we have a category -- if so add it to the categories list. if ($frontMatter['category'] !="") { $categories[] = $frontMatter['category']; } } } elseif ($frontMatter['draft'] == true) { $draftCount = ++$draftCount; $draftPost = [ "postID" => $postID[0], "title" => $frontMatter['title'], "date" => $originalDate, "time" => $fileTime, "rawtime" => $rawTime, "author" => $frontMatter['author'], "category" => $frontMatter['category'], "postTags" => $frontMatter['tags'], "smallLabel" => $frontMatter['small-label'], "body" => $parsedEntry, "unparsedbody" => $unparsedBody, "topperImage" => $frontMatter['topper'], "topperImageAlt" => $frontMatter['topperalt'], "unparsedCustomSummary" => $frontMatter['summary'], "customSummary" => $parsedCustomSummary, "isDraft" => $frontMatter['draft'], ]; $allDraftPosts[] = $draftPost; } } else { $futureCount = ++$futureCount; $futurePost = [ "postID" => $postID[0], "title" => $frontMatter['title'], "date" => $originalDate, "time" => $fileTime, "rawtime" => $rawTime, "author" => $frontMatter['author'], "category" => $frontMatter['category'], "postTags" => $frontMatter['tags'], "smallLabel" => $frontMatter['small-label'], "body" => $parsedEntry, "unparsedbody" => $unparsedBody, "topperImage" => $frontMatter['topper'], "topperImageAlt" => $frontMatter['topperalt'], "unparsedCustomSummary" => $frontMatter['summary'], "customSummary" => $parsedCustomSummary, "isDraft" => $frontMatter['draft'], ]; $allFuturePosts[] = $futurePost; } } $_SESSION['baseURL'] = "https://www.corbystephens.com/"; $_SESSION['zipSessionArray'] = $zipArray; $imagesdirectory = "../"; $_SESSION['imagesDirectory'] = $imagesdirectory; $_SESSION['imagesTargetFolder'] = 'image-uploads/'; $imageUploadsFolderName = "image-uploads"; // Sort the entries array_multisort(array_column($allPosts, 'date'), SORT_DESC, array_column($allPosts, 'time'), SORT_DESC, $allPosts); // Sort the categories sort($categories, SORT_NATURAL | SORT_FLAG_CASE); // Get the current URL and strip off any cruft $baseURL = 'http'; if ($_SERVER["HTTPS"] == "on") { $baseURL .= "s"; } $baseURL .= "://"; $baseURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; $baseURL = (explode("?",$baseURL)); if ($urlID != "") { foreach($allPosts as $basicmeta) { if ($basicmeta['postID'] == $urlID) { if ($basicmeta['customSummary'] != "") { $basicMetaSummary = $basicmeta['customSummary']; } else { $basicMetaSummary = truncateHTML($basicmeta['body'], 160); } $basicMetaSummary = strip_tags($basicMetaSummary); // // Pulls in the existing site title tag that is in the output buffer, // uses preg_replace to swap it out for our blog post's title and // then echos out our buffer, which has the new title tag. // $title = $basicmeta['title']; $buffer = ob_get_clean(); $buffer = preg_replace('/()(.*?)(<\/title>)/i', '<title>' . $title . '', $buffer); echo $buffer; echo ''; if ($basicmeta['author'] != "") { echo ''; } } } } // create canonical meta tag for summaries view if ($urlID == "") { echo ''; } if ($urlID != "") { foreach($allPosts as $apmeta) { if ($apmeta['postID'] == $urlID) { $time = strtotime($apmeta['date']); echo ''; echo ''; if ($apmeta['customSummary'] != "") { $metaSummary = $apmeta['customSummary']; } else { $metaSummary = truncateHTML($apmeta['body'], 280); } $metaSummary = strip_tags($metaSummary); echo ''; echo ''; echo ''; $metaURL = $baseURL[0] . '?id=' . $apmeta['postID']; echo ''; if ($apmeta['topperImage'] != "") { echo ''; } echo ''; echo ''; echo ''; echo ''; if ($apmeta['topperImage'] != "") { echo ''; } // switched canonical URL below from curPageURL() to curFullPageURL() // to have ?id= style URLs include the id in the meta tag. echo ''; } } } ?>

Blog (coming soon)

I want to document and share the things I learn, particularly in the tech world. I've gained so much from others, I want to give back. There might also be a promotional blurb about projects I'm working on. Sign up for the email list below to be notified of new content and hang out in the comments.

Corby Stephens

Voiceover and podcast production. IT and other technical services. Content creation. Jack of all trades, master of some.

Corby's Fun-time Newsblast

Get notified about blog posts, current projects, and stuff I think is fun.

I value your privacy! I use analytics from Plausible whose top priority is privacy. Your newsletter signup, comments registration, and any e-commerce information are managed by their respective platform owners.