Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into coriander
Browse files Browse the repository at this point in the history
* upstream/master: (45 commits)
  Remove get_the_posts_navigation from 404
  Update config.json (roots#1963)
  Add friendly-errors-webpack-plugin (roots#1961)
  Move /controllers to app, remove app/lib/Sage in readme.
  Controller 9.0.0-beta.4
  Followup roots#1950: Fix lint:styles task with cmd.exe
  Change default Controller path to app/controllers
  Ensure to get templates filenames without path and extension.
  Fix lint:styles script not matching files in deep subdirectories
  Update helpers.php
  Update webpack.config.js (roots#1946)
  👀
  Bump sage-installer
  BS4 now requires Popper
  Bump sage-lib
  Bootstrap 4 Beta, Sage 9.0.0-beta.4
  Remove PHP 5.6 tests from Travis
  Update README.md
  Update sage-installer 1.1 -> 1.2
  Update CHANGELOG
  ...

# Conflicts:
#	package.json
#	resources/assets/build/postcss.config.js
#	resources/assets/build/webpack.config.js
#	resources/assets/styles/common/_global.scss
#	resources/assets/styles/common/_variables.scss
#	resources/assets/styles/components/_comments.scss
#	resources/assets/styles/components/_forms.scss
#	resources/assets/styles/components/_wp-classes.scss
#	resources/assets/styles/layouts/_header.scss
#	resources/assets/styles/main.scss
#	yarn.lock
  • Loading branch information
Patrick Vézina committed Sep 13, 2017
2 parents 1183355 + b4421be commit 1cd93c0
Show file tree
Hide file tree
Showing 61 changed files with 22,097 additions and 6,696 deletions.
43 changes: 0 additions & 43 deletions .eslintrc

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Include your project-specific ignores in this file
# Read about how to use .gitignore: https://help.github.com/articles/ignoring-files
.cache-loader
dist
bower_components
node_modules
npm-debug.log
yarn-error.log
vendor
resources/assets/config-local.json
3 changes: 0 additions & 3 deletions .stylelintrc

This file was deleted.

1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dist: trusty
php:
- 7.1
- 7.0
- 5.6
- nightly

env:
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
### 9.0.0-beta.4: August 11th, 2017
* Update to Bootstrap 4.0.0-beta ([#1943](https://github.com/roots/sage/pull/1943))
* PHP 7+ is now required ([#1935](https://github.com/roots/sage/pull/1935))
* Update dependencies, support `config-local.json`, implement autoload system for styles/scripts, use `roots/sage-installer`, use `roots/sage-lib` ([#1919](https://github.com/roots/sage/pull/1919))
* Add soberwp/controller ([#1903](https://github.com/roots/sage/pull/1903))
* Change syntax of template call to match other files in views ([#1908](https://github.com/roots/sage/pull/1908))
* Add Tachyons as a CSS framework option ([#1867](https://github.com/roots/sage/pull/1867))
* Remove post format reference in template call ([#1904](https://github.com/roots/sage/pull/1904))
* Update inline documentation to reflect correct theme file locations ([#1890](https://github.com/roots/sage/pull/1890))
* Optimize CSS Assets safe = true ([#1901](https://github.com/roots/sage/pull/1901))
* Update Autoprefixer and standardize browserlist location ([#1899](https://github.com/roots/sage/pull/1899))
* Do not redirect for WP-CLI ([#1891](https://github.com/roots/sage/pull/1891))
* Illuminate: container make with parameters ([#1888](https://github.com/roots/sage/pull/1888))
* Add Stylelint for linting stylesheets ([#1885](https://github.com/roots/sage/pull/1885))

### 9.0.0-beta.3: April 21st, 2017
* Move required theme files to `sage/resources` ([#1877](https://github.com/roots/sage/pull/1877))
* Move `src/` to `app/` ([#1868](https://github.com/roots/sage/pull/1868))
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Sage is a WordPress starter theme with a modern development workflow.
* [Controller](https://github.com/soberwp/controller) for passing data to Blade templates
* CSS framework options:
* [Bootstrap 4](http://getbootstrap.com/)
* [Bulma](http://bulma.io/)
* [Foundation](http://foundation.zurb.com/)
* [Tachyons](http://tachyons.io/)
* None (blank slate)
Expand All @@ -37,7 +38,7 @@ See a working example at [roots-example-project.com](https://roots-example-proje
Make sure all dependencies have been installed before moving on:

* [WordPress](https://wordpress.org/) >= 4.7
* [PHP](http://php.net/manual/en/install.php) >= 5.6.4
* [PHP](http://php.net/manual/en/install.php) >= 7.0
* [Composer](https://getcomposer.org/download/)
* [Node.js](http://nodejs.org/) >= 6.9.x
* [Yarn](https://yarnpkg.com/en/docs/install)
Expand All @@ -63,7 +64,7 @@ During theme installation you will have the options to:
```shell
themes/your-theme-name/ # → Root of your Sage based theme
├── app/ # → Theme PHP
│ ├── lib/Sage/ #Blade implementation, asset manifest
│ ├── controllers/ #Controller files
│ ├── admin.php # → Theme customizer setup
│ ├── filters.php # → Theme filters
│ ├── helpers.php # → Helper functions
Expand All @@ -81,7 +82,6 @@ themes/your-theme-name/ # → Root of your Sage based theme
│ │ ├── images/ # → Theme images
│ │ ├── scripts/ # → Theme JS
│ │ └── styles/ # → Theme stylesheets
│ ├── controllers/ # → Controller files
│ ├── functions.php # → Composer autoloader, theme includes
│ ├── index.php # → Never manually edit
│ ├── screenshot.png # → Theme screenshot for WP admin
Expand Down
File renamed without changes.
33 changes: 33 additions & 0 deletions app/controllers/App.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App;

use Sober\Controller\Controller;

class App extends Controller
{
public function siteName()
{
return get_bloginfo('name');
}

public static function title()
{
if (is_home()) {
if ($home = get_option('page_for_posts', true)) {
return get_the_title($home);
}
return __('Latest Posts', 'sage');
}
if (is_archive()) {
return get_the_archive_title();
}
if (is_search()) {
return sprintf(__('Search Results for %s', 'sage'), get_search_query());
}
if (is_404()) {
return __('Not Found', 'sage');
}
return get_the_title();
}
}
File renamed without changes.
28 changes: 14 additions & 14 deletions app/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,7 @@
'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home',
'frontpage', 'page', 'paged', 'search', 'single', 'singular', 'attachment'
])->map(function ($type) {
add_filter("{$type}_template_hierarchy", function ($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();
});
add_filter("{$type}_template_hierarchy", __NAMESPACE__.'\\filter_templates');
});

/**
Expand All @@ -59,12 +50,21 @@
$data = collect(get_body_class())->reduce(function ($data, $class) use ($template) {
return apply_filters("sage/template/{$class}/data", $data, $template);
}, []);
echo template($template, $data);
// Return a blank file to make WordPress happy
return get_theme_file_path('index.php');
if ($template) {
echo template($template, $data);
return get_stylesheet_directory().'/index.php';
}
return $template;
}, PHP_INT_MAX);

/**
* 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);
});
85 changes: 56 additions & 29 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
namespace App;

use Roots\Sage\Container;
use Illuminate\Contracts\Container\Container as ContainerContract;

/**
* Get the sage container.
*
* @param string $abstract
* @param array $parameters
* @param ContainerContract $container
* @return ContainerContract|mixed
* @SuppressWarnings(PHPMD.StaticAccess)
* @param Container $container
* @return Container|mixed
*/
function sage($abstract = null, $parameters = [], ContainerContract $container = null)
function sage($abstract = null, $parameters = [], Container $container = null)
{
$container = $container ?: Container::getInstance();
if (!$abstract) {
Expand Down Expand Up @@ -54,6 +52,10 @@ function config($key = null, $default = null)
*/
function template($file, $data = [])
{
if (remove_action('wp_head', 'wp_enqueue_scripts', 1)) {
wp_enqueue_scripts();
}

return sage('blade')->render($file, $data);
}

Expand All @@ -77,6 +79,55 @@ function asset_path($asset)
return sage('assets')->getUri($asset);
}

/**
* @param string|string[] $templates Possible template files
* @return array
*/
function filter_templates($templates)
{
$paths = apply_filters('sage/filter_templates/paths', [
'views',
'resources/views'
]);
$paths_pattern = "#^(" . implode('|', $paths) . ")/#";

return collect($templates)
->map(function ($template) use ($paths_pattern) {
/** Remove .blade.php/.blade/.php from template names */
$template = preg_replace('#\.(blade\.?)?(php)?$#', '', ltrim($template));

/** Remove partial $paths from the beginning of template names */
if (strpos($template, '/')) {
$template = preg_replace($paths_pattern, '', $template);
}

return $template;
})
->flatMap(function ($template) use ($paths) {
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
* @return bool
Expand All @@ -87,27 +138,3 @@ function display_sidebar()
isset($display) || $display = apply_filters('sage/display_sidebar', false);
return $display;
}

/**
* Page titles
* @return string
*/
function title()
{
if (is_home()) {
if ($home = get_option('page_for_posts', true)) {
return get_the_title($home);
}
return __('Latest Posts', 'sage');
}
if (is_archive()) {
return get_the_archive_title();
}
if (is_search()) {
return sprintf(__('Search Results for %s', 'sage'), get_search_query());
}
if (is_404()) {
return __('Not Found', 'sage');
}
return get_the_title();
}
41 changes: 0 additions & 41 deletions app/lib/Sage/Assets/JsonManifest.php

This file was deleted.

31 changes: 0 additions & 31 deletions app/lib/Sage/Assets/ManifestInterface.php

This file was deleted.

8 changes: 0 additions & 8 deletions app/lib/Sage/Config.php

This file was deleted.

Loading

0 comments on commit 1cd93c0

Please sign in to comment.