Giter Club home page Giter Club logo

terrificcorebundle's Introduction

TerrificCoreBundle

The TerrificCore bundle makes it easy to develop frontends based on the Terrific Concept. It provides you a good starting point and useful features (eg. additional assetic filters) to streamline your frontend development.

The TerrificCore bundle has no dependencies but works best in combination with the TerrificComposerBundle. For installation of the TerrificComposerBundle, please follow the instructions there.

Installation

TerrificCoreBundle can be conveniently installed via Composer. Just add the following to your composer.json file:

// composer.json
{
    // ...
    require: {
        // ...
        "brunschgi/terrific-core-bundle": "dev-master"
    }
}

Note: Please replace dev-master in the snippet above with the latest stable branch, for example 1.0.*. Please check the tags on Github for which versions are available. Then, you can install the new dependencies by running Composer’s update command from the directory where your composer.json file is located:

php composer.phar update

Now, Composer will automatically download all required files, and install them for you. All that is left to do is to update your AppKernel.php file, and register the new bundle:

// in AppKernel::registerBundles()
public function registerBundles()
{
    return array(
        // ...
        new Terrific\CoreBundle\TerrificCoreBundle(),
    );
}

Enable the new terrificrewrite filter in app/config/config.yml:

# app/config/config_dev.yml
# extend assetic filter configuration (rewrite of the backround image path in your terrific modules)
assetic:
    …
    filters:
        …
        terrificrewrite:
            resource: %kernel.root_dir%/../vendor/brunschgi/terrific-core-bundle/Terrific/CoreBundle/Resources/config/terrificrewrite.xml

Enable the bundle's configuration in app/config/config_dev.yml:

# app/config/config_dev.yml
terrific_core:
    copy_images: true # copy your module images on the fly without running `assets:install web`

Usage

To see the TerrificComposerCore in action, download the Terrific Composer Distribution and play around with the included examples. For more information about the Terrific Concept, please have a look at http://terrifically.org

After that, the below should be pretty straight forward ;-)

Base Layout

The base twig layout provides you everything you need to start with your Terrific project right away. Simple extend the base layout from your project layout:

{# eg. src/Terrific/Composition/Resources/views/base.html.twig #}
{% extends 'TerrificCoreBundle::base.html.twig' %}
...

The core layout provides you with several twig blocks to extend or overwrite. The most important ones are:

    {# main content of your page #}
    {% block composition %}here comes the content of the <body> element…{% endblock %}

    {# content of the <title> element #}
    {% block title %}Terrific Composer{% endblock %}

    {# placeholder for your meta tags (charset is always set to utf-8) #}
    {% block meta %}here comes your meta tags…{% endblock %}

    {# styles #}
    {% block styles %}
        {% stylesheets
            '@TerrificComposition/Resources/public/css/reset.less'
            '@TerrificComposition/Resources/public/css/grid.less'
            '@TerrificComposition/Resources/public/css/elements.less'
            output="css/compiled/project.css"
        %}
            <link rel="stylesheet" href="{{ asset_url }}" />
        {% endstylesheets %}

        {# styles from parent (terrific core) layout #}
        {{ parent() }}
    {% endblock %}

    {# scripts #}
    {% block scripts %}
        {% javascripts
            '../src/Terrific/Module/*/Resources/public/js/*.js'
            '../src/Terrific/Module/*/Resources/public/js/skin/*.js'
            output='js/compiled/base.js'
        %}
            <script src="{{ asset_url }}" type="text/javascript"></script>
        {% endjavascripts %}
    {% endblock %}

For a full list of available blocks, please have a look at @TerrificCoreBundle::base.html.twig.

Module Macro

Every Terrific Module is a separate bundle. The module macro makes it easy to mix and match them on your page. It works similar as the built-in twig helpers include and render and wraps your included / embedded module templates in the appropriate module <div>, eg. <div class="mod mod-news" data-connectors="update">... your template ...</div>.

Including Module Templates

{# wrap & include the view template /src/Terrific/Module/Teaser/Resources/views/default.html.twig #}
{{ tc.module('Teaser', 'default') }}

{# wrap & include the view template /src/Terrific/Module/Teaser/Resources/views/Concept/reusability.html.twig #}
{{ tc.module('Teaser', 'Concept/reusability') }}

Embedding Module Controller

If you are building not just templates but real applications with Terrific, it might be useful to delegate all the data stuff to the module itself so that you don't have to repeat yourself.

{# wrap & embed the module controller /src/Terrific/Module/Navigation/Controller/NavigationController.php -> mainAction #}
{{ tc.module('Navigation', 'Navigation:main') }}

The module macro can take some more parameters than just the module name and the view.

{% macro module(name, view, skins, connectors, attrs, data) %}

For more detailed infos, please have a look at Twig/Extension/terrificcore.html.twig.

That's it… Enjoy!

terrificcorebundle's People

Contributors

brunschgi avatar beatgeb avatar

Stargazers

Nikos M. avatar Bruno Lorenz avatar Martin Janser avatar Oliver Schmidt avatar  avatar

Watchers

Roger Dudler avatar James Cloos avatar

terrificcorebundle's Issues

Image copy problem

The image copying process sometimes crashes unexpectedly under heavy load.

'src=' anywhere inside JavaScript causes Internal Server Error 500

Whenever I use 'src=' anywhere inside a string in JavaScript, the generated .js file gets an Internal Server Error 500 containing the following message:

/*
[exception] 500 | Internal Server Error | ErrorException
[message] Notice: Uninitialized string offset: 0 in /Volumes/Namics/sew-eurodrive/vendor/brunschgi/terrific-core-bundle/Terrific/CoreBundle/Filter/TerrificRewriteFilter.php line 64
[1] ErrorException: Notice: Uninitialized string offset: 0 in /Volumes/Namics/sew-eurodrive/vendor/brunschgi/terrific-core-bundle/Terrific/CoreBundle/Filter/TerrificRewriteFilter.php line 64
                    at n/a
                    in /Volumes/Namics/sew-eurodrive/vendor/brunschgi/terrific-core-bundle/Terrific/CoreBundle/Filter/TerrificRewriteFilter.php line 64

                at Symfony\Component\HttpKernel\Debug\ErrorHandler-&gt;handle(&#039;8&#039;, &#039;Uninitialized string offset: 0&#039;, &#039;/Volumes/Namics/sew-eurodrive/vendor/brunschgi/terrific-core-bundle/Terrific/CoreBundle/Filter/TerrificRewriteFilter.php&#039;, &#039;64&#039;, array(&#039;matches&#039; =&gt; array(&#039;src=&#039;, &#039;&#039;, &#039;url&#039; =&gt; &#039;&#039;, &#039;&#039;), &#039;path&#039; =&gt; &#039;../../..&#039;, &#039;module&#039; =&gt; &#039;terrificmoduleteaser&#039;))
                    in /Volumes/Namics/sew-eurodrive/vendor/brunschgi/terrific-core-bundle/Terrific/CoreBundle/Filter/TerrificRewriteFilter.php line 64

                at Terrific\CoreBundle\Filter\TerrificRewriteFilter-&gt;Terrific\CoreBundle\Filter\{closure}(array(&#039;src=&#039;, &#039;&#039;, &#039;url&#039; =&gt; &#039;&#039;, &#039;&#039;))
                    in  line 

                at preg_replace_callback(&#039;/src=([&amp;quot;&amp;#039;]?)(?P&amp;lt;url&amp;gt;.*?)\1/&#039;, object(Closure), &#039;

This is produced with a console.log('src=')or $('<img src="/some/image/path" />') anywhere inside a Terrific module in the project.

Terrific Core Bundle version 1.0.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.