mirror of
https://github.com/pattern-lab/edition-php-thin.git
synced 2025-01-16 21:08:16 +01:00
initial commit
This commit is contained in:
commit
fa36542488
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
.DS_Store
|
||||
public/*
|
||||
vendor/*
|
||||
composer.lock
|
20
LICENSE
Normal file
20
LICENSE
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-14 Brad Frost, http://bradfrostweb.com & Dave Olsen, http://dmolsen.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
62
README.md
Normal file
62
README.md
Normal file
@ -0,0 +1,62 @@
|
||||
## About Pattern Lab
|
||||
- [Pattern Lab Website](http://patternlab.io/)
|
||||
- [About Pattern Lab](http://patternlab.io/about.html)
|
||||
- [Documentation](http://patternlab.io/docs/index.html)
|
||||
- [Demo](http://demo.patternlab.io/)
|
||||
|
||||
The PHP version of Pattern Lab is, at its core, a static site generator. It combines platform-agnostic assets, like the [Mustache](http://mustache.github.io/)-based patterns and the JavaScript-based viewer, with a PHP-based "builder" that transforms and dynamically builds the Pattern Lab site. By making it a static site generator, Pattern Lab strongly separates patterns, data, and presentation from build logic.
|
||||
|
||||
## Demo
|
||||
|
||||
You can play with a demo of the front-end of Pattern Lab at [demo.patternlab.io](http://demo.patternlab.io).
|
||||
|
||||
## Getting Started
|
||||
|
||||
* [Requirements](http://patternlab.io/docs/requirements.html)
|
||||
* [Installing the PHP Version of Pattern Lab](http://patternlab.io/docs/installation.html)
|
||||
* [Upgrading the PHP Version of Pattern Lab](http://patternlab.io/docs/upgrading.html)
|
||||
* [Generating the Pattern Lab Website for the First Time](http://patternlab.io/docs/first-run.html)
|
||||
* [Editing the Pattern Lab Website Source Files](http://patternlab.io/docs/editing-source-files.html)
|
||||
* [Using the Command-line Options](http://patternlab.io/docs/command-line.html)
|
||||
* [Command Prompt on Windows](http://patternlab.io/docs/command-prompt-windows.html)
|
||||
|
||||
## Working with Patterns
|
||||
|
||||
Patterns are the core element of Pattern Lab. Understanding how they work is the key to getting the most out of the system. Patterns use [Mustache](http://mustache.github.io/) so please read [Mustache's docs](http://mustache.github.io/mustache.5.html) as well.
|
||||
|
||||
* [How Patterns Are Organized](http://patternlab.io/docs/pattern-organization.html)
|
||||
* [Adding New Patterns](http://patternlab.io/docs/pattern-add-new.html)
|
||||
* [Reorganizing Patterns](http://patternlab.io/docs/pattern-reorganizing.html)
|
||||
* [Including One Pattern Within Another via Partials](http://patternlab.io/docs/pattern-including.html)
|
||||
* [Managing Assets for a Pattern: JavaScript, images, CSS, etc.](http://patternlab.io/docs/pattern-managing-assets.html)
|
||||
* [Modifying the Pattern Header and Footer](http://patternlab.io/docs/pattern-header-footer.html)
|
||||
* [Using Pseudo-Patterns](http://patternlab.io/docs/pattern-pseudo-patterns.html)
|
||||
* [Using Pattern Parameters](http://patternlab.io/docs/pattern-parameters.html)
|
||||
* [Using Pattern State](http://patternlab.io/docs/pattern-states.html)
|
||||
* ["Hiding" Patterns in the Navigation](http://patternlab.io/docs/pattern-hiding.html)
|
||||
* [Adding Annotations](http://patternlab.io/docs/pattern-adding-annotations.html)
|
||||
* [Viewing Patterns on a Mobile Device](http://patternlab.io/docs/pattern-mobile-view.html)
|
||||
|
||||
## Creating & Working With Dynamic Data for a Pattern
|
||||
|
||||
The PHP version of Pattern Lab utilizes Mustache as the template language for patterns. In addition to allowing for the [inclusion of one pattern within another](http://patternlab.io/docs/pattern-including.html) it also gives pattern developers the ability to include variables. This means that attributes like image sources can be centralized in one file for easy modification across one or more patterns. The PHP version of Pattern Lab uses a JSON file, `source/_data/data.json`, to centralize many of these attributes.
|
||||
|
||||
* [Introduction to JSON & Mustache Variables](http://patternlab.io/docs/data-json-mustache.html)
|
||||
* [Overriding the Central `data.json` Values with Pattern-specific Values](http://patternlab.io/docs/data-pattern-specific.html)
|
||||
* [Linking to Patterns with Pattern Lab's Default `link` Variable](http://patternlab.io/docs/data-link-variable.html)
|
||||
* [Creating Lists with Pattern Lab's Default `listItems` Variable](http://patternlab.io/docs/data-listitems.html)
|
||||
|
||||
## Using Pattern Lab's Advanced Features
|
||||
|
||||
By default, the Pattern Lab assets can be manually generated and the Pattern Lab site manually refreshed but who wants to waste time doing that? Here are some ways that Pattern Lab can make your development workflow a little smoother:
|
||||
|
||||
* [Watching for Changes and Auto-Regenerating Patterns](http://patternlab.io/docs/advanced-auto-regenerate.html)
|
||||
* [Auto-Reloading the Browser Window When Changes Are Made](http://patternlab.io/docs/advanced-reload-browser.html)
|
||||
* [Multi-browser & Multi-device Testing with Page Follow](http://patternlab.io/docs/advanced-page-follow.html)
|
||||
* [Keyboard Shortcuts](http://patternlab.io/docs/advanced-keyboard-shortcuts.html)
|
||||
* [Special Pattern Lab-specific Query String Variables ](http://patternlab.io/docs/pattern-linking.html)
|
||||
* [Preventing the Cleaning of public/](http://patternlab.io/docs/advanced-clean-public.html)
|
||||
* [Generating CSS](http://patternlab.io/docs/advanced-generating-css.html)
|
||||
* [Modifying the Pattern Lab Nav](http://patternlab.io/docs/advanced-pattern-lab-nav.html)
|
||||
* [Editing the config.ini Options](http://patternlab.io/docs/advanced-config-options.html)
|
||||
* [Integration with Compass](http://patternlab.io/docs/advanced-integration-with-compass.html)
|
45
composer.json
Normal file
45
composer.json
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "pattern-lab/framework-thin-edition",
|
||||
"description": "The thin edition of Pattern Lab. It only installs Pattern Lab core.",
|
||||
"version": "0.7.12",
|
||||
"keywords": ["pattern lab"],
|
||||
"homepage": "http://patternlab.io",
|
||||
"license": "MIT",
|
||||
"type": "project",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Dave Olsen",
|
||||
"email": "dmolsen@gmail.com",
|
||||
"homepage": "http://dmolsen.com",
|
||||
"role": "Lead Developer"
|
||||
}
|
||||
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/pattern-lab/patternlab-php/issues",
|
||||
"wiki": "http://patternlab.io/docs/",
|
||||
"source": "https://github.com/pattern-lab/patternlab-php/releases"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"PatternLab": "core/src/"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"require": {
|
||||
"php": ">=5.3.6",
|
||||
"pattern-lab/core": "dev-dev"
|
||||
},
|
||||
"scripts": {
|
||||
"pre-install-cmd": [
|
||||
"PatternLab\\Installer::preInstallCmd"
|
||||
],
|
||||
"post-package-install": [
|
||||
"PatternLab\\Installer::postPackageInstall"
|
||||
],
|
||||
"post-package-update": [
|
||||
"PatternLab\\Installer::postPackageUpdate"
|
||||
]
|
||||
}
|
||||
}
|
1
config/README
Normal file
1
config/README
Normal file
@ -0,0 +1 @@
|
||||
After you generate Pattern Lab for the first time your configuration file will be placed here.
|
BIN
core/bin/composer.phar
Normal file
BIN
core/bin/composer.phar
Normal file
Binary file not shown.
42
core/builder.php
Normal file
42
core/builder.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*!
|
||||
* Pattern Lab Builder CLI - v0.7.12
|
||||
*
|
||||
* Copyright (c) 2013-2014 Dave Olsen, http://dmolsen.com
|
||||
* Licensed under the MIT license
|
||||
*
|
||||
*/
|
||||
|
||||
use \PatternLab\Config;
|
||||
use \PatternLab\Console;
|
||||
use \PatternLab\Dispatcher;
|
||||
|
||||
// check to see if json_decode exists. might be disabled in installs of PHP 5.5
|
||||
if (!function_exists("json_decode")) {
|
||||
print "Please check that your version of PHP includes the JSON extension. It's required for Pattern Lab to run. Aborting.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// set-up the project base directory
|
||||
$baseDir = __DIR__."/../";
|
||||
|
||||
// auto-load classes
|
||||
if (file_exists($baseDir."vendor/autoload.php")) {
|
||||
require($baseDir."vendor/autoload.php");
|
||||
} else {
|
||||
print "it doesn't appear that pattern lab has been set-up yet...\n";
|
||||
print "please install pattern lab's dependicies by typing: php core/bin/composer.phar install...\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// load the options
|
||||
Console::init();
|
||||
Config::init($baseDir);
|
||||
|
||||
// initialize the dispatcher & note that the config has been loaded
|
||||
Dispatcher::init();
|
||||
Dispatcher::$instance->dispatch("config.configLoadEnd");
|
||||
|
||||
// run the console
|
||||
Console::run();
|
6
core/scripts/README
Normal file
6
core/scripts/README
Normal file
@ -0,0 +1,6 @@
|
||||
These are Mac OS X-compatible files to open up select command line scripts. Simply double-click on a file and it should run
|
||||
the appropriate shell command. If you receive a permissions error you will need to use the command line to fix it.
|
||||
Simply go to the command line, cd to the scripts/php directory and type chmod +x [filename]. Replace [filename] with the
|
||||
appropriate filenames.
|
||||
|
||||
That's confusing.
|
3
core/scripts/generateSite.command
Executable file
3
core/scripts/generateSite.command
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
php "$DIR/../builder.php" -g
|
3
core/scripts/generateSiteWithCSS.command
Executable file
3
core/scripts/generateSiteWithCSS.command
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
php "$DIR/../builder.php" -gc
|
3
core/scripts/startWatcher.command
Executable file
3
core/scripts/startWatcher.command
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
php "$DIR/../builder.php" -w
|
237
core/src/PatternLab/Installer.php
Normal file
237
core/src/PatternLab/Installer.php
Normal file
@ -0,0 +1,237 @@
|
||||
<?php
|
||||
|
||||
/*!
|
||||
* Installer Class
|
||||
*
|
||||
* Copyright (c) 2014 Dave Olsen, http://dmolsen.com
|
||||
* Licensed under the MIT license
|
||||
*
|
||||
* Various functions to be run before and during composer package installs
|
||||
*
|
||||
*/
|
||||
|
||||
namespace PatternLab;
|
||||
|
||||
use \Composer\Script\Event;
|
||||
use \PatternLab\Config;
|
||||
use \PatternLab\Console;
|
||||
use \Symfony\Component\Filesystem\Filesystem;
|
||||
use \Symfony\Component\Filesystem\Exception\IOExceptionInterface;
|
||||
|
||||
class Installer {
|
||||
|
||||
/**
|
||||
* Move the files from the package to their location in the public dir or source dir
|
||||
* @param {String} the name of the package
|
||||
* @param {String} the base directory for the source of the files
|
||||
* @param {String} the base directory for the destintation of the files (publicDir or sourceDir)
|
||||
* @param {Array} the list of files to be moved
|
||||
*/
|
||||
protected static function parseFileList($packageName,$sourceBase,$destinationBase,$fileList) {
|
||||
|
||||
$fs = new Filesystem();
|
||||
|
||||
foreach ($fileList as $fileItem) {
|
||||
|
||||
// retrieve the source & destination
|
||||
$source = self::removeDots(key($fileItem));
|
||||
$destination = self::removeDots($fileItem[$source]);
|
||||
|
||||
// depending on the source handle things differently. mirror if it ends in /*
|
||||
if (($source == "*") && ($destination == "*")) {
|
||||
if (!self::pathExists($packageName,$destinationBase."/")) {
|
||||
$fs->mirror($sourceBase."/assets/",$destinationBase."/");
|
||||
}
|
||||
} else if (($source == "*") && ($destination[strlen($source)-1] == "*")) {
|
||||
$destination = rtrim($destination,"/*");
|
||||
if (!self::pathExists($packageName,$destinationBase."/".$destination)) {
|
||||
$fs->mirror($sourceBase."/assets/",$destinationBase."/".$destination);
|
||||
}
|
||||
} else if ($source[strlen($source)-1] == "*") {
|
||||
$source = rtrim($source,"/*");
|
||||
$destination = rtrim($destination,"/*");
|
||||
if (!self::pathExists($packageName,$destinationBase."/".$destination)) {
|
||||
$fs->mirror($sourceBase."/assets/".$source,$destinationBase."/".$destination);
|
||||
}
|
||||
} else {
|
||||
$pathInfo = explode("/",$destination);
|
||||
$file = array_pop($pathInfo);
|
||||
$destinationDir = implode("/",$pathInfo);
|
||||
if (!$fs->exists($destinationBase."/".$destinationDir)) {
|
||||
$fs->mkdir($destinationBase."/".$destinationDir);
|
||||
}
|
||||
if (!self::pathExists($packageName,$destinationBase."/".$destination)) {
|
||||
$fs->copy($sourceBase."/assets/".$source,$destinationBase."/".$destination,true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the path already exists. If it does prompt the user to double-check it should be overwritten
|
||||
* @param {String} the package name
|
||||
* @param {String} path to be checked
|
||||
*
|
||||
* @return {Boolean} if the path exists and should be overwritten
|
||||
*/
|
||||
protected static function pathExists($packageName,$path) {
|
||||
|
||||
$fs = new Filesystem();
|
||||
|
||||
if ($fs->exists($path)) {
|
||||
|
||||
Console::writeLine("<info>the path <path>".$path."</path> already exists. overwrite it with the contents of <path>".$packageName."</path>? Y/n > </info><nophpeol>");
|
||||
$answer = strtolower(trim(fgets($stdin)));
|
||||
fclose($stdin);
|
||||
if ($answer == "y") {
|
||||
Console::writeLine("<ok>contents of <path>".$path."</path> being overwritten...</ok>", false, true);
|
||||
return false;
|
||||
} else {
|
||||
Console::writeLine("<warning>contents of <path>".$path."</path> weren't overwritten. some parts of the <path>".$packageName."</path> package may be missing...</warning>", false, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the PL tasks when a package is installed
|
||||
* @param {Object} a script event object from composer
|
||||
*/
|
||||
public static function postPackageInstall(Event $event) {
|
||||
|
||||
self::runTasks($event);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the PL tasks when a package is updated
|
||||
* @param {Object} a script event object from composer
|
||||
*/
|
||||
public static function postPackageUpdate(Event $event) {
|
||||
|
||||
self::runTasks($event);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure certain things are set-up before running composer's install
|
||||
* @param {Object} a script event object from composer
|
||||
*/
|
||||
public static function preInstallCmd(Event $event) {
|
||||
|
||||
if (class_exists("\PatternLab\Config")) {
|
||||
|
||||
// initialize the console to print out any issues
|
||||
Console::init();
|
||||
|
||||
// initialize the config
|
||||
$baseDir = __DIR__."/../../../";
|
||||
Config::init($baseDir,false);
|
||||
|
||||
// check directories
|
||||
if (!is_dir(Config::$options["sourceDir"])) {
|
||||
mkdir(Config::$options["sourceDir"]);
|
||||
}
|
||||
|
||||
if (!is_dir(Config::$options["packagesDir"])) {
|
||||
mkdir(Config::$options["packagesDir"]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove dots from the path to make sure there is no file system traversal when looking for or writing files
|
||||
* @param {String} the path to check and remove dots
|
||||
*
|
||||
* @return {String} the path minus dots
|
||||
*/
|
||||
protected static function removeDots($path) {
|
||||
$parts = array();
|
||||
foreach (explode("/", $path) as $chunk) {
|
||||
if ((".." !== $chunk) && ("." !== $chunk) && ("" !== $chunk)) {
|
||||
$parts[] = $chunk;
|
||||
}
|
||||
}
|
||||
return implode("/", $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle some Pattern Lab specific tasks based on what's found in the package's composer.json file
|
||||
* @param {Object} a script event object from composer
|
||||
*/
|
||||
protected static function runTasks($event) {
|
||||
|
||||
// make sure pattern lab has been loaded
|
||||
if (class_exists("\PatternLab\Config")) {
|
||||
|
||||
// initialize the console to print out any issues
|
||||
Console::init();
|
||||
|
||||
// initialize the config for the pluginDir
|
||||
$baseDir = __DIR__."/../../../";
|
||||
Config::init($baseDir,false);
|
||||
|
||||
// get package info
|
||||
$package = $event->getOperation()->getPackage();
|
||||
$extra = $package->getExtra();
|
||||
$type = $package->getType();
|
||||
$name = $package->getName();
|
||||
$path = Config::$options["packagesDir"]."/".$name;
|
||||
|
||||
// make sure we're only evaluating pattern lab packages
|
||||
if (strpos($type,"patternlab-") !== false) {
|
||||
|
||||
// make sure that it has the name-spaced section of data to be parsed
|
||||
if (isset($extra["patternlab"])) {
|
||||
|
||||
// rebase $extra
|
||||
$extra = $extra["patternlab"];
|
||||
|
||||
// move assets to the base directory
|
||||
if (isset($extra["assets"]["baseDir"])) {
|
||||
self::parseFileList($name,$path,Config::$options["baseDir"],$extra["assets"]["baseDir"]);
|
||||
}
|
||||
|
||||
// move assets to the public directory
|
||||
if (isset($extra["assets"]["publicDir"])) {
|
||||
self::parseFileList($name,$path,Config::$options["publicDir"],$extra["assets"]["publicDir"]);
|
||||
}
|
||||
|
||||
// move assets to the source directory
|
||||
if (isset($extra["assets"]["sourceDir"])) {
|
||||
self::parseFileList($name,$path,Config::$options["sourceDir"],$extra["assets"]["sourceDir"]);
|
||||
}
|
||||
|
||||
// see if we need to modify the config
|
||||
if (isset($extra["config"])) {
|
||||
|
||||
foreach ($extra["config"] as $optionInfo) {
|
||||
|
||||
// get config info
|
||||
$option = key($optionInfo);
|
||||
$value = $optionInfo[$option];
|
||||
|
||||
// update the config option
|
||||
Config::updateConfigOption($option,$value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
1
export/README
Normal file
1
export/README
Normal file
@ -0,0 +1 @@
|
||||
This directory holds the files that are exported when using the export command.
|
1
packages/README
Normal file
1
packages/README
Normal file
@ -0,0 +1 @@
|
||||
Plugins will go here when you've installed them.
|
1
source/README
Normal file
1
source/README
Normal file
@ -0,0 +1 @@
|
||||
After you generate Pattern Lab for the first time your source files will be placed here.
|
Loading…
x
Reference in New Issue
Block a user