function printNotes($request) { $dir = BASE_PATH . $request; $uri = BASE_URI . $request; $html = '<div id="notes">'; if (is_dir($dir)) { $html .= printDir($request); $html .= "</div>"; return $html; } else { if (substr($request, -1) == '/') { $request = substr($request, 0, strlen($request) - 1); } if (file_exists(BASE_PATH . $request . TEXTENSION)) { $file = substr($request, strrpos($request, '/') + 1, strlen($request)); $dir = substr($request, 0, strrpos($request, '/') + 1); $html .= printPost(BASE_PATH . $dir, $file . TEXTENSION, $uri); $html .= "</div>"; return $html; } } return printErrorText(); }
function parseRequest($request, $category) { global $categoriesRegexp, $dateRegexp, $specialPages, $title; //getFileFromRequest($request); $html = ""; if ($request == '') { $title = "Home"; $html = printSpecialPage($specialPages['home'], BASE_URI); return $html; } foreach ($specialPages as $page => $file) { if ($request == $page || $request == $page . "/") { // last case is for colophon page $title = ucfirst($page); $html = printSpecialPage($file, $request . "/"); return $html; } } if ($category == "notes/") { $html .= printNotes($request); return $html; } if ($category == "projects/") { $html .= printProjects(BASE_PATH . $request, $request, "projects/"); return $html; } if ($category == "blog/") { $html .= printBlogPosts($request); return $html; } //error 404 $html .= printErrorText(); return $html; }