From bce1fc1804d2b6169a0921cdc45539ee1e6a1e23 Mon Sep 17 00:00:00 2001 From: KrisJordan Date: Thu, 13 Nov 2008 01:08:11 -0500 Subject: [PATCH] Library optimizations looking good. --- apps/blog/controllers/PostsController.class.php | 10 ++++++++++ apps/blog/views/home/comments.php | 2 +- lib/recess/framework/controllers/Controller.class.php | 5 +++++ lib/recess/http/Response.class.php | 2 -- lib/recess/http/responses/ForbiddenResponse.class.php | 1 - .../http/responses/ForwardingOkResponse.class.php | 10 ++++++++++ public/recess-config.php | 8 +++++--- 7 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 lib/recess/http/responses/ForwardingOkResponse.class.php diff --git a/apps/blog/controllers/PostsController.class.php b/apps/blog/controllers/PostsController.class.php index 09c8990..e022c00 100644 --- a/apps/blog/controllers/PostsController.class.php +++ b/apps/blog/controllers/PostsController.class.php @@ -42,6 +42,16 @@ function newComment($postId) { } + /** !Route GET, comment/$commentId/delete/ */ + function deleteComment($commentId) { + $comment = new Comment(); + $comment->id = $commentId; + $post = $comment->post(); + $comment->delete(); + Library::import('recess.http.ForwardingResponse'); + return $this->forwardOk('/blog/comments/' . $post->id); + } + } ?> \ No newline at end of file diff --git a/apps/blog/views/home/comments.php b/apps/blog/views/home/comments.php index e4f818b..14d9afb 100644 --- a/apps/blog/views/home/comments.php +++ b/apps/blog/views/home/comments.php @@ -12,7 +12,7 @@ foreach($comments as $comment) { - echo '

' . $comment->comment . '

'; + echo '

X ' . $comment->comment . '

'; echo '
'; diff --git a/lib/recess/framework/controllers/Controller.class.php b/lib/recess/framework/controllers/Controller.class.php index 823236c..f96e413 100644 --- a/lib/recess/framework/controllers/Controller.class.php +++ b/lib/recess/framework/controllers/Controller.class.php @@ -152,6 +152,11 @@ protected function ok($viewName = null) { return $response; } + protected function forwardOk($forwardedUri) { + Library::import('recess.http.responses.ForwardingOkResponse'); + return new ForwardingOkResponse($this->request, $forwardedUri); + } + protected function created($resourceUri, $contentUri = '') { Library::import('recess.http.responses.CreatedResponse'); if($contentUri == '') $contentUri = $resourceUri; diff --git a/lib/recess/http/Response.class.php b/lib/recess/http/Response.class.php index cd4f9b7..3c0284f 100644 --- a/lib/recess/http/Response.class.php +++ b/lib/recess/http/Response.class.php @@ -1,5 +1,4 @@ headers[] = $header; } } - ?> \ No newline at end of file diff --git a/lib/recess/http/responses/ForbiddenResponse.class.php b/lib/recess/http/responses/ForbiddenResponse.class.php index 66126f7..1bc61b2 100644 --- a/lib/recess/http/responses/ForbiddenResponse.class.php +++ b/lib/recess/http/responses/ForbiddenResponse.class.php @@ -1,5 +1,4 @@ \ No newline at end of file diff --git a/public/recess-config.php b/public/recess-config.php index 2e789fa..26efb25 100644 --- a/public/recess-config.php +++ b/public/recess-config.php @@ -4,7 +4,7 @@ Config::$mode = Config::DEVELOPMENT; -Config::$useTurboSpeed = true; // Do you want to go fast? +Config::$useTurboSpeed = false; // I wanna go FAST! Config::$cacheProviders = array( 'Apc', @@ -13,8 +13,8 @@ ); Config::$applications - = array( // 'frontend.FrontEndApplication', - // 'backend.BackEndApplication', + = array( 'frontend.FrontEndApplication', + 'backend.BackEndApplication', 'recess.apps.ide.RecessIdeApplication', 'blog.BlogApplication' ); @@ -71,6 +71,7 @@ static function init() { $provider = $provider . 'CacheProvider'; Cache::reportsTo(new $provider); } + Cache::clear(); } if(isset(self::$settings['dir.temp'])) { @@ -97,6 +98,7 @@ static function init() { Library::addClassPath(self::$settings['dir.apps']); // TODO: GET RID OF THIS + Library::import('recess.framework.Application'); self::$applications = array_map(create_function('$class','return Library::importAndInstantiate($class);'),Config::$applications); Library::import('recess.sources.db.DbSources');