public function prePathParse(Controller $controller, StaticServer $server) { try { $this->path = $controller->getPath(); // Transform routes base on host preferences $host_routes = Current::$config->get('plugins.routing.host_routes'); if (count($host_routes)) { $host = $_SERVER['HTTP_HOST']; foreach ($host_routes as $search => $replace) { if (preg_match($search, $host)) { $this->applyTransform($replace); } } } // Transform normal routes $routes = Current::$config->get('plugins.routing.routes'); if (count($routes)) { $this->applyTransform($routes); } $controller->setPath($this->path); $server->setPath($this->path); } catch (RegistryException $e) { } }
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; }