示例#1
0
<?php

$path = array_shift($params);
if (!$path) {
    error("\n  Missing model path\n");
} elseif (is_file($path)) {
    hydrate_model($path);
} else {
    $mod_path = path(APP_PATH, $path);
    if (!is_dir($mod_path)) {
        error("\n  Model path '{$path}' does not exists\n");
    } else {
        $crawl = function ($file) {
            hydrate_model($file);
        };
        if (arg('R recursive')) {
            \IO\Dir::each($mod_path, '*.php', $crawl);
        } else {
            \IO\Dir::open($mod_path, $crawl);
        }
    }
}
示例#2
0
<?php

create_dir($target_dir);
$out = array();
$tmp_dir = path(dirname(__DIR__), 'assets');
$base_dir = path($tmp_dir, 'static');
\IO\Dir::each($base_dir, '*', function ($file) use($target_dir, $base_dir) {
    $new = str_replace($base_dir . DIRECTORY_SEPARATOR, '', $file);
    $out = path($target_dir, $new);
    if (!is_dir($file)) {
        $path = dirname($out);
        if (!is_dir($path)) {
            status('create', $path);
            mkdir($path, 0755, TRUE);
        }
        status('copy', $out);
        copy($file, $out);
    }
});
copy_file(path($target_dir, 'assets', 'css'), path($tmp_dir, 'sauce.less'));
copy_file(path($target_dir, 'assets', 'css'), path($tmp_dir, 'base.less'));
copy_file(path($target_dir, 'assets', 'css'), path($tmp_dir, 'media.less'));
copy_file(path($target_dir, 'assets', 'css'), path($tmp_dir, 'styles.css.less'));
copy_file(path($target_dir, 'assets', 'js', 'lib'), path($tmp_dir, 'console.js'));
copy_file(path($target_dir, 'assets', 'js', 'lib'), path($tmp_dir, 'jquery.min.js'));
copy_file(path($target_dir, 'assets', 'js', 'lib'), path($tmp_dir, 'modernizr.min.js'));
copy_file(path($target_dir, 'assets', 'js'), path($tmp_dir, 'script.js.coffee'));
$name = camelcase(basename($target_dir));
create_file(path($target_dir, '.gitignore'), ".cache\nstatic/*");
create_file(path($target_dir, 'config.php'), '<' . "?php\n\n\$config['title'] = '{$name}';\n\$config['base_url'] = '';\n");
示例#3
0
             } else {
                 !is_dir(dirname($file_path)) && mkdir(dirname($file_path), 0777, TRUE);
                 !is_file($file_path) && copy($file, $file_path);
             }
             \Sauce\App\Assets::assign($path = str_replace(path($base_path, $on) . DIRECTORY_SEPARATOR, '', $file), $file_hash);
             status('hashing', "{$path} [{$file_hash}]");
         }
     };
 };
 $test = array('f fonts all' => 'font *.{woff,eot,ttf,svg}', 'i images all' => 'img *.{jpeg,jpg,png,gif}');
 // fonts + images
 foreach ($test as $flags => $set) {
     @(list($path, $filter) = explode(' ', $set));
     $dir = path($base_path, $path);
     if (arg($flags) && is_dir($dir)) {
         \IO\Dir::each($dir, $filter, $handler($path));
     }
 }
 // scripts & styles
 foreach (array('css' => 'c styles all', 'js' => 'j scripts all') as $type => $option) {
     if (arg($option) && is_dir(path($base_path, $type))) {
         \IO\Dir::open(path($base_path, $type), function ($file) use($base_path, $static_dir, $type, $cache_dir, $cache) {
             if (is_file($file)) {
                 $out = array();
                 $tmp = \Sauce\App\Assets::parse($file);
                 $test = array();
                 isset($tmp['head']) && ($test = array_merge($test, $tmp['head']));
                 isset($tmp['require']) && ($test = array_merge($test, $tmp['require']));
                 // required scripts, stand-alone
                 if ($test) {
                     foreach ($test as $old) {
示例#4
0
 \IO\Dir::each($from, '*', function ($file) use(&$cache, $source_dir, $assets_dir, $output_dir) {
     $key = md5_file($file);
     $key .= filemtime($file);
     if (in_array($key, $cache)) {
         return;
     }
     $cache[] = $key;
     $path = trim(dirname(str_replace(array($source_dir, $assets_dir), '', $file)), '.\\/');
     if (preg_match('/\\.((?:ht|x)ml|rss|txt|php|css|js)(?:\\.\\w+)*?$/', $file, $match)) {
         $type = $match[1];
         @(list($name) = explode(".{$type}", basename($file)));
         $base = str_replace("{$name}.{$type}", '', basename($file)) ?: FALSE;
         $out = path($output_dir, $path, "{$name}.{$type}");
         $dir = dirname($out);
         is_dir($dir) or mkdir($dir, 0777, TRUE);
         if (!is_file($out) or filemtime($file) > filemtime($out)) {
             switch ($type) {
                 case 'html':
                     $uri = $path ? "/{$path}" : '';
                     $uri .= $name != 'index' ? "/{$name}.{$type}" : '/';
                     assign('current_url', $uri);
                     if ($base) {
                         $view = \Tailor\Base::compile($file);
                     } else {
                         $view = read($file);
                     }
                     $layout = fetch('layout') ?: 'default';
                     $layout = \Tailor\Helpers::resolve("layouts/{$layout}", 'views_dir');
                     $hash = "{$layout}@";
                     $hash .= md5_file($file);
                     $hash .= filemtime($file);
                     if (is_file($layout)) {
                         $view = adjust_tags($view, \Tailor\Base::compile($layout));
                     }
                     status('partial', $out);
                     write($out, $view);
                     break;
                 case 'css':
                 case 'js':
                 default:
                     if ($base) {
                         $view = \Tailor\Base::compile($file);
                         status('partial', $out);
                         write($out, $view);
                     } else {
                         status('copy', $out);
                         copy($file, $out);
                     }
                     break;
             }
         }
         // TODO: more formats or better check-up?
     } elseif (preg_match('/\\.(?:jpe?g|png|gif|woff|eot|ttf|svg|ico|xml|rss|txt|webm|mp[34]|og[gv])$/', $file)) {
         $out = path($output_dir, $path, basename($file));
         $dir = dirname($out);
         is_dir($dir) or mkdir($dir, 0777, TRUE);
         status('copy', $out);
         copy($file, $out);
     }
 });