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..7d7e904 --- /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 $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