diff --git a/app/config/core.php b/app/config/core.php index c996d45..0832260 100755 --- a/app/config/core.php +++ b/app/config/core.php @@ -245,7 +245,7 @@ * If you are on PHP 5.3 uncomment this line and correct your server timezone * to fix the date & time related errors. */ - //date_default_timezone_set('UTC'); + date_default_timezone_set('UTC'); /** * diff --git a/app/config/routes.php b/app/config/routes.php old mode 100644 new mode 100755 index 6fec35b..44a0c72 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -47,6 +47,8 @@ Router::connect('/about', array('controller' => 'pages', 'action' => 'display', 'about')); Router::connect('/help', array('controller' => 'pages', 'action' => 'display', 'help')); Router::connect('/bugs', array('controller'=> 'bugs', 'action' => 'add')); + + Router::connect('/feeds', array('controller' => 'rss', 'action' => 'feeds')); Router::connect('/tags', array('controller' => 'tags', 'action' => 'tag_list')); Router::connect('/tags/:page', array('controller' => 'tags', 'action' => 'tag_list'), array('pass' => array('page'), 'page' => '[0-9-]+')); @@ -100,6 +102,8 @@ Router::connect('/logout', array('controller' => 'users', 'action' => 'logout')); Router::connect('/tags/suggest.js', array('controller' => 'tags', 'action' => 'suggest')); + + Router::parseExtensions('rss'); } else { Router::connect('/', array('controller' => 'installer', 'action' => 'start')); Router::connect('/install/license', array('controller' => 'installer', 'action' => 'license')); diff --git a/app/controllers/rss_controller.php b/app/controllers/rss_controller.php new file mode 100644 index 0000000..d71a9ed --- /dev/null +++ b/app/controllers/rss_controller.php @@ -0,0 +1,30 @@ + + */ +class RssController extends AppController { + var $name = 'Rss'; + var $uses = array('Post', 'User'); + + var $components = array('RequestHandler'); + var $helpers = array('Text'); + + /** + * By default return an rss feed with the latest 15 questions + */ + public function feeds() { + + if( !$this->RequestHandler->isRss() ) { + $this->redirect('/'); + } + $questions = $this->Post->find('all', array('conditions' => array('Post.type' => 'question',), + 'order' => 'Post.timestamp DESC', + 'limit' => 15)); + + return $this->set(compact('questions')); + } +} + +?> diff --git a/app/views/layouts/rss/default.ctp b/app/views/layouts/rss/default.ctp new file mode 100644 index 0000000..bbb02e0 --- /dev/null +++ b/app/views/layouts/rss/default.ctp @@ -0,0 +1,5 @@ +header(); + +echo $content_for_layout; +?> \ No newline at end of file diff --git a/app/views/posts/display.ctp b/app/views/posts/display.ctp old mode 100644 new mode 100755 index 81c43e7..bd6cef1 --- a/app/views/posts/display.ctp +++ b/app/views/posts/display.ctp @@ -1,4 +1,4 @@ - +