2017 © Pedro Peláez
 

library lassy

Lazy static site generator for Laravel4

image

radmen/lassy

Lazy static site generator for Laravel4

  • Monday, May 5, 2014
  • by radmen
  • Repository
  • 1 Watchers
  • 11 Stars
  • 23 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

About

Build Status, (*1)

Lassy is lazy static site generator. It means that every request (well not every.. check out Filters section) will generate a HTML file with its contents inside., (*2)

Every next request will be redirected to this file., (*3)

Installation

Add radmen/lassy to composer.json:, (*4)

{
  "require": {
    "radmen/lassy": "1.1.*"
   }
}

Then in app/config/app.php add:, (*5)

  • 'Radmen\Lassy\LassyServiceProvider' to providers
  • 'Lassy' => 'Radmen\Lassy\Facade' to aliases

And publish config: php artisan config:publish radmen/lassy, (*6)

Rewrites

Lassy only genereates HTML files. All requests must be rewrited to this files. Here are some example configs for such rewrites., (*7)

Note that _static is only example dirname. It can be changed in config file., (*8)

Apache

RewriteCond %{DOCUMENT_ROOT}/_static/%{REQUEST_URI} -f
RewriteRule ^(.*)$ /_static/$1 [QSA,PT,L]

RewriteCond %{DOCUMENT_ROOT}/_static/%{REQUEST_URI}/index.html -f
RewriteRule ^(.*)$ /_static/$1/index.html [QSA,PT,L]

Laravel

If you have problem with server rewrites (it happens to me all the time) you can serve static files through Laravel application., (*9)

In app/filters.php add:, (*10)

App::before(function($request)
{
  $path = Lassy::getFilePath($request);

  if(true === is_file($path)) 
  {
    Lassy::disable();
    return file_get_contents($path);
  }
});

Filters

In some situations static file should not be generated. That's where filters come in action.
Filter is closure which returns boolean. If it's FALSE Lassy will be disabled., (*11)

Lassy provides some basic filters:, (*12)

  • Radmen\Lassy\Filter\AjaxRequest checks if request is an AJAX call. If TRUE disable Lassy
  • Radmen\Lassy\Filter\GetRequest enables Lassy only for GET requests
  • Radmen\Lassy\Filter\HtmlResponse enables Lassy only for valid (response code = 200) HTML responses
  • Radmen\Lassy\Filter\QueriedRequest disables Lassy when request has data in query

Filters can be specified in package config file., (*13)

Lassy can be enabled / disabled manually during the request. To do this run Lassy::enable(), or Lassy::disable() in your code., (*14)

Clearing files

If you want to delete generated files just run php artisan lassy:clear in console., (*15)

License

The Lassy package is open-sourced software licensed under the MIT license., (*16)

The Versions

05/05 2014

dev-master

9999999-dev

Lazy static site generator for Laravel4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Radoslaw Mejer

laravel generator static

05/05 2014

1.1.0

1.1.0.0

Lazy static site generator for Laravel4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Radoslaw Mejer

laravel generator static

25/07 2013

1.0.2

1.0.2.0

Lazy static site generator for Laravel4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Radoslaw Mejer

laravel generator static

24/07 2013

1.0.1

1.0.1.0

Lazy static site generator for Laravel4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Radoslaw Mejer

laravel generator static

23/07 2013

1.0.0

1.0.0.0

Lazy static site generator for Laravel4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Radoslaw Mejer

laravel generator static