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 @@ -
@@ -55,7 +55,7 @@ foreach($questions as $question) { ?>
- +
link( $tag['tag'], @@ -63,12 +63,12 @@ foreach($questions as $question) { ?> ); ?>
- +
- 3) && $current > 3) { ?> 1    @@ -77,15 +77,23 @@ foreach($questions as $question) { ?>     - + page of - + page of -   Next >> << Previous   - \ No newline at end of file + + + +
+ + recent questions feed + +
+ \ No newline at end of file diff --git a/app/views/rss/rss/feeds.ctp b/app/views/rss/rss/feeds.ctp new file mode 100644 index 0000000..4abf02a --- /dev/null +++ b/app/views/rss/rss/feeds.ctp @@ -0,0 +1,53 @@ +url($this->webroot, true); + $currentDate = new DateTime(); + + $feedLink = $html->url(array( 'controller' => 'rss', + 'action' => 'feeds', 'ext' => 'rss'), true); + + ?> + + Recent Questions + + format(DateTime::ATOM);?> + +url(array( 'controller' => 'posts', + 'action' => 'view', 'public_key' => $question['Post']['public_key'], 'title' => Inflector::slug($question['Post']['title'])), true); + + $userLink = $html->url(array( 'controller' => 'users', + 'action' => 'view', 'public_key' => $question['User']['public_key'], 'title' => Inflector::slug($question['User']['username'])), true); + + $dateCreated = new DateTime(); + $dateCreated->setTimestamp($question['Post']['timestamp']); + + $dateModified = new DateTime(); + + + if( $question['Post']['last_edited_timestamp'] == 0 ) { + $dateModified = $dateCreated; + } else { + $dateModified->setTimestamp($question['Post']['last_edited_timestamp']); + } + + ?> + + + <?php echo htmlspecialchars($question['Post']['title']); ?> + + + + + + format(DateTime::ATOM);?> + format(DateTime::ATOM);?> + + + + + + \ No newline at end of file diff --git a/app/webroot/css/skin.css b/app/webroot/css/skin.css old mode 100644 new mode 100755 index 35dc23b..e1a562a --- a/app/webroot/css/skin.css +++ b/app/webroot/css/skin.css @@ -89,4 +89,20 @@ a:hover { background-color: #d05024; border-bottom: 1px solid #FFECE5; border-right: 1px solid #FFECE5; +} + + +/* -------------------------------------------------------------- + RSS Feed +-------------------------------------------------------------- */ +div.questionFeed { + float: right; + margin-top: 50px; +} + +div.questionFeed a { + color: #666; + background: transparent url(/img/rss.gif) no-repeat; + padding-left: 22px; + height: 18px; } \ No newline at end of file diff --git a/app/webroot/img/rss.gif b/app/webroot/img/rss.gif new file mode 100644 index 0000000..d6f0606 Binary files /dev/null and b/app/webroot/img/rss.gif differ