diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-06-29 08:24:42 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-06-29 08:24:42 -0700 |
commit | 6ec293dfe70665c528d803b78a2bb295633496ec (patch) | |
tree | be3b7f8d7c2e8ba0e11e3432e2891206272efc1a /modules/gallery/controllers/combined.php | |
parent | 10b4eda6f0cbb44fde9fb3158bd174c82467f2ee (diff) |
*Note* work in progress.
Implement the combined css functionality. Local url references and replace with absolute urls instead of relative.
Diffstat (limited to 'modules/gallery/controllers/combined.php')
-rw-r--r-- | modules/gallery/controllers/combined.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php index 510482db..50fe77c4 100644 --- a/modules/gallery/controllers/combined.php +++ b/modules/gallery/controllers/combined.php @@ -58,5 +58,51 @@ class Combined_Controller extends Controller { Kohana::close_buffers(false); print $content; } + + public function css($key) { + if (preg_match('/[^0-9a-f]/', $key)) { + // The key can't contain non-hex, so just terminate early + Kohana::show_404(); + } + + // We don't need to save the session for this request + Session::abort_save(); + + // Our data is immutable, so if they already have a copy then it needs no updating. + if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { + header('HTTP/1.0 304 Not Modified'); + return; + } + + $cache = Cache::instance(); + if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false ) { + $content = $cache->get("{$key}_gz"); + } + + if (empty($content)) { + $content = $cache->get($key); + } + + if (empty($content)) { + Kohana::show_404(); + } + + if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false) { + header("Content-Encoding: gzip"); + header("Cache-Control: public"); + } + + header("Content-Type: text/css; charset=UTF-8"); + header("Expires: Tue, 19 Jan 2038 00:00:00 GMT"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s T", time())); + + Kohana::close_buffers(false); + print $content; + } + + public function __call($function, $args) { + array_unshift($args, $function); + print "<!-- " . implode("/", $args) . " -->"; + } } |