Use roots/sage-lib (incl. new config system)

This commit is contained in:
2017-07-09 07:05:07 -07:00
parent 7a9d4f6be8
commit 1a8dce9b09
16 changed files with 626 additions and 806 deletions

View File

@@ -40,16 +40,7 @@ collect([
'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home', 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home',
'frontpage', 'page', 'paged', 'search', 'single', 'singular', 'attachment' 'frontpage', 'page', 'paged', 'search', 'single', 'singular', 'attachment'
])->map(function ($type) { ])->map(function ($type) {
add_filter("{$type}_template_hierarchy", function ($templates) { add_filter("{$type}_template_hierarchy", __NAMESPACE__.'\\filter_templates');
return collect($templates)->flatMap(function ($template) {
$transforms = [
'%^/?(resources[\\/]views)?[\\/]?%' => '',
'%(\.blade)?(\.php)?$%' => ''
];
$normalizedTemplate = preg_replace(array_keys($transforms), array_values($transforms), $template);
return ["{$normalizedTemplate}.blade.php", "{$normalizedTemplate}.php"];
})->toArray();
});
}); });
/** /**
@@ -59,12 +50,21 @@ add_filter('template_include', function ($template) {
$data = collect(get_body_class())->reduce(function ($data, $class) use ($template) { $data = collect(get_body_class())->reduce(function ($data, $class) use ($template) {
return apply_filters("sage/template/{$class}/data", $data, $template); return apply_filters("sage/template/{$class}/data", $data, $template);
}, []); }, []);
echo template($template, $data); if ($template) {
// Return a blank file to make WordPress happy echo template($template, $data);
return get_theme_file_path('index.php'); return get_stylesheet_directory().'/index.php';
}
return $template;
}, PHP_INT_MAX); }, PHP_INT_MAX);
/** /**
* Tell WordPress how to find the compiled path of comments.blade.php * Tell WordPress how to find the compiled path of comments.blade.php
*/ */
add_filter('comments_template', 'App\\template_path'); add_filter('comments_template', function ($comments_template) {
$comments_template = str_replace(
[get_stylesheet_directory(), get_template_directory()],
'',
$comments_template
);
return template_path(locate_template(["views/{$comments_template}", $comments_template]) ?: $comments_template);
});

View File

@@ -3,16 +3,14 @@
namespace App; namespace App;
use Roots\Sage\Container; use Roots\Sage\Container;
use Illuminate\Contracts\Container\Container as ContainerContract;
/** /**
* Get the sage container. * Get the sage container.
* *
* @param string $abstract * @param string $abstract
* @param array $parameters * @param array $parameters
* @param ContainerContract $container * @param Container $container
* @return ContainerContract|mixed * @return Container|mixed
* @SuppressWarnings(PHPMD.StaticAccess)
*/ */
function sage($abstract = null, $parameters = [], ContainerContract $container = null) function sage($abstract = null, $parameters = [], ContainerContract $container = null)
{ {
@@ -77,6 +75,42 @@ function asset_path($asset)
return sage('assets')->getUri($asset); return sage('assets')->getUri($asset);
} }
/**
* @param string|string[] $templates Possible template files
* @return array
*/
function filter_templates($templates)
{
return collect($templates)
->map(function ($template) {
return preg_replace('#\.(blade\.)?php$#', '', ltrim($template));
})
->flatMap(function ($template) {
$paths = apply_filters('sage/filter_templates/paths', ['views', 'resources/views']);
return collect($paths)
->flatMap(function ($path) use ($template) {
return [
"{$path}/{$template}.blade.php",
"{$path}/{$template}.php",
"{$template}.blade.php",
"{$template}.php",
];
});
})
->filter()
->unique()
->all();
}
/**
* @param string|string[] $templates Relative path to possible template files
* @return string Location of the template
*/
function locate_template($templates)
{
return \locate_template(filter_templates($templates));
}
/** /**
* Determine whether to show the sidebar * Determine whether to show the sidebar
* @return bool * @return bool

View File

@@ -1,41 +0,0 @@
<?php
namespace Roots\Sage\Assets;
/**
* Class JsonManifest
* @package Roots\Sage
* @author QWp6t
*/
class JsonManifest implements ManifestInterface
{
/** @var array */
public $manifest;
/** @var string */
public $dist;
/**
* JsonManifest constructor
*
* @param string $manifestPath Local filesystem path to JSON-encoded manifest
* @param string $distUri Remote URI to assets root
*/
public function __construct($manifestPath, $distUri)
{
$this->manifest = file_exists($manifestPath) ? json_decode(file_get_contents($manifestPath), true) : [];
$this->dist = $distUri;
}
/** @inheritdoc */
public function get($asset)
{
return isset($this->manifest[$asset]) ? $this->manifest[$asset] : $asset;
}
/** @inheritdoc */
public function getUri($asset)
{
return "{$this->dist}/{$this->get($asset)}";
}
}

View File

@@ -1,31 +0,0 @@
<?php
namespace Roots\Sage\Assets;
/**
* Interface ManifestInterface
* @package Roots\Sage
* @author QWp6t
*/
interface ManifestInterface
{
/**
* Get the cache-busted filename
*
* If the manifest does not have an entry for $asset, then return $asset
*
* @param string $asset The original name of the file before cache-busting
* @return string
*/
public function get($asset);
/**
* Get the cache-busted URI
*
* If the manifest does not have an entry for $asset, then return URI for $asset
*
* @param string $asset The original name of the file before cache-busting
* @return string
*/
public function getUri($asset);
}

View File

@@ -1,8 +0,0 @@
<?php
namespace Roots\Sage;
class Config extends \Illuminate\Config\Repository
{
}

View File

@@ -1,10 +0,0 @@
<?php
namespace Roots\Sage;
use Illuminate\Container\Container as BaseContainer;
class Container extends BaseContainer
{
}

View File

@@ -1,129 +0,0 @@
<?php
namespace Roots\Sage\Template;
use Illuminate\Contracts\Container\Container as ContainerContract;
use Illuminate\Contracts\View\Factory as FactoryContract;
use Illuminate\View\Engines\CompilerEngine;
use Illuminate\View\Engines\EngineInterface;
use Illuminate\View\ViewFinderInterface;
/**
* Class BladeProvider
* @method \Illuminate\View\View file($file, $data = [], $mergeData = [])
* @method \Illuminate\View\View make($file, $data = [], $mergeData = [])
*/
class Blade
{
/** @var ContainerContract */
protected $app;
public function __construct(FactoryContract $env, ContainerContract $app)
{
$this->env = $env;
$this->app = $app;
}
/**
* Get the compiler
*
* @return \Illuminate\View\Compilers\BladeCompiler
*/
public function compiler()
{
static $engineResolver;
if (!$engineResolver) {
$engineResolver = $this->app->make('view.engine.resolver');
}
return $engineResolver->resolve('blade')->getCompiler();
}
/**
* @param string $view
* @param array $data
* @param array $mergeData
* @return string
*/
public function render($view, $data = [], $mergeData = [])
{
/** @var \Illuminate\Contracts\Filesystem\Filesystem $filesystem */
$filesystem = $this->app['files'];
return $this->{$filesystem->exists($view) ? 'file' : 'make'}($view, $data, $mergeData)->render();
}
/**
* @param string $file
* @param array $data
* @param array $mergeData
* @return string
*/
public function compiledPath($file, $data = [], $mergeData = [])
{
$rendered = $this->file($file, $data, $mergeData);
/** @var EngineInterface $engine */
$engine = $rendered->getEngine();
if (!($engine instanceof CompilerEngine)) {
// Using PhpEngine, so just return the file
return $file;
}
$compiler = $engine->getCompiler();
$compiledPath = $compiler->getCompiledPath($rendered->getPath());
if ($compiler->isExpired($compiledPath)) {
$compiler->compile($file);
}
return $compiledPath;
}
/**
* @param string $file
* @return string
*/
public function normalizeViewPath($file)
{
// Convert `\` to `/`
$view = str_replace('\\', '/', $file);
// Add namespace to path if necessary
$view = $this->applyNamespaceToPath($view);
// Remove unnecessary parts of the path
$view = str_replace(array_merge($this->app['config']['view.paths'], ['.blade.php', '.php']), '', $view);
// Remove superfluous and leading slashes
return ltrim(preg_replace('%//+%', '/', $view), '/');
}
/**
* Convert path to view namespace
* @param string $path
* @return string
*/
public function applyNamespaceToPath($path)
{
/** @var ViewFinderInterface $finder */
$finder = $this->app['view.finder'];
if (!method_exists($finder, 'getHints')) {
return $path;
}
$delimiter = $finder::HINT_PATH_DELIMITER;
$hints = $finder->getHints();
$view = array_reduce(array_keys($hints), function ($view, $namespace) use ($delimiter, $hints) {
return str_replace($hints[$namespace], $namespace.$delimiter, $view);
}, $path);
return preg_replace("%{$delimiter}[\\/]*%", $delimiter, $view);
}
/**
* Pass any method to the view Factory instance.
*
* @param string $method
* @param array $params
* @return mixed
*/
public function __call($method, $params)
{
return call_user_func_array([$this->env, $method], $params);
}
}

View File

@@ -1,91 +0,0 @@
<?php
namespace Roots\Sage\Template;
use Illuminate\Container\Container;
use Illuminate\Contracts\Container\Container as ContainerContract;
use Illuminate\Events\Dispatcher;
use Illuminate\Filesystem\Filesystem;
use Illuminate\View\ViewServiceProvider;
/**
* Class BladeProvider
*/
class BladeProvider extends ViewServiceProvider
{
/**
* @param ContainerContract $container
* @param array $config
* @SuppressWarnings(PHPMD.StaticAccess)
*/
public function __construct(ContainerContract $container = null, $config = [])
{
/** @noinspection PhpParamsInspection */
parent::__construct($container ?: Container::getInstance());
$this->app->bindIf('config', function () use ($config) {
return $config;
}, true);
}
/**
* Bind required instances for the service provider.
*/
public function register()
{
$this->registerFilesystem();
$this->registerEvents();
$this->registerEngineResolver();
$this->registerViewFinder();
$this->registerFactory();
return $this;
}
/**
* Register Filesystem
*/
public function registerFilesystem()
{
$this->app->bindIf('files', Filesystem::class, true);
return $this;
}
/**
* Register the events dispatcher
*/
public function registerEvents()
{
$this->app->bindIf('events', Dispatcher::class, true);
return $this;
}
/** @inheritdoc */
public function registerEngineResolver()
{
parent::registerEngineResolver();
return $this;
}
/** @inheritdoc */
public function registerFactory()
{
parent::registerFactory();
return $this;
}
/**
* Register the view finder implementation.
*/
public function registerViewFinder()
{
$this->app->bindIf('view.finder', function ($app) {
$config = $this->app['config'];
$paths = $config['view.paths'];
$namespaces = $config['view.namespaces'];
$finder = new FileViewFinder($app['files'], $paths);
array_map([$finder, 'addNamespace'], array_keys($namespaces), $namespaces);
return $finder;
}, true);
return $this;
}
}

View File

@@ -1,40 +0,0 @@
<?php
namespace Roots\Sage\Template;
class FileViewFinder extends \Illuminate\View\FileViewFinder
{
const FALLBACK_PARTS_DELIMITER = '-';
/**
* Get an array of possible view files from a single file name.
*
* @param string $name
* @return array
*/
public function getPossibleViewFiles($name)
{
$parts = explode(self::FALLBACK_PARTS_DELIMITER, $name);
$templates[] = array_shift($parts);
foreach ($parts as $i => $part) {
$templates[] = $templates[$i].self::FALLBACK_PARTS_DELIMITER.$part;
}
rsort($templates);
return $this->getPossibleViewFilesFromTemplates($templates);
}
/**
* Get an array of possible view files from an array of templates
*
* @param array $templates
* @return array
*/
public function getPossibleViewFilesFromTemplates($templates)
{
return call_user_func_array('array_merge', array_map(function ($template) {
return array_map(function ($extension) use ($template) {
return str_replace('.', '/', $template).'.'.$extension;
}, $this->extensions);
}, $templates));
}
}

View File

@@ -2,9 +2,8 @@
namespace App; namespace App;
use Illuminate\Contracts\Container\Container as ContainerContract; use Roots\Sage\Container;
use Roots\Sage\Assets\JsonManifest; use Roots\Sage\Assets\JsonManifest;
use Roots\Sage\Config;
use Roots\Sage\Template\Blade; use Roots\Sage\Template\Blade;
use Roots\Sage\Template\BladeProvider; use Roots\Sage\Template\BladeProvider;
@@ -101,29 +100,6 @@ add_action('the_post', function ($post) {
* Setup Sage options * Setup Sage options
*/ */
add_action('after_setup_theme', function () { add_action('after_setup_theme', function () {
/**
* Sage config
*/
$paths = [
'dir.stylesheet' => get_stylesheet_directory(),
'dir.template' => get_template_directory(),
'dir.upload' => wp_upload_dir()['basedir'],
'uri.stylesheet' => get_stylesheet_directory_uri(),
'uri.template' => get_template_directory_uri(),
];
$viewPaths = collect(preg_replace('%[\/]?(resources/views)?[\/.]*?$%', '', [STYLESHEETPATH, TEMPLATEPATH]))
->flatMap(function ($path) {
return ["{$path}/resources/views", $path];
})->unique()->toArray();
config([
'assets.manifest' => "{$paths['dir.stylesheet']}/../dist/assets.json",
'assets.uri' => "{$paths['uri.stylesheet']}/dist",
'view.compiled' => "{$paths['dir.upload']}/cache/compiled",
'view.namespaces' => ['App' => WP_CONTENT_DIR],
'view.paths' => $viewPaths,
] + $paths);
/** /**
* Add JsonManifest to Sage container * Add JsonManifest to Sage container
*/ */
@@ -134,24 +110,19 @@ add_action('after_setup_theme', function () {
/** /**
* Add Blade to Sage container * Add Blade to Sage container
*/ */
sage()->singleton('sage.blade', function (ContainerContract $app) { sage()->singleton('sage.blade', function (Container $app) {
$cachePath = config('view.compiled'); $cachePath = config('view.compiled');
if (!file_exists($cachePath)) { if (!file_exists($cachePath)) {
wp_mkdir_p($cachePath); wp_mkdir_p($cachePath);
} }
(new BladeProvider($app))->register(); (new BladeProvider($app))->register();
return new Blade($app['view'], $app); return new Blade($app['view']);
}); });
/** /**
* Create @asset() Blade directive * Create @asset() Blade directive
*/ */
sage('blade')->compiler()->directive('asset', function ($asset) { sage('blade')->compiler()->directive('asset', function ($asset) {
return "<?= App\\asset_path({$asset}); ?>"; return "<?= " . __NAMESPACE__ . "\\asset_path({$asset}); ?>";
}); });
}); });
/**
* Init config
*/
sage()->bindIf('config', Config::class, true);

View File

@@ -25,26 +25,26 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Roots\\Sage\\": "app/lib/Sage/" "App\\": "app/"
} }
}, },
"require": { "require": {
"php": ">=5.6.4", "php": ">=5.6.4",
"composer/installers": "~1.0", "composer/installers": "~1.0",
"illuminate/view": "~5.4", "illuminate/support": "~5.4",
"illuminate/config": "~5.4", "roots/sage-lib": "~9.0.0-beta.3",
"soberwp/controller": "dev-master", "soberwp/controller": "dev-master"
"roots/sage-installer": "~1.0"
}, },
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": "^2.8.0" "squizlabs/php_codesniffer": "^2.8.0",
"roots/sage-installer": "~1.1"
}, },
"scripts": { "scripts": {
"test": [ "test": [
"phpcs" "phpcs"
], ],
"post-create-project-cmd": [ "post-create-project-cmd": [
"Roots\\Sage\\Installer\\ComposerScript::postCreateProject" "Roots\\Sage\\Installer\\ComposerScript::postCreateProject"
] ]
} }
} }

813
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "fc2a3ea295ebcf82c9ed351b447446b2", "content-hash": "9a56b0654d7dff65e2aebe6ed81833f3",
"packages": [ "packages": [
{ {
"name": "brain/hierarchy", "name": "brain/hierarchy",
@@ -344,57 +344,6 @@
"homepage": "https://laravel.com", "homepage": "https://laravel.com",
"time": "2017-02-04T20:27:32+00:00" "time": "2017-02-04T20:27:32+00:00"
}, },
{
"name": "illuminate/console",
"version": "v5.4.27",
"source": {
"type": "git",
"url": "https://github.com/illuminate/console.git",
"reference": "bdc5c6f53cb474e2aeec46b6a9999fcedfb62a4e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/console/zipball/bdc5c6f53cb474e2aeec46b6a9999fcedfb62a4e",
"reference": "bdc5c6f53cb474e2aeec46b6a9999fcedfb62a4e",
"shasum": ""
},
"require": {
"illuminate/contracts": "5.4.*",
"illuminate/support": "5.4.*",
"nesbot/carbon": "~1.20",
"php": ">=5.6.4",
"symfony/console": "~3.2"
},
"suggest": {
"guzzlehttp/guzzle": "Required to use the ping methods on schedules (~6.0).",
"mtdowling/cron-expression": "Required to use scheduling component (~1.0).",
"symfony/process": "Required to use scheduling component (~3.2)."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.4-dev"
}
},
"autoload": {
"psr-4": {
"Illuminate\\Console\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Console package.",
"homepage": "https://laravel.com",
"time": "2017-06-10T13:11:18+00:00"
},
{ {
"name": "illuminate/container", "name": "illuminate/container",
"version": "v5.4.27", "version": "v5.4.27",
@@ -680,59 +629,6 @@
"homepage": "https://laravel.com", "homepage": "https://laravel.com",
"time": "2017-06-07T13:32:57+00:00" "time": "2017-06-07T13:32:57+00:00"
}, },
{
"name": "nesbot/carbon",
"version": "1.22.1",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc",
"reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/translation": "~2.6 || ~3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~2",
"phpunit/phpunit": "~4.0 || ~5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.23-dev"
}
},
"autoload": {
"psr-4": {
"Carbon\\": "src/Carbon/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Brian Nesbitt",
"email": "brian@nesbot.com",
"homepage": "http://nesbot.com"
}
],
"description": "A simple API extension for DateTime.",
"homepage": "http://carbon.nesbot.com",
"keywords": [
"date",
"datetime",
"time"
],
"time": "2017-01-16T07:55:07+00:00"
},
{ {
"name": "paragonie/random_compat", "name": "paragonie/random_compat",
"version": "v2.0.10", "version": "v2.0.10",
@@ -829,34 +725,32 @@
"time": "2016-10-10T12:19:37+00:00" "time": "2016-10-10T12:19:37+00:00"
}, },
{ {
"name": "roots/sage-installer", "name": "roots/sage-lib",
"version": "1.0.0", "version": "9.0.0-beta.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/roots/sage-installer.git", "url": "https://github.com/roots/sage-lib.git",
"reference": "bd969d1a7c824ec7fe0579bf27181c9a729d8881" "reference": "d7789609eae857e910812cf62ae55355b836ad58"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/roots/sage-installer/zipball/bd969d1a7c824ec7fe0579bf27181c9a729d8881", "url": "https://api.github.com/repos/roots/sage-lib/zipball/d7789609eae857e910812cf62ae55355b836ad58",
"reference": "bd969d1a7c824ec7fe0579bf27181c9a729d8881", "reference": "d7789609eae857e910812cf62ae55355b836ad58",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"illuminate/console": "~5.4", "composer/installers": "~1.0",
"illuminate/filesystem": "~5.4", "illuminate/config": "~5.4",
"symfony/process": "~3.3" "illuminate/view": "~5.4",
"php": ">=5.6.4"
}, },
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": "^3.0" "squizlabs/php_codesniffer": "^2.8.0"
}, },
"bin": [
"bin/sage"
],
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Roots\\Sage\\Installer\\": "src/" "Roots\\Sage\\": ""
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@@ -875,17 +769,12 @@
"homepage": "https://github.com/qwp6t" "homepage": "https://github.com/qwp6t"
} }
], ],
"description": "Sage installer.", "description": "Library files for Sage Starter Theme",
"homepage": "https://roots.io/sage/",
"keywords": [ "keywords": [
"FontAwesome",
"bootstrap",
"foundation",
"sage",
"tachyons",
"theme",
"wordpress" "wordpress"
], ],
"time": "2017-07-01T22:49:02+00:00" "time": "2017-07-09T11:48:17+00:00"
}, },
{ {
"name": "soberwp/controller", "name": "soberwp/controller",
@@ -939,87 +828,18 @@
], ],
"time": "2017-06-25T13:13:49+00:00" "time": "2017-06-25T13:13:49+00:00"
}, },
{
"name": "symfony/console",
"version": "v3.3.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "70d2a29b2911cbdc91a7e268046c395278238b2e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/70d2a29b2911cbdc91a7e268046c395278238b2e",
"reference": "70d2a29b2911cbdc91a7e268046c395278238b2e",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/debug": "~2.8|~3.0",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"symfony/dependency-injection": "<3.3"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~3.3",
"symfony/dependency-injection": "~3.3",
"symfony/event-dispatcher": "~2.8|~3.0",
"symfony/filesystem": "~2.8|~3.0",
"symfony/http-kernel": "~2.8|~3.0",
"symfony/process": "~2.8|~3.0"
},
"suggest": {
"psr/log": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/filesystem": "",
"symfony/process": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Console\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2017-06-02T19:24:58+00:00"
},
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v3.3.2", "version": "v3.3.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/debug.git", "url": "https://github.com/symfony/debug.git",
"reference": "e9c50482841ef696e8fa1470d950a79c8921f45d" "reference": "63b85a968486d95ff9542228dc2e4247f16f9743"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/e9c50482841ef696e8fa1470d950a79c8921f45d", "url": "https://api.github.com/repos/symfony/debug/zipball/63b85a968486d95ff9542228dc2e4247f16f9743",
"reference": "e9c50482841ef696e8fa1470d950a79c8921f45d", "reference": "63b85a968486d95ff9542228dc2e4247f16f9743",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1062,11 +882,11 @@
], ],
"description": "Symfony Debug Component", "description": "Symfony Debug Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-06-01T21:01:25+00:00" "time": "2017-07-05T13:02:37+00:00"
}, },
{ {
"name": "symfony/finder", "name": "symfony/finder",
"version": "v3.3.2", "version": "v3.3.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/finder.git", "url": "https://github.com/symfony/finder.git",
@@ -1113,191 +933,18 @@
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-06-01T21:01:25+00:00" "time": "2017-06-01T21:01:25+00:00"
}, },
{
"name": "symfony/polyfill-mbstring",
"version": "v1.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "f29dca382a6485c3cbe6379f0c61230167681937"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f29dca382a6485c3cbe6379f0c61230167681937",
"reference": "f29dca382a6485c3cbe6379f0c61230167681937",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"time": "2017-06-09T14:24:12+00:00"
},
{
"name": "symfony/process",
"version": "v3.3.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "8e30690c67aafb6c7992d6d8eb0d707807dd3eaf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/8e30690c67aafb6c7992d6d8eb0d707807dd3eaf",
"reference": "8e30690c67aafb6c7992d6d8eb0d707807dd3eaf",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Process\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2017-05-22T12:32:03+00:00"
},
{
"name": "symfony/translation",
"version": "v3.3.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "dc3b2a0c6cfff60327ba1c043a82092735397543"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/dc3b2a0c6cfff60327ba1c043a82092735397543",
"reference": "dc3b2a0c6cfff60327ba1c043a82092735397543",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"symfony/config": "<2.8",
"symfony/yaml": "<3.3"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~2.8|~3.0",
"symfony/intl": "^2.8.18|^3.2.5",
"symfony/yaml": "~3.3"
},
"suggest": {
"psr/log": "To use logging capability in translator",
"symfony/config": "",
"symfony/yaml": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Translation\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2017-05-22T07:42:36+00:00"
},
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v3.3.2", "version": "v3.3.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/yaml.git", "url": "https://github.com/symfony/yaml.git",
"reference": "9752a30000a8ca9f4b34b5227d15d0101b96b063" "reference": "1f93a8d19b8241617f5074a123e282575b821df8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/9752a30000a8ca9f4b34b5227d15d0101b96b063", "url": "https://api.github.com/repos/symfony/yaml/zipball/1f93a8d19b8241617f5074a123e282575b821df8",
"reference": "9752a30000a8ca9f4b34b5227d15d0101b96b063", "reference": "1f93a8d19b8241617f5074a123e282575b821df8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1339,10 +986,173 @@
], ],
"description": "Symfony Yaml Component", "description": "Symfony Yaml Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-06-02T22:05:06+00:00" "time": "2017-06-15T12:58:50+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
{
"name": "illuminate/console",
"version": "v5.4.27",
"source": {
"type": "git",
"url": "https://github.com/illuminate/console.git",
"reference": "bdc5c6f53cb474e2aeec46b6a9999fcedfb62a4e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/console/zipball/bdc5c6f53cb474e2aeec46b6a9999fcedfb62a4e",
"reference": "bdc5c6f53cb474e2aeec46b6a9999fcedfb62a4e",
"shasum": ""
},
"require": {
"illuminate/contracts": "5.4.*",
"illuminate/support": "5.4.*",
"nesbot/carbon": "~1.20",
"php": ">=5.6.4",
"symfony/console": "~3.2"
},
"suggest": {
"guzzlehttp/guzzle": "Required to use the ping methods on schedules (~6.0).",
"mtdowling/cron-expression": "Required to use scheduling component (~1.0).",
"symfony/process": "Required to use scheduling component (~3.2)."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.4-dev"
}
},
"autoload": {
"psr-4": {
"Illuminate\\Console\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Console package.",
"homepage": "https://laravel.com",
"time": "2017-06-10T13:11:18+00:00"
},
{
"name": "nesbot/carbon",
"version": "1.22.1",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc",
"reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/translation": "~2.6 || ~3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~2",
"phpunit/phpunit": "~4.0 || ~5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.23-dev"
}
},
"autoload": {
"psr-4": {
"Carbon\\": "src/Carbon/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Brian Nesbitt",
"email": "brian@nesbot.com",
"homepage": "http://nesbot.com"
}
],
"description": "A simple API extension for DateTime.",
"homepage": "http://carbon.nesbot.com",
"keywords": [
"date",
"datetime",
"time"
],
"time": "2017-01-16T07:55:07+00:00"
},
{
"name": "roots/sage-installer",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/roots/sage-installer.git",
"reference": "837411acf1337d35e1b497c4ba3a8ed7cf6077fa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/roots/sage-installer/zipball/837411acf1337d35e1b497c4ba3a8ed7cf6077fa",
"reference": "837411acf1337d35e1b497c4ba3a8ed7cf6077fa",
"shasum": ""
},
"require": {
"illuminate/console": "~5.4",
"illuminate/filesystem": "~5.4",
"symfony/process": "~3.3"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.0"
},
"bin": [
"bin/sage"
],
"type": "library",
"autoload": {
"psr-4": {
"Roots\\Sage\\Installer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ben Word",
"email": "ben@benword.com",
"homepage": "https://github.com/retlehs"
},
{
"name": "QWp6t",
"email": "hi@qwp6t.me",
"homepage": "https://github.com/qwp6t"
}
],
"description": "Sage installer.",
"keywords": [
"FontAwesome",
"bootstrap",
"foundation",
"sage",
"tachyons",
"theme",
"wordpress"
],
"time": "2017-07-04T17:57:47+00:00"
},
{ {
"name": "squizlabs/php_codesniffer", "name": "squizlabs/php_codesniffer",
"version": "2.9.1", "version": "2.9.1",
@@ -1420,11 +1230,254 @@
"standards" "standards"
], ],
"time": "2017-05-22T02:43:20+00:00" "time": "2017-05-22T02:43:20+00:00"
},
{
"name": "symfony/console",
"version": "v3.3.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "a97e45d98c59510f085fa05225a1acb74dfe0546"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/a97e45d98c59510f085fa05225a1acb74dfe0546",
"reference": "a97e45d98c59510f085fa05225a1acb74dfe0546",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/debug": "~2.8|~3.0",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"symfony/dependency-injection": "<3.3"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~3.3",
"symfony/dependency-injection": "~3.3",
"symfony/event-dispatcher": "~2.8|~3.0",
"symfony/filesystem": "~2.8|~3.0",
"symfony/http-kernel": "~2.8|~3.0",
"symfony/process": "~2.8|~3.0"
},
"suggest": {
"psr/log": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/filesystem": "",
"symfony/process": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Console\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2017-07-03T13:19:36+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "f29dca382a6485c3cbe6379f0c61230167681937"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f29dca382a6485c3cbe6379f0c61230167681937",
"reference": "f29dca382a6485c3cbe6379f0c61230167681937",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"time": "2017-06-09T14:24:12+00:00"
},
{
"name": "symfony/process",
"version": "v3.3.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "5ab8949b682b1bf9d4511a228b5e045c96758c30"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/5ab8949b682b1bf9d4511a228b5e045c96758c30",
"reference": "5ab8949b682b1bf9d4511a228b5e045c96758c30",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Process\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2017-07-03T08:12:02+00:00"
},
{
"name": "symfony/translation",
"version": "v3.3.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "35dd5fb003c90e8bd4d8cabdf94bf9c96d06fdc3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/35dd5fb003c90e8bd4d8cabdf94bf9c96d06fdc3",
"reference": "35dd5fb003c90e8bd4d8cabdf94bf9c96d06fdc3",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"symfony/config": "<2.8",
"symfony/yaml": "<3.3"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~2.8|~3.0",
"symfony/intl": "^2.8.18|^3.2.5",
"symfony/yaml": "~3.3"
},
"suggest": {
"psr/log": "To use logging capability in translator",
"symfony/config": "",
"symfony/yaml": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Translation\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2017-06-24T16:45:30+00:00"
} }
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": {
"roots/sage-lib": 10,
"soberwp/controller": 20 "soberwp/controller": 20
}, },
"prefer-stable": false, "prefer-stable": false,

31
config/assets.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Assets Manifest
|--------------------------------------------------------------------------
|
| Your asset manifest is used by Sage to assist WordPress and your views
| with rendering the correct URLs for your assets. This is especially
| useful for statically referencing assets with dynamically changing names
| as in the case of cache-busting.
|
*/
'manifest' => get_theme_file_path().'/dist/assets.json',
/*
|--------------------------------------------------------------------------
| Assets Path URI
|--------------------------------------------------------------------------
|
| The asset manifest contains relative paths to your assets. This URI will
| be prepended when using Sage's asset management system. Change this if
| you are using a CDN.
|
*/
'uri' => get_theme_file_uri().'/dist',
];

32
config/theme.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Theme Directory
|--------------------------------------------------------------------------
|
| This is the absolute path to your theme directory.
|
| Example:
| /srv/www/example.com/current/web/app/themes/sage
|
*/
'dir' => get_theme_file_path(),
/*
|--------------------------------------------------------------------------
| Theme Directory URI
|--------------------------------------------------------------------------
|
| This is the web server URI to your theme directory.
|
| Example:
| https://example.com/app/themes/sage
|
*/
'uri' => get_theme_file_uri(),
];

51
config/view.php Normal file
View File

@@ -0,0 +1,51 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most template systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views.
|
*/
'paths' => [
get_theme_file_path().'/resources/views',
get_parent_theme_file_path().'/resources/views',
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the uploads
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => wp_upload_dir()['basedir'].'/cache',
/*
|--------------------------------------------------------------------------
| View Namespaces
|--------------------------------------------------------------------------
|
| Blade has an underutilized feature that allows developers to add
| supplemental view paths that may contain conflictingly named views.
| These paths are prefixed with a namespace to get around the conflicts.
| A use case might be including views from within a plugin folder.
|
*/
'namespaces' => [
// In your views use something like: @include(WC::some.view.or.partial.here)
'WC' => WP_PLUGIN_DIR.'/woocommerce/templates/',
],
];

View File

@@ -4,6 +4,9 @@
* Do not edit anything in this file unless you know what you're doing * Do not edit anything in this file unless you know what you're doing
*/ */
use Roots\Sage\Config;
use Roots\Sage\Container;
/** /**
* Helper function for prettying up errors * Helper function for prettying up errors
* @param string $message * @param string $message
@@ -74,21 +77,16 @@ array_map(function ($file) use ($sage_error) {
* ├── STYLESHEETPATH -> /srv/www/example.com/current/web/app/themes/sage/resources/views * ├── STYLESHEETPATH -> /srv/www/example.com/current/web/app/themes/sage/resources/views
* └── TEMPLATEPATH -> /srv/www/example.com/current/web/app/themes/sage/resources * └── TEMPLATEPATH -> /srv/www/example.com/current/web/app/themes/sage/resources
*/ */
if (is_customize_preview() && isset($_GET['theme'])) { array_map(
$sage_error(__('Theme must be activated prior to using the customizer.', 'sage')); 'add_filter',
} ['theme_file_path', 'theme_file_uri', 'parent_theme_file_path', 'parent_theme_file_uri'],
$sage_views = basename(dirname(__DIR__)).'/'.basename(__DIR__).'/views'; array_fill(0, 4, 'dirname')
add_filter('stylesheet', function () use ($sage_views) { );
return dirname($sage_views); Container::getInstance()
}); ->bindIf('config', function () {
add_filter('stylesheet_directory_uri', function ($uri) { return new Config([
return dirname($uri); 'assets' => require dirname(__DIR__).'/config/assets.php',
}); 'theme' => require dirname(__DIR__).'/config/theme.php',
if ($sage_views !== get_option('stylesheet')) { 'view' => require dirname(__DIR__).'/config/view.php',
update_option('stylesheet', $sage_views); ]);
if (php_sapi_name() === 'cli') { }, true);
return;
}
wp_redirect($_SERVER['REQUEST_URI']);
exit();
}