Exemplo n.º 1
0
 public function setUp()
 {
     vfsStream::setup('public');
     mkdir(vfsStream::url('public/js'));
     parent::setUp();
     AssetsLoader::appendSourceDir('tests/files/assets');
     AssetsLoader::setDestinationDir(vfsStream::url('public'));
 }
Exemplo n.º 2
0
 public function testAssetLoading()
 {
     vfsStream::setup('public');
     AssetsLoader::appendSourceDir('tests/files/assets');
     AssetsLoader::setDestinationDir(vfsStream::url('public'));
     touch(vfsStream::url('public/existing.css'));
     $output = TemplateEngine::render('assets.tpl.php', array());
     $this->assertEquals("vfs://public/some.css\nvfs://public/another.css\nvfs://public/existing.css", $output);
     $this->assertFileExists(vfsStream::url('public/some.css'));
     $this->assertFileExists(vfsStream::url('public/another.css'));
 }
Exemplo n.º 3
0
Arquivo: Wyf.php Projeto: ntentan/wyf
 public static function init($parameters = [])
 {
     Router::mapRoute('wyf_auth', 'auth/{action}', ['default' => ['controller' => controllers\AuthController::class]]);
     Router::mapRoute('wyf_api', 'api/{*path}', ['default' => ['controller' => controllers\ApiController::class, 'action' => 'rest']]);
     Router::mapRoute('wyf_main', function ($route) {
         $routeArray = explode('/', $route);
         $routeDetails = self::getController($routeArray, realpath(__DIR__ . '/../../../../src/app/'), \ntentan\Ntentan::getNamespace() . '\\app');
         return $routeDetails;
     }, ['default' => ['action' => 'index']]);
     TemplateEngine::appendPath(realpath(__DIR__ . '/../views/layouts'));
     TemplateEngine::appendPath(realpath(__DIR__ . '/../views'));
     AssetsLoader::appendSourceDir(realpath(__DIR__ . '/../assets'));
     View::set('wyf_app_name', $parameters['short_name']);
     InjectionContainer::bind(ModelClassResolver::class)->to(ClassNameResolver::class);
     InjectionContainer::bind(ControllerClassResolver::class)->to(ClassNameResolver::class);
 }
Exemplo n.º 4
0
 public function __toString()
 {
     $minifiedScript = '';
     $tags = '';
     $filename = "/" . $this->getExtension() . "/combined_{$this->context}." . $this->getExtension();
     if ($this->combine === true) {
         foreach ($this->minifiableScripts as $script) {
             $minifiedScript .= file_get_contents($script);
         }
         file_put_contents(AssetsLoader::getDestinationDir() . $filename, Minifier::minify($minifiedScript, $this->getMinifier()));
         $tags = $this->getTag(AssetsLoader::getSiteUrl() . $filename);
     } else {
         if ($this->combine == false) {
             $tags .= $this->writeTags($this->minifiableScripts);
         }
     }
     $tags .= $this->writeTags($this->otherScripts);
     $this->minifiableScripts = array();
     $this->otherScripts = array();
     return $tags;
 }
Exemplo n.º 5
0
 public static function run()
 {
     Session::start();
     honam\TemplateEngine::prependPath('views/shared');
     honam\TemplateEngine::prependPath('views/layouts');
     honam\AssetsLoader::setSiteUrl(Url::path('public'));
     honam\AssetsLoader::appendSourceDir('assets');
     honam\AssetsLoader::setDestinationDir('public');
     honam\Helper::setBaseUrl(Url::path(''));
     self::getRouter()->execute(substr(utils\Input::server('REQUEST_URI'), 1));
 }
Exemplo n.º 6
0
function get_asset($asset)
{
    return AssetsLoader::getAssetPath($asset);
}