/** * Handle short URLs * * @param string $uniqueID * @route b/(.*) */ public function shortURL(string $uniqueID = '') { if (empty($uniqueID)) { \Airship\redirect($this->airship_cabin_prefix . '/blog'); } $long = $this->blog->longURL($uniqueID); \Airship\redirect($this->airship_cabin_prefix . '/blog' . $long); }
/** * @param CacheInterface $cache * @param string $uniqueID */ protected function fetchComments(CacheInterface $cache, string $uniqueID) { $blog = $this->blog->getBlogPostByUniqueId($uniqueID); $comments = $this->blog->getCommentTree((int) $blog['postid']); $contents = $this->lensRender('blog/comments', ['blogpost' => $blog, 'comments' => $comments, 'config' => $this->config()]); $cache->set($uniqueID, ['status' => 'OK', 'cached' => $contents]); \Airship\json_response(['status' => 'OK', 'cached' => $contents]); }
/** * The homepage for an Airship. * * @route / */ public function index() { $this->blog = $this->blueprint('Blog'); if (!\file_exists(ROOT . '/public/robots.txt')) { // Default robots.txt \file_put_contents(ROOT . '/public/robots.txt', "User-agent: *\nAllow: /"); } $blogRoll = $this->blog->recentFullPosts((int) ($this->config('homepage.blog-posts') ?? 5)); $mathJAX = false; foreach ($blogRoll as $i => $blog) { $blogRoll[$i] = $this->blog->getSnippet($blog); if (Binary::safeStrlen($blogRoll[$i]['snippet']) !== Binary::safeStrlen($blog['body'])) { $blogRoll[$i]['snippet'] = \rtrim($blogRoll[$i]['snippet'], "\n"); } $mathJAX |= \strpos($blog['body'], '$$') !== false; } $args = ['blogposts' => $blogRoll]; $this->config('blog.cachelists') ? $this->stasis('index', $args) : $this->lens('index', $args); }