Converts a given asset file into a CSS or JS file.
@param string $asset the asset file path, relative to $basePath
@param string $basePath the directory the $asset is relative to.
@return string the converted asset file path, relative to $basePath.
486315
public function convert($asset, $basePath)
    {
        $pos = strrpos($asset, '.');
        if ($pos !== false) {
            $srcExt = substr($asset, $pos + 1);
            if (isset($this->commands[$srcExt])) {
                [$ext, $command] = $this->commands[$srcExt];
                $result = substr($asset, 0, $pos + 1) . $ext;
                if ($this->forceConvert || $this->isOutdated($basePath, $asset, $result, $srcExt, $ext)) {
                    $this->runCommand($command, $basePath, $asset, $result);
                }

                return $result;
            }
        }

        return $asset;
    }
1105019
public function getUrlFromPath($assetPath)
    {
        // Ensure platform independency
        $path = str_replace('\\', '/', $assetPath);

        $filePath = pathinfo($path);

        $fileType = array_key_exists(strtolower($filePath['extension']), config('nodes.assets.providers.publicFolder.imageExtensionMimeTypes')) ? 'images' : 'data';

        // If the asset is type 'data', show the raw file. If it's 'image' we want to use the CDN
        if ($fileType == 'data') {
            return  $this->getUrlProtocol().config('nodes.assets.providers.publicFolder.domain').'/'.config('nodes.assets.providers.publicFolder.subFolder').'/'.$path;
        } else {
            $fileParts = explode('/', $path);

            return route('nodes.assets.public_folder.cdn', $fileParts);
        }
    }
670426
public function assetPath($path = null)
    {
        return ! is_null($path) ? $this->assetDir().'/'.ltrim($path, '/') : $this->assetDir();
    }
508447
public static function css($fileName, $base_path = true)
    {
        if (!is_array($fileName))
            $fileName = array($fileName);
        $data = null;
        foreach ($fileName as $file)
        {
            $url = "";
            $url .= ($base_path) ? self::getCSSLink() : '';
            $url .= $file;
            $data .= '<link rel="stylesheet" type="text/css" href="' . $url . '"/>' . PHP_EOL;
        }
        
        return $data;
    }
980268
public function getAssetFile($file) {
        if (is_file($file)) {
            return new AssetFile($file);
        }
        $ext = pathinfo($file, PATHINFO_EXTENSION);
        if (strpos($file, '@') === 0 && ($ext == 'js' || $ext == 'css')) {
            $file = $ext.'/'. substr($file, 1);
        }
        return new AssetFile(Factory::public_path()->file($this->assetsDirectory.$file));
    }
111982
public function getJavascriptRenderer($baseUrl = null, $basePath = null)
    {
        if ($this->jsRenderer === null) {
            $this->jsRenderer = new JsRender($this, $baseUrl, $basePath);
            $this->jsRenderer->setUrlGenerator($this->di['url']);
        }
        return $this->jsRenderer;
    }
810256
public function getAsset($asset, $extensionId = null)
    {
        if( ! is_null($extensionId)){
            $url = $this->getJsBaseWww($extensionId) . FsUtils::normalizePath($asset);
        } else {
            $url = $this->getAssetBaseUrl() . FsUtils::normalizePath($asset);
        }

        $isFolder = (substr_compare($url, '/', strlen($url) - 1) === 0);

        $buster = $this->getCacheBuster();
        if($buster != false && $isFolder == false) {
            $url .= '?' . self::BUSTER_QUERY_KEY . '=' . urlencode($buster);
        }

        return $url;
    }
1113047
protected function resolveAssetPath()
    {
        $basename = md5(serialize(array_map(function ($path) {
            return [$path, filemtime($path)];
        }, $this->paths)));

        return Configure::read('Assets.target') . DS . $basename . '.' . $this->type;
    }
194581
public function filterDump(AssetInterface $asset)
    {
        $commandline = $this->nodeBin
            ? array($this->nodeBin, $this->uglifyjsBin)
            : array($this->uglifyjsBin);

        if ($this->noCopyright) {
            array_push($commandline, '--no-copyright');
        }

        if ($this->beautify) {
            array_push($commandline, '--beautify');
        }

        if ($this->unsafe) {
            array_push($commandline, '--unsafe');
        }

        if (false === $this->mangle) {
            array_push($commandline, '--no-mangle');
        }

        if ($this->defines) {
            foreach ($this->defines as $define) {
                array_push($commandline, '-d', $define);
            }
        }

        // input and output files
        $input = FilesystemUtils::createTemporaryFile('uglifyjs_in');
        $output = FilesystemUtils::createTemporaryFile('uglifyjs_out');

        file_put_contents($input, $asset->getContent());
        array_push($commandline, '-o', $output, $input);

        $proc = new Process(implode(' ', $commandline));
        $code = $proc->run();
        unlink($input);

        if (0 !== $code) {
            if (file_exists($output)) {
                unlink($output);
            }

            if (127 === $code) {
                throw new \RuntimeException('Path to node executable could not be resolved.');
            }

            throw FilterException::fromProcess($proc)->setInput($asset->getContent());
        }

        if (!file_exists($output)) {
            throw new \RuntimeException('Error creating output file.');
        }

        $uglifiedJs = file_get_contents($output);
        unlink($output);

        $asset->setContent($uglifiedJs);
    }
1211932
public function getJavascriptRenderer($baseUrl = null, $basePath = null)
    {
        if ($this->jsRenderer === null) {
            $this->jsRenderer = new JavascriptRenderer($this, $baseUrl, $basePath);
        }
        return $this->jsRenderer;
    }
1144739
public function renderGroup($assets) {
		$out = array();
		if ($this->f3->get('ASSETS.trim_public_root')) {
			$basePath=$this->f3->fixslashes(realpath($this->f3->fixslashes(
				$_SERVER['DOCUMENT_ROOT'].$this->f3->get('BASE'))));
			$cDir=$this->f3->fixslashes(getcwd());
			$trimPublicDir=str_replace($cDir,'',$basePath);
		}
		foreach($assets as $asset_type=>$collection) {
			if ($this->f3->exists('ASSETS.filter.'.$asset_type,$filters)) {
				if (is_string($filters))
					$filters = $this->f3->split($filters);
				$flist=array_flip($filters);
				$filters = array_values(array_intersect_key(array_replace($flist, $this->filter), $flist));
				$collection = $this->f3->relay($filters,array($collection));
			}
			foreach($collection as $asset) {
				if (isset($asset['path'])) {
					$path = $asset['path'];
					$mtime = ($this->f3->get('ASSETS.timestamps') && $asset['origin']!='external'
						&& is_file($path)) ? '?'.filemtime($path) : '';
					$base = ($this->f3->get('ASSETS.prepend_base') && $asset['origin']!='external'
						&& is_file($path)) ? $this->f3->get('BASE').'/': '';
					if (isset($trimPublicDir) && $asset['origin']!='external')
						$path = substr($path,strlen($trimPublicDir));
					$asset['path'] = $base.$path.$mtime;
				}
				$out[]=$this->f3->call($this->formatter[$asset_type],array($asset));
			}
		}
		return "\n\t".implode("\n\t",$out)."\n";
	}
839513
protected function getAssetScheme($asset)
    {
        if (starts_with($asset, ['//', 'http://', 'https://'])) {
            return $asset;
        }

        if (substr($asset, 0, 1) == '/') {
            $asset = Url::asset($asset);
        }

        return $asset;
    }
928825
public function includeJavascripts($media, $basePath = '')
    {
        $html = '';
        foreach ($this->assets['js'] as $javascript) {
            $html .= "\n".sprintf('<script src="%s%s" type="text/javascript"></script>', $basePath, $javascript);
        }

        return $html;
    }
283165
def construct_asset_path(self, asset_path, css_path, output_filename, variant=None):
        """"""
        public_path = self.absolute_path(asset_path, os.path.dirname(css_path).replace('\\', '/'))
        if self.embeddable(public_path, variant):
            return "__EMBED__%s" % public_path
        if not posixpath.isabs(asset_path):
            asset_path = self.relative_path(public_path, output_filename)
        return asset_path
1279204
protected function parseAssetDefinition($asset)
    {
        if (starts_with($asset, 'http://')) {
            return new HttpAsset($asset);
        } elseif (str_contains($asset, array('*', '?'))) {
            return new GlobAsset($this->absolutePath($asset));
        } else {
            return new FileAsset($this->absolutePath($asset));
        }
    }
762100
public function addAssets($cssFiles, $jsFiles, $basePath = null, $baseUrl = null)
    {
        $this->additionalAssets[] = array(
            'base_path' => $basePath,
            'base_url' => $baseUrl,
            'css' => (array) $cssFiles,
            'js' => (array) $jsFiles
        );
        return $this;
    }
85535
public function prepend($asset)
	{
		// More than one asset
		if(is_array($asset))
		{
			foreach(array_reverse($asset) as $a)
				$this->prepend($a);
		}

		// Collection
		elseif(isset($this->collections[$asset]))
			$this->prepend($this->collections[$asset]);

		// JavaScript asset
		elseif(preg_match($this->js_regex, $asset))
			$this->prependJs($asset);

		// CSS asset
		elseif(preg_match($this->css_regex, $asset))
			$this->prependCss($asset);

		return $this;
	}