Epub: do not use twig namespaces when rendering templates
as this precludes the usage of customized templates per ebook
[WIP] Added a new 'chunk_level' option to 'html_chunked' format.

This option allows to improve the publication of complex books as
websites. The default value (`1`) is backwards-compatible and it
just publishes a single HTML page for each <h1> section.

The new `2` value allows to split each chapter/appendix into
several HTML pages, one for each <h1> and <h2> sections.

This is a work-in-progress feature. Therefore, the current code
is too complex (although it works), it's not documented (yet)
and it lacks (more) unit tests. To try it, just add the `chunk_level`
option in any edition:

book:
    # ...
    editions:
        my_edition:
            format:      html_chunked
            chunk_level: 2  # only 1 and 2 are allowed
Tweaked the previous commit /simplified the TOC generation and taken into
account that each book chunk can modify its own TOC)
Added images_base_dir option to set the base directory for web images.

It allows to serve the book images from a directory different from
the default `images/` directory.

See UPGRADE.md file for details.
Added initial support for books written in Japanese, Russian, Turkish,
Greek, Czech, LAtvian, Polish and Ukrainian.

Hopefully this will fix issue #92
[WIP] Tweaked the chunk process for books published as websites

This commit removes all the logic from the Twig templates and greatly
simplifies the generation of TOC and navigation URL. All the navigation
URLs are now generated as absolute instead of relative.

I still consider this feature as WIP because I need to try it with
more books and it needs to be properly documented and tested.
Refactored the Slugger class. Now you can set configuration
options globally (via Slugger constructor) and locally
(via slugify() method).

This allows to modify the slugger behaviour for your books. The
following example shows how to set '_' as the slug separator
instead of the default '-' value. You just have to create a method
that executes before the book publishing (in the future this simple
configuration modification will be much easier to perform):

<?php
// <your-book-dir>/Resources/Plugins/EasybookPlugin.php

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Easybook\Events\EasybookEvents as Events;
use Easybook\Events\BaseEvent;

class EasybookPlugin implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return array(
            Events::PRE_PUBLISH => array('onBookPrePublish'),
        );
    }

    public function onBookPrePublish(BaseEvent $event)
    {
        $sluggerOptions = array(
            'separator' => '_',
            'prefix'    => '',
            'unique'    => true
        );

        $event->app->set('slugger.options', $sluggerOptions);
    }
}
Merge pull request #88 from magabriel/fix-epub-tpl-namespace

Fixed usage of twig namespaces when rendering templates for epub books
Tweaked image URI generation.

easybook originally forced image URI to be prepend by a slash:

    $uri = rtrim($event->app->edition('images_base_dir'), '/\\').'/'.$uri;

This is correct for most cases, but sometimes the images of the
book already have a slash and 'images_base_dir' is empty, so
easybook ended up generating the following wrong URI:

    (empty 'images_base_dir') + / + /whatever/image.png = //whatever/image.png

easybook now doesn't include any slash or character by itself:

    $uri = $event->app->edition('images_base_dir').$uri;
Minor tweak to prevent a PHP notice in some rare occasions
Added 'publishing.book.toc' parameter to the container.

This parameter holds the real slug of the book being published.
Added 'app' global variable to 'renderString()' method.

Now every string rendered as Twig has access to every book
and edition configuration options.
[WIP] Added 'before_publish' and 'after_publish' options for book editions.

These options are modeled after Travis 'before_script' and 'after_script'
options and allow you to execute command/commands before or after
boo publishing without the need to define a custom plugin.

Use these options to update book contents before publishing (pulling
them from a repository) or for sending notifications after the
book is published. Each option admit an array of commands that are
executed sequentially:

book:
    title: '...'
    # ...

    editions:

        website:
            format:         html_chunked
            chunk_level:    2
            # ...
            before_publish:
                - echo "This command is executed before book publishing"
                - cp ...
                - git pull ...
            after_publish:
                - "/home/user/scripts/notify_book_publish.sh"
                - "/home/user/scripts/update_google_sitemap_xml.sh"

In addition, you can also indicate just one command per option by
using a string instead of an array:

book:
    # ...

    editions:

        website:
            # ...
            before_publish: "cd ... && git pull"
            after_publish:  "/home/user/scripts/notify_book_publish.sh"
Fixed navigation of books published as websites.

Next and previous elements are determined based on the URL, not
the slug. The URL is the only unique property of each book piece.