├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── config └── .gitkeep ├── core ├── console ├── server │ └── router.php └── src │ └── PatternLab │ └── Installer.php ├── public └── .gitkeep └── source └── .gitkeep /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | export/* 3 | public/* 4 | source/styleguide/* 5 | vendor/* 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2016 Brad Frost, http://bradfrostweb.com & Dave Olsen, http://dmolsen.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![license](https://img.shields.io/github/license/pattern-lab/patternlab-php.svg) 2 | [![Packagist](https://img.shields.io/packagist/v/pattern-lab/edition-mustache-standard.svg)](https://packagist.org/packages/pattern-lab/edition-mustache-standard) [![Gitter](https://img.shields.io/gitter/room/pattern-lab/php.svg)](https://gitter.im/pattern-lab/php) 3 | 4 | # Pattern Lab Standard Edition for Mustache 5 | 6 | The Pattern Lab Standard Edition for Mustache is the evolution of Pattern Lab 1. Pattern Lab is still, at its core, a prototyping tool focused on encouraging communication between content creators, designers, devs, and clients. It combines platform-agnostic assets, like the [Mustache](http://mustache.github.io/)-based patterns, with a PHP-based "builder." Pattern Lab 2 introduces [the beginnings of an ecosystem](http://patternlab.io/docs/advanced-ecosystem-overview.html) that will allow teams to mix, match and extend Pattern Lab to meet their specific needs. It will also make it easier for the Pattern Lab team to push out new features. Pattern Lab Standard Edition for Mustache is just [one of the four PHP-based Editions currently available](http://patternlab.io/docs/installation.html). 7 | 8 | ## Demo 9 | 10 | You can play with a demo of the front-end of Pattern Lab at [demo.patternlab.io](http://demo.patternlab.io). 11 | 12 | ## Requirements 13 | 14 | To use the basic features of Pattern Lab to compile patterns, you must have **PHP 5.4+** installed. On Mac OS X Pattern Lab should work "out of the box." If you're on Windows you can [download PHP from PHP.net](http://windows.php.net/download/). Pattern Lab comes with its own built-in web server. 15 | 16 | Pattern Lab uses [Composer](https://getcomposer.org/) to manage project dependencies. It's required if you want to install Pattern Lab using Composer's `create-project` command or if you want to upgrade Pattern Lab in the future. 17 | 18 | ## Installing 19 | 20 | There are two methods for downloading and installing the Standard Edition for Mustache: 21 | 22 | * Download a pre-built project 23 | * Create a project based on this Edition with Composer 24 | 25 | ### Download a pre-built project 26 | 27 | The fastest way to get started with Pattern Lab's Standard Edition for Mustache is to download the latest pre-built version from the [releases page](https://github.com/pattern-lab/patternlab-php/releases/latest). 28 | 29 | ### Use Composer to create a project 30 | 31 | Pattern Lab uses [Composer](https://getcomposer.org/) to manage project dependencies. 32 | 33 | #### 1. Install Composer 34 | 35 | Please follow the directions for [installing Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx) on the Composer website. We recommend you [install it globally](https://getcomposer.org/doc/00-intro.md#globally). 36 | 37 | #### 2. Install the Standard Edition for Mustache 38 | 39 | Use Composer's [`create-project` command](https://getcomposer.org/doc/03-cli.md#create-project) to install the Standard Edition for Mustache into a location of your choosing. To create a project do the following: 40 | 41 | 1. In a terminal window navigate to where you want to install Pattern Lab 42 | 2. Type `composer create-project pattern-lab/edition-mustache-standard patternlab2-example && cd $_` 43 | 3. When prompted, type `1` to install the demo StarterKit 44 | 45 | This will install the Standard Edition for Mustache along with the demo StarterKit into a directory called `patternlab2-example`. You will be automatically dropped into `patternlab2-example/` when the install is finished. 46 | 47 | **Note:** If you clone or download this repository and use `composer install` to install the project dependencies you'll need to type the following to install the demo StarterKit: 48 | 49 | composer install-demo 50 | 51 | Otherwise you'll have a very bare set-up of Pattern Lab. 52 | 53 | ## Get Up and Running 54 | 55 | After installing do the following to start and view Pattern Lab: 56 | 57 | 1. In a terminal window navigate to the root of your project if you aren't there already 58 | 2. Type `php core/console --server --with-watch` 59 | 60 | You should now be able to open [http://localhost:8080](http://localhost:8080) to see your generated site. Any changes you make in `./source/` will automatically rebuild your site and reload your browser. 61 | 62 | As you get more comfortable with Pattern Lab you can [integrate it with a Gulp or Grunt workflow](http://patternlab.io/docs/advanced-integration-with-grunt.html) and drop some of the native Pattern Lab features like automatic browser reload. You can also check out [the list of plugins](http://patternlab.io/download.html). 63 | 64 | ## More Documentation 65 | 66 | Obviously Pattern Lab is deeper than the install process. [Check out the documentation](https://patternlab.io/docs/) to learn about how to use patterns, how to modify the data used to populate those patterns, and about some advanced features. 67 | 68 | ## Migrating from Pattern Lab 1 to Pattern Lab 2 69 | 70 | Pattern Lab 2 was a complete rewrite and reorganization of Pattern Lab 1. [Learn about the changes](http://patternlab.io/docs/changes-1-to-2.html). After installing the Standard Edition for Mustache do the following to migrate from Pattern Lab 1 to Pattern Lab 2: 71 | 72 | 1. Copy `./source` from your old project to your new install 73 | 2. Copy `./source/_patterns/00-atoms/00-meta/_00-head.mustache` to `./source/_meta/_00-head.mustache` 74 | 3. Copy `./source/_patterns/00-atoms/00-meta/_01-foot.mustache` to `./source/_meta/_00-foot.mustache` 75 | 4. Copy `./source/_data/annotations.js` to `./source/_annotations/annotations.js` 76 | 77 | Everything else should work without changes. 78 | 79 | ## Need Pattern Lab 1? 80 | 81 | The [source code for Pattern Lab 1](https://github.com/pattern-lab/patternlab-php/releases/tag/v1.1.0) is still available for download. 82 | 83 | ## Packaged Components 84 | 85 | The Standard Edition for Mustache installs the following components: 86 | 87 | * `pattern-lab/core`: [GitHub](https://github.com/pattern-lab/patternlab-php-core), [Packagist](https://packagist.org/packages/pattern-lab/core) 88 | * `pattern-lab/patternengine-mustache`: [documentation](https://github.com/pattern-lab/patternengine-php-mustache#mustache-patternengine-for-pattern-lab-php), [GitHub](https://github.com/pattern-lab/patternengine-php-mustache), [Packagist](https://packagist.org/packages/pattern-lab/patternengine-mustache) 89 | * `pattern-lab/plugin-reload`: [GitHub](https://github.com/pattern-lab/plugin-php-reload), [Packagist](https://packagist.org/packages/pattern-lab/plugin-reload) 90 | * `pattern-lab/styleguidekit-assets-default`: [GitHub](https://github.com/pattern-lab/styleguidekit-assets-default), [Packagist](https://packagist.org/packages/pattern-lab/styleguidekit-assets-default) 91 | * `pattern-lab/styleguidekit-mustache-default`: [GitHub](https://github.com/pattern-lab/styleguidekit-mustache-default), [Packagist](https://packagist.org/packages/pattern-lab/styleguidekit-mustache-default) 92 | 93 | ## List All of the Available Commands and Their Options 94 | 95 | To list all available commands type: 96 | 97 | php core/console --help 98 | 99 | To list the options for a particular command type: 100 | 101 | php core/console --help --[command] 102 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pattern-lab/edition-mustache-standard", 3 | "description": "The Standard Edition of Pattern Lab for Mustache. Installs all Mustache-related dependencies.", 4 | "keywords": ["pattern lab", "mustache"], 5 | "homepage": "http://patternlab.io", 6 | "license": "MIT", 7 | "type": "project", 8 | "authors": [ 9 | { 10 | "name": "Dave Olsen", 11 | "email": "dmolsen@gmail.com", 12 | "homepage": "http://dmolsen.com", 13 | "role": "Lead Developer" 14 | } 15 | ], 16 | "support": { 17 | "issues": "https://github.com/pattern-lab/patternlab-php/issues", 18 | "wiki": "http://patternlab.io/docs/", 19 | "source": "https://github.com/pattern-lab/patternlab-php/releases" 20 | }, 21 | "autoload": { 22 | "psr-0": { 23 | "PatternLab": "core/src/" 24 | } 25 | }, 26 | "require": { 27 | "php": ">=5.4", 28 | "pattern-lab/core": "^2.0.0", 29 | "pattern-lab/patternengine-mustache": "^2.0.0", 30 | "pattern-lab/styleguidekit-mustache-default": "^3.0.0", 31 | "pattern-lab/plugin-reload": "^2.0.0" 32 | }, 33 | "scripts": { 34 | "server": "php core/console --server", 35 | "generate": "php core/console --generate", 36 | "watch": "php core/console --watch", 37 | "start": "php core/console --server --with-watch", 38 | "install-demo": "php core/console --starterkit --install pattern-lab/starterkit-mustache-demo", 39 | "post-install-cmd": [ 40 | "PatternLab\\Installer::postInstallCmd" 41 | ], 42 | "post-update-cmd": [ 43 | "PatternLab\\Installer::postUpdateCmd" 44 | ], 45 | "post-root-package-install": [ 46 | "PatternLab\\Installer::setProjectInstall", 47 | "PatternLab\\Installer::getSuggestedStarterKits", 48 | "PatternLab\\Installer::getConfigOverrides" 49 | ], 50 | "post-package-install": [ 51 | "PatternLab\\Installer::postPackageInstall" 52 | ], 53 | "post-package-update": [ 54 | "PatternLab\\Installer::postPackageUpdate" 55 | ], 56 | "pre-package-uninstall": [ 57 | "PatternLab\\Installer::prePackageUninstall" 58 | ] 59 | }, 60 | "extra": { 61 | "patternlab": { 62 | "starterKitSuggestions": [ 63 | "pattern-lab/starterkit-mustache-demo", 64 | "pattern-lab/starterkit-mustache-base" 65 | ] 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /config/.gitkeep: -------------------------------------------------------------------------------- 1 | After you generate Pattern Lab for the first time your configuration file will be placed here. -------------------------------------------------------------------------------- /core/console: -------------------------------------------------------------------------------- 1 | dispatch("config.configLoadEnd"); 44 | 45 | // run the console 46 | Console::run(); 47 | -------------------------------------------------------------------------------- /core/server/router.php: -------------------------------------------------------------------------------- 1 | false, "packagesRemove" => false, "suggestedStarterKits" => array(), "configOverrides" => array(), "patternLabPackages" => array()); 22 | 23 | /** 24 | * Get any config overrides that may exist for the edition 25 | * @param {Object} a script event object from composer 26 | */ 27 | public static function getConfigOverrides(Event $event) { 28 | 29 | $extra = $event->getComposer()->getPackage()->getExtra(); 30 | if (isset($extra["patternlab"]) && isset($extra["patternlab"]["config"]) && is_array($extra["patternlab"]["config"])) { 31 | self::$installerInfo["configOverrides"] = $extra["patternlab"]["config"]; 32 | } 33 | 34 | } 35 | 36 | /** 37 | * Get the package info from each patternlab-* package's composer.json 38 | * @param {String} the type of event fired during the composer install 39 | * @param {Object} a script event object from composer 40 | */ 41 | public static function getPackageInfo($type, $event) { 42 | 43 | $package = ($type == "update") ? $event->getOperation()->getTargetPackage() : $event->getOperation()->getPackage(); 44 | $packageType = $package->getType(); 45 | $packageExtra = $package->getExtra(); 46 | $packageInfo = array(); 47 | 48 | // make sure we're only evaluating pattern lab packages 49 | if (strpos($packageType,"patternlab-") !== false) { 50 | 51 | $packageInfo["name"] = $package->getName(); 52 | $packageInfo["type"] = $packageType; 53 | $packageInfo["pathBase"] = $event->getComposer()->getInstallationManager()->getInstallPath($package); 54 | $packageInfo["pathDist"] = $packageInfo["pathBase"].DIRECTORY_SEPARATOR."dist".DIRECTORY_SEPARATOR; 55 | $packageInfo["extra"] = (isset($packageExtra["patternlab"])) ? $packageExtra["patternlab"] : array(); 56 | 57 | self::$installerInfo["packages"][] = $packageInfo; 58 | 59 | } 60 | 61 | } 62 | 63 | /** 64 | * Get the suggested starter kits from the root package composer.json 65 | * @param {Object} a script event object from composer 66 | */ 67 | public static function getSuggestedStarterKits(Event $event) { 68 | 69 | $extra = $event->getComposer()->getPackage()->getExtra(); 70 | if (isset($extra["patternlab"]) && isset($extra["patternlab"]["starterKitSuggestions"]) && is_array($extra["patternlab"]["starterKitSuggestions"])) { 71 | self::$installerInfo["suggestedStarterKits"] = $extra["patternlab"]["starterKitSuggestions"]; 72 | } 73 | 74 | } 75 | 76 | /** 77 | * Run the centralized postInstallCmd 78 | * @param {Object} a script event object from composer 79 | */ 80 | public static function postInstallCmd(Event $event) { 81 | 82 | InstallerUtil::postInstallCmd(self::$installerInfo, $event); 83 | 84 | } 85 | 86 | /** 87 | * Run the centralized postUpdateCmd 88 | * @param {Object} a script event object from composer 89 | */ 90 | public static function postUpdateCmd(Event $event) { 91 | 92 | InstallerUtil::postUpdateCmd(self::$installerInfo, $event); 93 | 94 | } 95 | 96 | /** 97 | * Clean-up when a package is removed 98 | * @param {Object} a script event object from composer 99 | */ 100 | public static function postPackageInstall(PackageEvent $event) { 101 | 102 | self::getPackageInfo("install", $event); 103 | 104 | } 105 | 106 | /** 107 | * Clean-up when a package is removed 108 | * @param {Object} a script event object from composer 109 | */ 110 | public static function postPackageUpdate(PackageEvent $event) { 111 | 112 | self::getPackageInfo("update", $event); 113 | 114 | } 115 | 116 | /** 117 | * Clean-up when a package is removed 118 | * @param {Object} a script event object from composer 119 | */ 120 | public static function prePackageUninstall(PackageEvent $event) { 121 | 122 | // make sure the postUpdateCmd doesnt actually do anything 123 | self::setPackagesRemove(); 124 | 125 | // get the basic package info 126 | $package = $event->getOperation()->getPackage(); 127 | $packageType = $package->getType(); 128 | $packageInfo = array(); 129 | 130 | // make sure we're only evaluating pattern lab packages. remove attributes related to them. 131 | if (strpos($packageType,"patternlab-") !== false) { 132 | 133 | $packageInfo["name"] = $package->getName(); 134 | $packageInfo["type"] = $packageType; 135 | $packageInfo["pathBase"] = $event->getComposer()->getInstallationManager()->getInstallPath($package); 136 | 137 | InstallerUtil::packageRemove($packageInfo); 138 | 139 | } 140 | 141 | } 142 | 143 | /** 144 | * Set the packages remove boolean to true 145 | */ 146 | public static function setPackagesRemove() { 147 | 148 | self::$installerInfo["packagesRemove"] = true; 149 | 150 | } 151 | 152 | /** 153 | * Set the project install boolean to true 154 | * @param {Object} a script event object from composer 155 | */ 156 | public static function setProjectInstall(Event $event) { 157 | 158 | self::$installerInfo["projectInstall"] = true; 159 | 160 | } 161 | 162 | } 163 | -------------------------------------------------------------------------------- /public/.gitkeep: -------------------------------------------------------------------------------- 1 | Holding file for public/ directory 2 | -------------------------------------------------------------------------------- /source/.gitkeep: -------------------------------------------------------------------------------- 1 | After you generate Pattern Lab for the first time your source files will be placed here. --------------------------------------------------------------------------------