$page, 'posts' => $posts, 'has_pagination' => has_pagination($page) ), false, false); } else render('home'); }); // The changelog. get('/changes', function () { if(!PROJECTVALID) not_found(); $page = from($_GET, 'page'); $page = $page ? (int)$page : 1; $updates = get_updates($page); if(!is_enabled("enablechanges") || empty($updates) || $page < 1){ // a non-existing page not_found(); } render('changes', array( 'title' => 'Changes - ' . project_config("title"), 'description' => 'Historical changelog of ' . project_config("title"), 'page' => $page, 'updates' => $updates, 'has_pagination' => has_pagination_updates($page) )); }); // The front page of the blog. get('/blog', function () { if(!PROJECTVALID) not_found(); $page = from($_GET, 'page'); $page = $page ? (int)$page : 1; $posts = get_posts($page); if(!is_enabled("enableblog") || empty($posts) || $page < 1){ // a non-existing page not_found(); } render('blog',array( 'title' => 'Blog - ' . project_config("title"), 'page' => $page, 'posts' => $posts, 'has_pagination' => has_pagination($page) )); }); // The blog post page get('/blog/:name',function($name){ if(!PROJECTVALID) not_found(); $post = find_post($name); if(!is_enabled("enableblog") || !$post){ not_found(); } render('post',array( 'title' => $post->title . ' - ' . project_config("title"), 'description' => $post->description, 'header' => $post->header, 'p' => $post )); }); // The JSON API get('/blog/api/json',function() { if(!PROJECTVALID) not_found(); header('Content-type: application/json'); // Print the 10 latest posts as JSON echo generate_json(get_posts(1, 10)); }); // Show the RSS feed get('/blog/rss',function() { if(!PROJECTVALID) not_found(); header('Content-Type: application/rss+xml'); // Show an RSS feed with the 30 latest posts echo generate_rss(get_posts(1, 30)); }); // If we get here, it means that // nothing has been matched above get('.*',function(){ // handle old blog redirects if(PROJECTID == "blog") { switch ($_SERVER['REQUEST_URI']) { case "/oyster-a-post-release-post-mortem": redirect_to('https://oyster.solwllms.com/blog/a-post-release-post-mortem'); break; } } not_found(); }); // Serve the page dispatch();