mirror of
https://github.com/pattern-lab/patternlab-php.git
synced 2025-01-17 22:29:12 +01:00
adding auto-loader support
This commit is contained in:
parent
b4851c4722
commit
6df68649cf
@ -24,80 +24,74 @@
|
||||
*
|
||||
*/
|
||||
|
||||
// load builder classes
|
||||
require __DIR__."/lib/builder.lib.php";
|
||||
require __DIR__."/lib/generator.lib.php";
|
||||
require __DIR__."/lib/watcher.lib.php";
|
||||
|
||||
// load mustache & register it
|
||||
require __DIR__."/lib/Mustache/Autoloader.php";
|
||||
Mustache_Autoloader::register();
|
||||
// auto-load classes
|
||||
require(__DIR__."/lib/SplClassLoader.php");
|
||||
|
||||
$loader = new SplClassLoader('PatternLab', __DIR__.'/lib');
|
||||
$loader->register();
|
||||
|
||||
$loader = new SplClassLoader('Mustache', __DIR__.'/lib');
|
||||
$loader->setNamespaceSeparator("_");
|
||||
$loader->register();
|
||||
|
||||
// make sure this script is being accessed from the command line
|
||||
if (php_sapi_name() == 'cli') {
|
||||
|
||||
$args = getopt("gwcr");
|
||||
|
||||
if (isset($args["g"])) {
|
||||
|
||||
// initiate the g (generate) switch
|
||||
|
||||
// iterate over the source directory and generate the site
|
||||
$g = new Generatr();
|
||||
|
||||
// check to see if CSS for patterns should be parsed & outputted
|
||||
if (isset($args["c"])) {
|
||||
// load css rule saver
|
||||
require __DIR__."/lib/css-rule-saver/css-rule-saver.php";
|
||||
print "CSS generation enabled. This could take a few seconds...\n";
|
||||
$g->generate(true);
|
||||
} else {
|
||||
$g->generate();
|
||||
}
|
||||
|
||||
print "your site has been generated...\n";
|
||||
|
||||
} else if (isset($args["w"])) {
|
||||
|
||||
// initiate the w (watch) switch
|
||||
|
||||
// iterate over the source directory and generate the site
|
||||
$g = new Generatr();
|
||||
$g->generate();
|
||||
print "your site has been generated...\n";
|
||||
|
||||
// watch the source directory and regenerate any changed files
|
||||
$w = new Watchr();
|
||||
print "watching your site for changes...\n";
|
||||
if (isset($args["r"])) {
|
||||
print "starting page auto-reload...\n";
|
||||
$w->watch(true);
|
||||
} else {
|
||||
$w->watch();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// when in doubt write out the usage
|
||||
print "\n";
|
||||
print "Usage:\n\n";
|
||||
print " php ".$_SERVER["PHP_SELF"]." -g\n";
|
||||
print " Iterates over the 'source' directories & files and generates the entire site a single time.\n";
|
||||
print " It also cleans the 'public' directory.\n\n";
|
||||
print " php ".$_SERVER["PHP_SELF"]." -gc\n";
|
||||
print " In addition to the -g flag features it will also generate CSS for each pattern. Resource instensive.\n\n";
|
||||
print " php ".$_SERVER["PHP_SELF"]." -w\n";
|
||||
print " Generates the site like the -g flag and then watches for changes in the 'source' directories &\n";
|
||||
print " files. Will re-generate files if they've changed.\n\n";
|
||||
print " php ".$_SERVER["PHP_SELF"]." -wr\n";
|
||||
print " In addition to the -w flag features it will also automatically start the auto-reload server.\n\n";
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (php_sapi_name() != 'cli') {
|
||||
print "The builder script can only be run from the command line.";
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$args = getopt("gwcr");
|
||||
|
||||
if (isset($args["g"]) || isset($args["w"])) {
|
||||
|
||||
// iterate over the source directory and generate the site
|
||||
$g = new PatternLab\Generator();
|
||||
$c = false;
|
||||
|
||||
// check to see if CSS for patterns should be parsed & outputted
|
||||
if (isset($args["c"]) && !isset($args["w"])) {
|
||||
// load css rule saver
|
||||
|
||||
$c = true;
|
||||
}
|
||||
|
||||
print "your site has been generated...\n";
|
||||
|
||||
$g->generate($c);
|
||||
|
||||
}
|
||||
|
||||
if (isset($args["w"])) {
|
||||
|
||||
// watch the source directory and regenerate any changed files
|
||||
$w = new PatternLab\Watcher();
|
||||
$a = false;
|
||||
|
||||
if (isset($args["r"])) {
|
||||
print "starting page auto-reload...\n";
|
||||
$a = true;
|
||||
}
|
||||
|
||||
print "watching your site for changes...\n";
|
||||
|
||||
$w->watch($a);
|
||||
|
||||
}
|
||||
|
||||
if (!isset($args["g"]) && !isset($args["w"])) {
|
||||
|
||||
// when in doubt write out the usage
|
||||
print "\n";
|
||||
print "Usage:\n\n";
|
||||
print " php ".$_SERVER["PHP_SELF"]." -g\n";
|
||||
print " Iterates over the 'source' directories & files and generates the entire site a single time.\n";
|
||||
print " It also cleans the 'public' directory.\n\n";
|
||||
print " php ".$_SERVER["PHP_SELF"]." -gc\n";
|
||||
print " In addition to the -g flag features it will also generate CSS for each pattern. Resource instensive.\n\n";
|
||||
print " php ".$_SERVER["PHP_SELF"]." -w\n";
|
||||
print " Generates the site like the -g flag and then watches for changes in the 'source' directories &\n";
|
||||
print " files. Will re-generate files if they've changed.\n\n";
|
||||
print " php ".$_SERVER["PHP_SELF"]." -wr\n";
|
||||
print " In addition to the -w flag features it will also automatically start the auto-reload server.\n\n";
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user