<?php

class Blog_IndexController extends Fiktiv_Controller_Action
{
    public function indexAction()
    {
        $this->_forward('latest');
    }

    public function latestAction()
    {
        // Fetch last ten posts
        $posts = new ModelBlogPost();
        $this->view->posts = $posts->fetchAll(null, 'pubDate DESC', 10);
    }

    public function readableAction()
    {
        
    }

    public function readAction()
    {
        $posts = new ModelBlogPost();

        $this->view->post = $posts->findByPermlink($this->_getParam('id', null));
        
        if (!$this->view->post)
            $this->_redirect(array('action' => 'latest'));

        
    }
}
