Exemplo n.º 1
0
 /**
  * Pulls together a bunch of functions from builder.lib.php in an order that makes sense
  * @param  {Boolean}       decide if CSS should be parsed and saved. performance hog.
  * @param  {Boolean}       decide if static files like CSS and JS should be moved
  */
 public function generate($options = array())
 {
     // double-checks options was properly set
     if (empty($options)) {
         Console::writeError("need to pass options to generate...");
     }
     // set the default vars
     $moveStatic = isset($options["moveStatic"]) ? $options["moveStatic"] : true;
     $noCacheBuster = isset($options["noCacheBuster"]) ? $options["noCacheBuster"] : false;
     $exportFiles = isset($options["exportFiles"]) ? $options["exportFiles"] : false;
     $exportClean = isset($options["exportClean"]) ? $options["exportClean"] : false;
     $watchMessage = isset($options["watchMessage"]) ? $options["watchMessage"] : false;
     $watchVerbose = isset($options["watchVerbose"]) ? $options["watchVerbose"] : false;
     $update = isset($options["update"]) ? $options["update"] : false;
     Config::setOption("update", $update);
     if ($noCacheBuster) {
         Config::updateOption("cacheBuster", 0);
     }
     FileChangeList::init(Config::getOption("publicDir") . DIRECTORY_SEPARATOR . "fileChangeList.csv");
     // gather up all of the data to be used in patterns
     Data::gather();
     // gather all of the various pattern info
     $options = array();
     $options["exportClean"] = $exportClean;
     $options["exportFiles"] = $exportFiles;
     PatternData::gather($options);
     // gather the annotations
     Annotations::gather();
     // clean the public directory to remove old files
     if (Config::getOption("cleanPublic") == "true" && $moveStatic) {
         FileUtil::cleanPublic();
     }
     // render out the index and style guide
     $this->generateIndex();
     $this->generateStyleguide();
     $this->generateViewAllPages();
     // render out the patterns and move them to public/patterns
     $options = array();
     $options["exportFiles"] = $exportFiles;
     $this->generatePatterns($options);
     // render the annotations as a js file
     $this->generateAnnotations();
     // move all of the files unless pattern only is set
     if ($moveStatic) {
         $this->moveStatic();
     }
     // update the change time so the auto-reload will fire (doesn't work for the index and style guide)
     Util::updateChangeTime();
     FileChangeList::write();
     if ($watchVerbose && $watchMessage) {
         Console::writeLine($watchMessage);
     } else {
         Console::writeLine("your site has been generated...");
         Timer::stop();
     }
 }
Exemplo n.º 2
0
 /**
  * Generates the annotations js file
  */
 protected function generateAnnotations()
 {
     // set-up the dispatcher
     $dispatcherInstance = Dispatcher::getInstance();
     // note the start of the operation
     $dispatcherInstance->dispatch("builder.generateAnnotationsStart");
     // default var
     $publicDir = Config::getOption("publicDir");
     // encode the content so it can be written out
     $json = json_encode(Annotations::get());
     // make sure annotations/ exists
     if (!is_dir($publicDir . "/annotations")) {
         mkdir($publicDir . "/annotations");
     }
     // write out the new annotations.js file
     file_put_contents($publicDir . "/annotations/annotations.js", "var comments = " . $json . ";");
     // note the end of the operation
     $dispatcherInstance->dispatch("builder.generateAnnotationsEnd");
 }
Exemplo n.º 3
0
 /**
  * Updates the Pattern Lab Website and prints the appropriate message
  * @param  {String}       file name to included in the message
  * @param  {String}       a switch for decided which message isn't printed
  *
  * @return {String}       the final message
  */
 private function updateSite($fileName, $message, $verbose = true)
 {
     $watchMessage = "";
     if ($verbose) {
         if ($message == "added") {
             $watchMessage = "<warning>" . $fileName . " was added to Pattern Lab. reload the website to see this change in the navigation...</warning>";
         } elseif ($message == "removed") {
             $watchMessage = "<warning>" . $fileName . " was removed from Pattern Lab. reload the website to see this change reflected in the navigation...</warning>";
         } elseif ($message == "hidden") {
             $watchMessage = "<warning>" . $fileName . " was hidden from Pattern Lab. reload the website to see this change reflected in the navigation...</warning>";
         } else {
             $watchMessage = "<info>" . $fileName . " changed...</info>";
         }
     }
     $options = $this->options;
     $options["watchVerbose"] = $verbose;
     $options["watchMessage"] = $watchMessage;
     $options["moveStatic"] = false;
     // clear the various data stores for re-population
     Data::clear();
     PatternData::clear();
     Annotations::clear();
     $g = new Generator();
     $g->generate($options);
 }