public function postStaticServe(StaticServer $server) { $request_time = microtime(true) - COWL_START_TIME; $this->log("static_serve", sprintf("took %01.6f s. %s", $request_time, $server->getPath())); // Logging static file requests is optional since it floods the logs if (Current::$config->get('plugins.logging.log_static_files')) { $this->save(); } }
public function preStaticServe(StaticServer $server) { // If file was a package file, don't do anything if ($this->is_package) { return; } // If the type isn't css we don't touch it if ($server->getType() != 'css') { return; } $path = $server->getPath(); $cache_path = $this->cache . '.' . preg_replace('#\\W#', '', $path); // Compile and cache CSS file. $cache = new FileCache($cache_path, $path); $cache->setExtension('css'); if ($cache->isOutDated() || $this->force_update) { $contents = file_get_contents($path); $compiler = new CSSCompiler($contents); $updated = $compiler->compile(); $cache->update($updated); } // Change the path to be the cached file instead $server->setPath($cache->getFile()); }
public function prePathParse(Controller $controller, StaticServer $server) { $path = strtolower($server->getPath()); $url_path = COWL_BASE . $this->packaged_dir; // Path begins with release path, then we build it if need be if (strncmp($path, $url_path, strlen($url_path)) !== 0) { return; } // Get package name from request path $package = preg_replace('#\\.js$#', '', substr($path, strlen($url_path))); $filepath = $this->buildPackage($package); // No package here if (!$filepath) { return; } $server->setPath($filepath); $controller->setPath($filepath); $server->lockPath(); $this->is_package = true; }