2017 © Pedro Pelรกez
 

library puzzle

Simple static sites with Laravel's Blade + Grunt + REST server.

image

lordoffreaks/puzzle

Simple static sites with Laravel's Blade + Grunt + REST server.

  • Friday, March 17, 2017
  • by lord_of_freaks
  • Repository
  • 1 Watchers
  • 0 Stars
  • 317 Installations
  • ApacheConf
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Puzzle

Puzzle is a simple static sites generator which also provides the oportunity to use REST endpoints for your forms (or any other type of endpoint you want to use)., (*1)

Uses Jigsaw to provide a template engine as Laravel's Blade and compile the resources to a static site., (*2)

Uses Grunt to automate tasks providing an effortless development experience and optimal frontend., (*3)

Getting Started

Installing Globally

  1. Install Puzzle globally via Composer:, (*4)

    $ composer global require lordoffreaks/puzzle, (*5)

    Make sure ~/.composer/vendor/bin is in your $PATH., (*6)

  2. Initialize a new project:, (*7)

    $ puzzle init my-site, (*8)

Installing Locally

If you run into dependency conflicts when trying to install Puzzle globally, you can always install it locally on a per site basis., (*9)

  1. Create a folder for your site:, (*10)

    $ mkdir my-site && cd my-site, (*11)

  2. Install Puzzle via Composer:, (*12)

    $ composer require lordoffreaks/puzzle, (*13)

  3. Initialize a new project in the current folder:, (*14)

    $ ./vendor/bin/puzzle init, (*15)

Building your first site

Building a Puzzle site is exactly like building a static HTML site, except that files ending in .blade.php will be rendered using Laravel's Blade Templating Language., (*16)

Build out your site however you like in the /source directory. It might look something like this:, (*17)

โ”œโ”€ source
โ”‚  โ”œโ”€ _assets
โ”‚  โ”œโ”€ _layouts
โ”‚  โ”‚  โ””โ”€ master.blade.php
โ”‚  โ”œโ”€ img
โ”‚  โ”‚  โ””โ”€ logo.png
โ”‚  โ”œโ”€ about-us.blade.php
โ”‚  โ””โ”€ index.blade.php
โ””โ”€ config.php

When you'd like to build it, run the build command from within your project root:, (*18)

$ puzzle build, (*19)

Your site will be built and placed in the /build_local directory by default., (*20)

Using the example structure above, you'd end up with something like this:, (*21)

โ”œโ”€ build_local
โ”‚  โ”œโ”€ about-us
โ”‚  โ”‚  โ””โ”€ index.html
โ”‚  โ”œโ”€ img
โ”‚  โ”‚  โ””โ”€ logo.png
โ”‚  โ””โ”€ index.html
โ”œโ”€ source
โ””โ”€ config.php

To quickly preview it, start a local PHP server:, (*22)

$ php -S localhost:8000/ -t build_local, (*23)

Layouts

One of the biggest benefits of a templating language is the ability to create reusable layouts., (*24)

Since it's important that a layout is never rendered on it's own, you need to be able to tell Jigsaw when a file shouldn't be rendered., (*25)

To prevent a file or folder from being rendered, simply prefix it with an underscore:, (*26)

โ”œโ”€ source
โ”‚  โ”œโ”€ _layouts
โ”‚  โ”‚  โ””โ”€ master.blade.php # Not rendered
โ”‚  โ””โ”€ index.blade.php     # Rendered
โ””โ”€ config.php

Config variables

Anything you add to the array in config.php will be made available as a variable in your templates., (*27)

For example, if your config looks like this..., (*28)

return [
    'contact_email' => 'support@example.com',
];

...you can use that variable in your templates like so:, (*29)

@extends('_layouts.master')

@section('content')


Contact us at {{ $contact_email }}, (*30)

@stop

Environments

You might have certain configuration variables that need to be different in different environments, like a Google Analytics tracking ID for example., (*31)

Puzzle lets you specify a different configuration file for each environment to handle this., (*32)

To create an environment-specific config file, just stick your environment name in front of the file extension:, (*33)

config.production.php, (*34)

To build your site for a specific environment, use the --env option:, (*35)

$ puzzle build --env=production, (*36)

Each environment gets it's own build_* folder, so in this case your site will be placed in build_production., (*37)

Note: Environment-specific config files are merged with the base config file, so you don't have to repeat values that don't need to change., (*38)

Pretty URLs

Puzzle will automatically take any Blade files not named index and render them as index.html in a subfolder with the same name as the original file., (*39)

For example, if you have a file named about-us.blade.php in your source directory:, (*40)

โ”œโ”€ source
   โ”œโ”€ _layouts
   โ”œโ”€ about-us.blade.php
   โ””โ”€ index.blade.php

...it will be rendered as index.html in the build/about-us directory:, (*41)

โ”œโ”€ build_local
   โ”œโ”€ about-us
   โ”‚  โ””โ”€ index.html 
   โ””โ”€ index.html

If you need to disable this behavior, use the --pretty=false option when building your site., (*42)

The Versions

17/03 2017

dev-master

9999999-dev http://github.com/lordoffreaks/puzzle

Simple static sites with Laravel's Blade + Grunt + REST server.

  Sources   Download

MIT

The Requires

 

laravel grunt rest generator blade static site

17/03 2017

0.3.5

0.3.5.0 http://github.com/lordoffreaks/puzzle

Simple static sites with Laravel's Blade + Grunt + REST server.

  Sources   Download

MIT

The Requires

 

laravel grunt rest generator blade static site

17/03 2017

0.3.4

0.3.4.0 http://github.com/lordoffreaks/puzzle

Simple static sites with Laravel's Blade + Grunt + REST server.

  Sources   Download

MIT

The Requires

 

laravel grunt rest generator blade static site

02/08 2016

0.3.3

0.3.3.0 http://github.com/lordoffreaks/puzzle

Simple static sites with Laravel's Blade + Grunt + REST server.

  Sources   Download

MIT

The Requires

 

laravel grunt rest generator blade static site

02/08 2016

0.3.2

0.3.2.0 http://github.com/lordoffreaks/puzzle

Simple static sites with Laravel's Blade + Grunt + REST server.

  Sources   Download

MIT

The Requires

 

laravel grunt rest generator blade static site

28/01 2016

0.3.0

0.3.0.0 http://github.com/lordoffreaks/puzzle

Simple static sites with Laravel's Blade + Grunt + REST server.

  Sources   Download

MIT

The Requires

 

laravel grunt rest generator blade static site

27/01 2016

0.2.0

0.2.0.0 http://github.com/lordoffreaks/puzzle

Simple static sites with Laravel's Blade + Grunt + REST server.

  Sources   Download

MIT

The Requires

 

laravel grunt rest generator blade static site

27/01 2016

0.1.0

0.1.0.0 http://github.com/lordoffreaks/puzzle

Simple static sites with Laravel's Blade + Grunt + REST server.

  Sources   Download

MIT

The Requires

 

laravel grunt rest generator blade static site