Permalink
Browse files

Abstracted logic to own methods

  • Loading branch information...
1 parent 173a2b6 commit 692c06082d57a92fbe819047291a75dd4179a864 @lukemorton committed Apr 3, 2011
Showing with 29 additions and 3 deletions.
  1. +6 −2 classes/kohana/controller/publicize.php
  2. +23 −1 classes/kohana/publicize.php
@@ -22,15 +22,19 @@ public function action_copy()
{
$asset = $this->request->param('asset');
- if (Kohana::$environment !== Kohana::DEVELOPMENT)
+ if (Publicize::should_copy_to_docroot())
{
$uri = $this->request->param('uri');
// Copy and redirect
Publicize::copy_to_docroot($asset, $uri);
- $this->request->redirect($uri);
+ //$this->request->redirect($uri);
}
+ // Send last modified headers so browsers have a chance
+ $this->response->headers('Last-Modified',
+ date(DATE_RFC1123, filemtime($asset)));
+
// Show live copy
$this->response->send_file($asset);
}
@@ -16,13 +16,35 @@ class Kohana_Publicize {
const PUBLIC_FOLDER = 'public';
/**
+ * Should we copy to docroot? We should if not in the
+ * development environment.
+ *
+ * @return boolean
+ */
+ public static function should_copy_to_docroot()
+ {
+ return Kohana::$environment !== Kohana::DEVELOPMENT;
+ }
+
+ /**
+ * Should we set route? We should if not in the
+ * production environment.
+ *
+ * @return boolean
+ */
+ public static function should_set_route()
+ {
+ return Kohana::$environment !== Kohana::PRODUCTION;
+ }
+
+/**
* Sets route if not in production.
*
* @return void
*/
public static function set_route()
{
- if (Kohana::$environment !== Kohana::PRODUCTION)
+ if (self::should_set_route())
{
self::_set_route();
}

0 comments on commit 692c060

Please sign in to comment.