From 3fc26dfb7351db0e78647d4b1880d6b9b0552ea0 Mon Sep 17 00:00:00 2001 From: Paul de Raaij Date: Sat, 17 Mar 2012 10:48:16 +0100 Subject: [PATCH 1/4] By default date_default_timezone_set should be uncomment and be set on UTC with the modern PHP releases. --- app/config/core.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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'); /** * From baa53140832d4d7d8aa140814aa66c92c3f2b8d6 Mon Sep 17 00:00:00 2001 From: Paul de Raaij Date: Sat, 17 Mar 2012 10:55:29 +0100 Subject: [PATCH 2/4] 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 + + + + + \ 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 From 02f4d98a5d6ac6e986233a91642f9ba2a684d99a Mon Sep 17 00:00:00 2001 From: Paul de Raaij Date: Wed, 21 Mar 2012 08:13:59 +0100 Subject: [PATCH 3/4] Forgot to commit the added routes --- app/config/routes.php | 4 ++++ 1 file changed, 4 insertions(+) mode change 100644 => 100755 app/config/routes.php 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')); From f5adb9fb2ab2ae4486cea28e9d999b9b48c2273a Mon Sep 17 00:00:00 2001 From: Paul de Raaij Date: Wed, 21 Mar 2012 08:24:06 +0100 Subject: [PATCH 4/4] Use htmlspecialchars for save outputting of title and username so feed doesn't break --- app/views/rss/rss/feeds.ctp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/rss/rss/feeds.ctp b/app/views/rss/rss/feeds.ctp index 7d7e904..4abf02a 100644 --- a/app/views/rss/rss/feeds.ctp +++ b/app/views/rss/rss/feeds.ctp @@ -35,9 +35,9 @@ ?> - <?php echo $question['Post']['title']; ?> + <?php echo htmlspecialchars($question['Post']['title']); ?> - +