From baa53140832d4d7d8aa140814aa66c92c3f2b8d6 Mon Sep 17 00:00:00 2001 From: Paul de Raaij Date: Sat, 17 Mar 2012 10:55:29 +0100 Subject: [PATCH] Added simple RSS feed for the latest questions. Misses some configuration options, but will provide after the next release of coordino. --- app/controllers/rss_controller.php | 30 ++++++++++++++++ app/views/layouts/rss/default.ctp | 5 +++ app/views/posts/display.ctp | 24 ++++++++----- app/views/rss/rss/feeds.ctp | 53 +++++++++++++++++++++++++++++ app/webroot/css/skin.css | 16 +++++++++ app/webroot/img/rss.gif | Bin 0 -> 1145 bytes 6 files changed, 120 insertions(+), 8 deletions(-) create mode 100644 app/controllers/rss_controller.php create mode 100644 app/views/layouts/rss/default.ctp mode change 100644 => 100755 app/views/posts/display.ctp create mode 100644 app/views/rss/rss/feeds.ctp mode change 100644 => 100755 app/webroot/css/skin.css create mode 100644 app/webroot/img/rss.gif 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 0000000000000000000000000000000000000000..d6f0606efedc6bec24a2981061041f35e5335199 GIT binary patch literal 1145 zcmV-<1cv)ZNk%w1VG;lm0QUd@`JzVophEbYJot(${r~^?oj>-8DfyT+_mMaHqC@$e zJ@|_(`2YX-m^k)^CH=f`{{R2?qhR#>|NEsy`H?j1zM1NjQR|gb{o&2|mO$NtOy!MG z;_UP5hCK0*JNcYE@tsujo>cakL*wl9@QgO~nLYTKIrieu`j$ZPta<&sap~F3_l6+w zt#tW}FZhlu=eU*lqFVX>|KYBZ_mev1ghKX`JMhGw_JJMtf*$pZFZ|=m_nJiSsdn^} zKK=Ri`_;Jn+{5>eEY_oo^YioNxt`;?n&*&C{_WuSizoV|M)iv;^^`sLmp%8IO!=5N z;>We^hd1h-UG|ke`sdW+u8#PaMCiw_`MiznhdAnnKJl%2>xMezrhodII@O(m`INJp0tP`L}lYlRWa0JN(O___&Aon@aYY zNBgTz_m(#Q{QCEiG3cLU`IIvAmQDAHEcE^V`He8`nNcg@Ai!`?uRw{qe9+$HjY zlRWp6JNA=1{N>g7lQsE^F8P!+>5@+Pl{5ILVdc=l=*P6|mQD7OIOB~{`JX`WqF?Zs zPVAdm`v3py?C$)(eemSm+lEs7yKwe}BjScj`Jg}Z%BJCqQvJYp^M@zp+}Gpa;QidZ z`H?mFuXgyLLFBQD_lP3-mNfk0&HL}^_=+w0kTm$;%K3^c|M%|y{{HurGWU%u@bUBc zl{f3^>-U&E_LxQTlRfy0DE+>3_L)25)y(;`c>4YR`JO-T-qHD%H~rtj`J+SgiZ1b& zMfQs-Hgx#@`oz^_wn(VN8jDw`HeC9qCxJog!`;i=Z;YR^zZkQI`)by z=%#S$nO*mkJpJ_U@ALTXh&1;8|M`L zqQ!fyX0e%JYL2cF&rwOV#!uW8|q0 zfg5qc5r`!zlcNsKt$S1Gn-v4M{7_+bjo1zy!DQ9I zg~Ne5JvlglKqZzKfPgzRxRL=YW#rL@3j=5p2{{W4Fbp3R0)qk>LyR+qBKd?U;)waY LqQMs&1Oxy(+uNK? literal 0 HcmV?d00001