public function createComponentCss() { // připravíme seznam souborů // FileCollection v konstruktoru může dostat výchozí adresář, pak není potřeba psát absolutní cesty $files = new \WebLoader\FileCollection(WWW_DIR . '/css'); // kompilátoru seznam předáme a určíme adresář, kam má kompilovat $compiler = \WebLoader\Compiler::createCssCompiler($files, WWW_DIR . '/webtemp'); // nette komponenta pro výpis <link>ů přijímá kompilátor a cestu k adresáři na webu return new \WebLoader\Nette\CssLoader($compiler, $this->template->basePath . '/webtemp'); }
/** * Creates a CSS loader component. */ public function createComponentCss() { // prepare files list // FileCollection constructor accepts default resources directory $files = new \WebLoader\FileCollection(WWW_DIR . '/css'); $files->addFiles(array('screen.css', 'bootstrap-3.0.0/less/bootstrap.less', 'bootstrap-3.0.0/less/variables.less', 'jqplot/dist/jquery.jqplot.min.css', 'jqplot.css')); // pass the files collection to the compiler and set output path $compiler = \WebLoader\Compiler::createCssCompiler($files, WWW_DIR . '/webtemp'); // add LESS filter to the compiler $compiler->addFileFilter(new \Webloader\Filter\LessFilter()); // add CSSMin filter to the compiler $compiler->addFilter(function ($code) { return \cssmin::minify($code); }); // nette komponenta pro výpis <link>ů přijímá kompilátor a cestu k adresáři na webu return new \WebLoader\Nette\CssLoader($compiler, $this->template->basePath . '/webtemp'); }
/** * @param array $fileNames * @param string|FALSE $media * @param string $stylesDir */ private function lessComponentWrapper(array $fileNames, $media = NULL, $stylesDir = NULL) { if ($media === NULL) { $media = 'screen,projection,tv'; } if ($stylesDir === NULL) { $stylesDir = __DIR__ . '/../styles'; } $outputDirName = '/tmp/css'; $fileCollection = new WebLoader\FileCollection($stylesDir); $fileCollection->addFiles($fileNames); $name = strtolower(substr($this->name, strrpos($this->name, ':') + 1)) . '.css'; if (file_exists($stylesDir . '/' . $name)) { $files->addFile($name); } $compiler = WebLoader\Compiler::createCssCompiler($fileCollection, $this->context->parameters['wwwDir'] . $outputDirName); $filter = new WebLoader\Filter\LessFilter(); $compiler->addFileFilter($filter); $control = new WebLoader\Nette\CssLoader($compiler, $this->template->basePath . $outputDirName); if (is_string($media)) { $control->setMedia($media); } return $control; }
public function createComponentCss($cssFiles = NULL) { // if no given files $cssFiles = gettype($cssFiles) == 'array' ? $cssFiles : $this->cssFiles; // připravíme seznam souborů // FileCollection v konstruktoru může dostat výchozí adresář, pak není potřeba psát absolutní cesty //$files = new \WebLoader\FileCollection(WWW_DIR . '/css'); $files = new \WebLoader\FileCollection(APP_DIR . '/templates/less'); $files->addFiles($cssFiles); // kompilátoru seznam předáme a určíme adresář, kam má kompilovat $compiler = \WebLoader\Compiler::createCssCompiler($files, WWW_DIR . '/webtemp'); // because it has problem with cooperating... // there must be changed delimiter // and the filter also require something to initialize with $compiler->addFileFilter(new \Webloader\Filter\LessFilter()); // nette komponenta pro výpis <link>ů přijímá kompilátor a cestu k adresáři na webu $css = new \WebLoader\Nette\CssLoader($compiler, $this->template->basePath . '/webtemp'); $css->setMedia('screen'); return $css; }
public function createCssLoader() { $fileCollection = $this->createFileCollection(array_filter($this->files, [$this, 'isCss'])); $compiler = Compiler::createCssCompiler($fileCollection, $this->wwwDir . '/' . $this->outputDir); return new CssLoader($compiler, $this->httpRequest->url->basePath . $this->outputDir); }