SlideShare a Scribd company logo
Terrific Composer
Makes your life easier…
Agenda

Concept

Terrific Composer
   ‣ Installation
   ‣ Twig
   ‣ Pages
   ‣ Modules & Skins
   ‣ Layout
   ‣ Dev -> Prod




Remo Brunschwiler   10. July 2012   #   3
Github
Take it. Make it better. Together.
Repositories

TerrificJS
   ‣ https://github.com/brunschgi/terrificjs

Terrific Composer (Symfony2 Edition)
   ‣ https://github.com/brunschgi/terrific-composer

Terrific Symfony2 Bundles
   ‣ https://github.com/brunschgi/TerrificCoreBundle
   ‣ https://github.com/brunschgi/TerrificComposerBundle




Remo Brunschwiler   10. July 2012                          #   5
Showcases
See Terrific in action
Remo Brunschwiler   14. August 2012   #   7
Concept
It’s really easy…
Hold on a minute!

Before we dive deeper into the Terrific Composer…




Remo Brunschwiler                                   #   9
Hold on a minute!

Before we dive deeper into the Terrific Composer…



Lets refresh our Terrific
knowledge!
http://www.slideshare.net/brunschgi/terrific-frontends




Remo Brunschwiler                                        #   9
Terrific Composer
Makes your life easier…
Terrific Composer

Frontend Development Framework
   ‣ Designed for building frontends / applications based on the
     Terrific concept
   ‣ Integrates TerrificJS
   ‣ Based on Symfony
   ‣ … still very young




Remo Brunschwiler   10. July 2012                                  #   11
Terrific Composer

Frontend Development Framework
   ‣ Designed for building frontends / applications based on the
     Terrific concept
   ‣ Integrates TerrificJS
   ‣ Based on Symfony
   ‣ … still very young



… melts dozens of best practices!




Remo Brunschwiler   10. July 2012                                  #   11
Documentation

Terrific Composer
   ‣ Unfortunately, a specific documentation does not exist yet
   ‣ Any help is gladly appreciated!!

Symfony Documentation
   ‣ http://symfony.com/doc/current/quick_tour/the_big_picture.html
     – quick tour
   ‣ http://symfony.com/doc/current/book/ – really great in-depth
     documentation!
   ‣ http://symfony.com/doc/current/cookbook/ – solutions and
     tutorials for common tasks
   ‣ http://symfony.com/doc/current/components/index.html –
     symfony components documentation



Remo Brunschwiler   10. July 2012                                   #   12
Installation
Very fast setup for your project!
Download it from: http://terrifically.org/composer/


 Installation




Remo Brunschwiler   10. July 2012                     # 14
Explore
… the sidebar and their possibilities
Create


                                    Add new Modules & Skins to your project.
                                    The Skeleton is generated for you so that
                                    you can start right away.




Remo Brunschwiler   10. July 2012                                        #   16
Open


                                    The Open dialog provides you fast access to
                                    all of your Modules and Pages.




Remo Brunschwiler   10. July 2012                                       #   17
Inspect


                                    The inspect mode shows you which modules
                                    are in use on the current page.




Remo Brunschwiler   10. July 2012                                    #   18
Twig
The flexible, fast, and secure template engine for PHP
Twig

Symfony comes with a powerful templating language called Twig
   ‣ http://symfony.com/doc/current/book/templating.html
   ‣ http://twig.sensiolabs.org/documentation



…I couldn’t have explained it better, so have a look at the links
above :-)




Remo Brunschwiler   10. July 2012                                   # 20
IDE Integration

Twig is a quite young project, but there is already support for
several IDEs:
   ‣ PhpStorm (native as of 2.1) – recommended!!
   ‣ Textmate via the Twig bundle
   ‣ Vim via the Jinja syntax plugin
   ‣ Netbeans via the Twig syntax plugin
   ‣ Eclipse via the Twig plugin
   ‣ Sublime Text via the Twig bundle
   ‣ Coda 2 via the other Twig syntax mode




Remo Brunschwiler   10. July 2012                                 #   21
Hands on!
Terrific Composer – Step by Step
Step by Step

Common Tasks
   ‣ Create a new page
   ‣ Create a new Module / Skin
   ‣ Create a new layout
   ‣ Development -> Productive




Remo Brunschwiler   10. July 2012   # 23
Pages
Play Lego!
… Let’s see it in action




Remo Brunschwiler   10. July 2012   # 25
Create a new page

Things to do
   1. Create a new or extend an existing controller
   2. Create an action in the controller
   3. Set annotations (@Template, @Route, @Composer)
   4. Create a view (twig file) in /Resources/views/




Remo Brunschwiler   10. July 2012                      # 26
1. Create / Extend Controller

<?php
namespace TerrificCompositionController;

use   SymfonyBundleFrameworkBundleControllerController;
use   TerrificComposerBundleAnnotationComposer;
use   SensioBundleFrameworkExtraBundleConfigurationRoute;
use   SensioBundleFrameworkExtraBundleConfigurationTemplate;

class DefaultController extends Controller
{
}

Things to consider
   ‣ PHP 5.3 namespace describes where the class is located
   ‣ Filename = ClassName, eg. DefaultController.php
     -> needed for classloading
   ‣ PHP 5.3 use statements for base controller and annotations


Remo Brunschwiler   10. July 2012                                  # 27
2. Create Action

class DefaultController extends Controller
{
    /**
      * @Composer("Welcome")
      * @Route("/", name="home")
      * @Template()
      */
    public function indexAction()
    {
         return array();
    }
}

Things to consider
   ‣ action name must end in Action
   ‣ return statement of an action is a Response object
     -> in our case it is and array: because of @Template()



Remo Brunschwiler   10. July 2012                             # 28
3. Set Annotations
/**
  * @Composer("Welcome")
  * @Route("/", name="home")
  * @Template()
  */
public function indexAction()
{
     return array();
}

@Composer(<name>)
   ‣ The given name will appear in the open dialog

@Route(“<path>”, name=”<name”)
   ‣ Describes the path under which the page is available
   ‣ For more options have a look at @Route

@Template()
   ‣ Specifies which template should be rendered (@Template documentation)



Remo Brunschwiler   10. July 2012                                      # 29
4. Create Twig View

/Resources/views/<ControllerName>/<actionName>.html.twig

   {% extends 'TerrificComposition::base.html.twig' %}

   {% block title %}Terrific Composer - Welcome{% endblock %}

   {% block body %}
   <div class="page">
     … here comes your stuff …
   </div>
   {% endblock %}



Things to consider
‣ Extend the layout of your choice
‣ Override / Extend the twig blocks you need


Remo Brunschwiler   10. July 2012                               # 30
Twig Blocks

Provided from TerrificCoreBundle::base.html.twig
   ‣ title – content of the <title> element
   ‣ meta – for meta tags (<meta charset="UTF-8"/> is always set)
   ‣ styles – the place for your stylesheets
   ‣ body_class – allows you to give your body a class
   ‣ composition – your content goes here
   ‣ jquery – jquery script element
   ‣ terrificjs – terrificjs script element
   ‣ scripts – the place for your javascripts
   ‣ bootstrap – the default terrificjs bootstrap



Remo Brunschwiler   10. July 2012                                   #   31
Hands on!

Create a new page that…
   ‣ is available under /workshop
   ‣ appears in the open dialog as “Workshop”
   ‣ has the same content as the homepage




Remo Brunschwiler   10. July 2012               # 32
Hands on!

Create a new page that…
   ‣ is available under /workshop
   ‣ appears in the open dialog as “Workshop”
   ‣ has the same content as the homepage

Enhance the page, so that…
   ‣ you can type an URL like /workshop/{title}
   ‣ the {title} is displayed as heading before the Intro module
   ‣ and if no title is given, “Terrific Composer” should be displayed
     instead




Remo Brunschwiler   10. July 2012                                    # 32
Twig Module Macro
{#
      Renders terrific modules.

      @param   name {String} name of the module
      @param   view {String} name of the view to render (without html.twig suffix) [optional]
      @param   skins {Array} contains the skins to apply [optional]
      @param   connectors {Array} contains the channel ids to connect to [optional]
      @param   attrs {Object} contains the additional html attributes for the module [optional]
      @param   data {Object} contains the data to pass to embedded controllers [optional]
#}
{% macro module(name, view, skins, connectors, attrs, data) %}



To consider
     ‣ Twig 1.x does not support things like:
      {{ tc.module('Intro', attrs={'data-name' : 'einstein'}) }}
      -> this is going to change with Twig 2.0



Remo Brunschwiler    10. July 2012                                                   # 33
Render Modules #1

Simple views without logic

{# this render the template with the same name (intro.html.twig) #}
{{ tc.module('Intro') }}

{# this renders the mrterrific template from the Hero Module #}
{{ tc.module('Hero', 'mrterrific')}}

{# the 3rd param is the Skins array, ie. Mr. Terrific is getting decorated
with the Stealth Skin #}
{{ tc.module('Hero', 'mrterrific', [ 'Stealth' ])}}

{# the 4th param is an array with communication channel ids, ie. all
modules with the same id can talk with each other #}
{{ tc.module('Hero', 'mrterrific', ['Stealth'], ['talk'])}}

{# the 5th param is the attrs object #}
{{ tc.module('Hero', 'mrterrific', null, null, { ‘data-name’ :
‘Mr. Terrific‘})}}


Remo Brunschwiler   10. July 2012                                       # 34
Render Modules #2

Complex views
‣ the concept is – thanks to TWIG – very simple
  http://symfony.com/doc/current/book/
  templating.html#embedding-controllers
‣ have their own controllers, actions & templates
‣ gives you Multi-MVC out-of-the-box
‣ are used rarely in plain “templating” projects


{{ tc.module('Filter','Filter:overspeed', null, null, null, {'segment':'washing'})}}

                embeds the view of the FilterController/   the data passed to the
                 overspeedAction in the Filter module         overspeedAction




Remo Brunschwiler   10. July 2012                                                   # 35
Hands on!

Enhance your workshop page, so that…
   ‣ only two of the heroes can talk with each other
   ‣ the {title} is rendered inside the speech bubble of Einstein




Remo Brunschwiler   10. July 2012                                   # 36
Modules & Skins
Get more flexibility…
What we want to achieve

Create a new «Victim» module, that…
   ‣ consists of a normal image (drowning man) & a background
     image (bubble)
   ‣ uses less for better code
   ‣ is able to call our heroes for help




Remo Brunschwiler   10. July 2012                               # 38
Markup

<div class="bubble">
    <span class="message">help!</span>
</div>
<img src="
  {{ asset("bundles/terrificmodulevictim/img/drowning-victim.png") }}
"/>
<a class="base" href="#help">Call for help!</a>


                                            links to image asset in /web/bundles/…


But how is the drowning-victim.png got there?
   ‣ The composer copies all module images on the fly to
     /web/bundles/<bundle>/img/ (configurable in config_dev.yml)

How did you come up with that path?
   ‣ Symfony standard: app/console assets:install


Remo Brunschwiler   10. July 2012                                           # 39
Import directive (mixins, variables etc.)
/* import.less */
@import "colors.less";
@import "mixins.less";

/* colors.less */
@text: #74AE00;               variable

/* mixins.less*/
.scale(@ratio) {             mixin function
  -webkit-transform:        scale(@ratio);
     -moz-transform:        scale(@ratio);
      -ms-transform:        scale(@ratio);
       -o-transform:        scale(@ratio);
          transform:        scale(@ratio);
}




Remo Brunschwiler   10. July 2012             # 40
/* @group Module: victim */
@import "../../../../../Composition/Resources/public/css/import.less";

@media screen {
                                           cascaded import – import.less has other imports
    .mod-victim {
        position: relative;

           .bubble {   nested rules -> .mod-victim .bubble { … }
               background: transparent url('../bubble.png') no-repeat 0 0;
               ...
           }
                   access variable             relative to less file
           .message {
               color: @text;
               font-size: 36 / 16em;
               ...
           }                 calculation
           ...
      }
}




Remo Brunschwiler   10. July 2012                                                 #   41
There is even more to less! Have a look at the documentation
   ‣ http://lesscss.org




Remo Brunschwiler   10. July 2012                              # 42
TerrificJS

on:function (callback) {
    var self = this,
        $ctx = this.$ctx;

      $('a', $ctx).on('click', function() {
          var message = $('.message', $ctx).text();

            self.fire('message', { name: 'drowner', message: message });

            return false;
      });

      callback();
}



Nothing special here, but mention the new naming of the hooks in
TerrificJS v2.0



Remo Brunschwiler   10. July 2012                                          # 43
Hands on!

Create a skin for your Victim that lets him drown when there is no
help from one of the heroes
   ‣ Create skin “Drown” for your Victim
   ‣ Write a simple drown functionality (eg. fadeOut)
   ‣ Trigger this functionality automatically after ~5 seconds
   ‣ Do not let your Victim drown when he calls for help within the
     given time frame




Remo Brunschwiler   10. July 2012                                     # 44
Layouts
Let’s say thanks to TWIG & Assetic
Layouts

A layouts job is to do stuff that is common to several pages
   ‣ javascripts
   ‣ styles
   ‣ meta tags
   ‣ header, footer, sidebar etc.

Thanks to TWIG & Assetic, layouts are no longer a big & inflexible
thing…




Remo Brunschwiler   10. July 2012                                    # 46
Twig Layout Approach

In Twig a layout is nothing more than an inherited template
   ‣ http://symfony.com/doc/current/book/templating.html#template-
     inheritance-and-layouts

In your page:                       this is your layout


   {% extends 'TerrificComposition::base.html.twig' %}

   {% block title %}Terrific Composer - Welcome{% endblock %}

   {% block body %}
   <div class="page">
     … here comes your stuff …
   </div>
   {% endblock %}




Remo Brunschwiler   10. July 2012                               # 47
Twig Layout Approach

In TerrificComposition::base.html.twig

{% extends 'TerrificCoreBundle::base.html.twig' %}          Terrific Core Layout

{% block title %}Terrific Composer{% endblock %}
…
{# content that is the same on every page goes into composition #}
{% block composition %}

{# your page content goes into body #}
{% block body %}    this block is overridden in your page
{% endblock %}

{% endblock %}
…




Remo Brunschwiler   10. July 2012                                                  # 48
Including JavaScripts

Symfony comes bundled with a very nice Assetic integration

Including JavaScripts has never been easier
                                     concatenates – and minifies in production
{% block scripts %}                       mode – all files in this directory
    {# here comes your scripts #}
    {% javascripts
    '@TerrificComposition/Resources/public/js/*.*'
    output='js/compiled/statics.js'      the name of the compiled file
    %}
        <script src="{{ asset_url }}" type="text/javascript"></script>
    {% endjavascripts %}

    {# scripts from parent (terrific core) layout #}
    {{ parent() }}      includes the content of the parent block
{% endblock %}




Remo Brunschwiler   10. July 2012                                                # 49
Including Stylesheets

… and the same for stylesheets
                                       concatenates – and minifies in production
                                             mode – all of the given files
{% 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"     the name of the compiled file
    %}
        <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}

    {# styles from parent (terrific core) layout #}
    {{ parent() }}      includes the content of the parent block
{% endblock %}




Remo Brunschwiler   10. July 2012                                                  # 50
Dev -> Prod
Prepare your assets for the real world
Productive

The productive version is…
   ‣ available under / (instead of /app_dev.php)

Dumping assets
   ‣ php app/console assets:install web

Compile CSS / JS
   ‣ php app/console assetic:dump --env=prod




Remo Brunschwiler   10. July 2012                  # 52
Questions?
More…
More…

Lets keep talking
   ‣ http://terrifically.org
   ‣ remo@terrifically.org
   ‣ https://github.com/brunschgi
   ‣ http://twitter.com/#!/brunschgi




Remo Brunschwiler   10. July 2012      # 55
Remo Brunschwiler   10. July 2012   # 56
Thank you!

More Related Content

What's hot

Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWest
Joshua Warren
 
Flutter movie apps tutor
Flutter movie apps tutorFlutter movie apps tutor
Flutter movie apps tutor
Herry Prasetyo
 
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and DockerDockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
pczarkowski
 
Creating Openbravo Workspace Widgets
Creating Openbravo Workspace WidgetsCreating Openbravo Workspace Widgets
Creating Openbravo Workspace Widgets
Rob Goris
 
Introduction to Continous Integration with WordPress
Introduction to Continous Integration with WordPressIntroduction to Continous Integration with WordPress
Introduction to Continous Integration with WordPress
Seagyn Davis
 
Asynchronous Programming at Netflix
Asynchronous Programming at NetflixAsynchronous Programming at Netflix
Asynchronous Programming at Netflix
C4Media
 
Maven 3.0 at Øredev
Maven 3.0 at ØredevMaven 3.0 at Øredev
Maven 3.0 at Øredev
Matthew McCullough
 

What's hot (7)

Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWest
 
Flutter movie apps tutor
Flutter movie apps tutorFlutter movie apps tutor
Flutter movie apps tutor
 
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and DockerDockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
 
Creating Openbravo Workspace Widgets
Creating Openbravo Workspace WidgetsCreating Openbravo Workspace Widgets
Creating Openbravo Workspace Widgets
 
Introduction to Continous Integration with WordPress
Introduction to Continous Integration with WordPressIntroduction to Continous Integration with WordPress
Introduction to Continous Integration with WordPress
 
Asynchronous Programming at Netflix
Asynchronous Programming at NetflixAsynchronous Programming at Netflix
Asynchronous Programming at Netflix
 
Maven 3.0 at Øredev
Maven 3.0 at ØredevMaven 3.0 at Øredev
Maven 3.0 at Øredev
 

Viewers also liked

德國氣球節
德國氣球節德國氣球節
德國氣球節
mapart
 
這些年.這些事
這些年.這些事這些年.這些事
這些年.這些事mapart
 
WL4 Firewall
WL4 FirewallWL4 Firewall
WL4 Firewall
cormacmcd
 
Developer sales staff amas power point presentation
Developer sales staff amas power point presentationDeveloper sales staff amas power point presentation
Developer sales staff amas power point presentation
LARRY FOSTER
 
Check mate infidelity test press release
Check mate infidelity test press releaseCheck mate infidelity test press release
Check mate infidelity test press release
Check Mate Test, LLC
 
VSTS in a nutshell for project lifecycle management
VSTS in a nutshell  for project lifecycle managementVSTS in a nutshell  for project lifecycle management
VSTS in a nutshell for project lifecycle management
Phanindra Kishore
 

Viewers also liked (6)

德國氣球節
德國氣球節德國氣球節
德國氣球節
 
這些年.這些事
這些年.這些事這些年.這些事
這些年.這些事
 
WL4 Firewall
WL4 FirewallWL4 Firewall
WL4 Firewall
 
Developer sales staff amas power point presentation
Developer sales staff amas power point presentationDeveloper sales staff amas power point presentation
Developer sales staff amas power point presentation
 
Check mate infidelity test press release
Check mate infidelity test press releaseCheck mate infidelity test press release
Check mate infidelity test press release
 
VSTS in a nutshell for project lifecycle management
VSTS in a nutshell  for project lifecycle managementVSTS in a nutshell  for project lifecycle management
VSTS in a nutshell for project lifecycle management
 

Similar to Terrific Composer Workshop

Tips and Tricks for Using Visual Studio.Net Effectively
Tips and Tricks for Using Visual Studio.Net EffectivelyTips and Tricks for Using Visual Studio.Net Effectively
Tips and Tricks for Using Visual Studio.Net Effectively
weili_at_slideshare
 
Chrome & Webkit overview
Chrome & Webkit overviewChrome & Webkit overview
Chrome & Webkit overview
Bin Chen
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
Terrific Frontends
Terrific FrontendsTerrific Frontends
Terrific Frontends
Remo Brunschwiler
 
Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0
André Moreira
 
web application.pptx
web application.pptxweb application.pptx
web application.pptx
vishal choudhary
 
Fewd week1 slides
Fewd week1 slidesFewd week1 slides
Fewd week1 slides
William Myers
 
CEF.net
CEF.netCEF.net
CEF.net
Cheng-Yi Yu
 
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Acquia
 
Untangling4
Untangling4Untangling4
Untangling4
Derek Jacoby
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
Laurence Svekis ✔
 
Makefile
MakefileMakefile
Makefile
Ionela
 
Desktop apps with node webkit
Desktop apps with node webkitDesktop apps with node webkit
Desktop apps with node webkit
Paul Jensen
 
His162013 140529214456-phpapp01
His162013 140529214456-phpapp01His162013 140529214456-phpapp01
His162013 140529214456-phpapp01
Getachew Ganfur
 
C++ for hackers
C++ for hackersC++ for hackers
C++ for hackers
Franciny Salles
 
Fewd week4 slides
Fewd week4 slidesFewd week4 slides
Fewd week4 slides
William Myers
 
Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdf
OKLABS
 
JavaScript Presentation Frameworks and Libraries
JavaScript Presentation Frameworks and LibrariesJavaScript Presentation Frameworks and Libraries
JavaScript Presentation Frameworks and Libraries
Oleksii Prohonnyi
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1
benDesigning
 
Web components Introduction
Web components IntroductionWeb components Introduction
Web components Introduction
Eugenio Romano
 

Similar to Terrific Composer Workshop (20)

Tips and Tricks for Using Visual Studio.Net Effectively
Tips and Tricks for Using Visual Studio.Net EffectivelyTips and Tricks for Using Visual Studio.Net Effectively
Tips and Tricks for Using Visual Studio.Net Effectively
 
Chrome & Webkit overview
Chrome & Webkit overviewChrome & Webkit overview
Chrome & Webkit overview
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
Terrific Frontends
Terrific FrontendsTerrific Frontends
Terrific Frontends
 
Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0
 
web application.pptx
web application.pptxweb application.pptx
web application.pptx
 
Fewd week1 slides
Fewd week1 slidesFewd week1 slides
Fewd week1 slides
 
CEF.net
CEF.netCEF.net
CEF.net
 
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
 
Untangling4
Untangling4Untangling4
Untangling4
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
 
Makefile
MakefileMakefile
Makefile
 
Desktop apps with node webkit
Desktop apps with node webkitDesktop apps with node webkit
Desktop apps with node webkit
 
His162013 140529214456-phpapp01
His162013 140529214456-phpapp01His162013 140529214456-phpapp01
His162013 140529214456-phpapp01
 
C++ for hackers
C++ for hackersC++ for hackers
C++ for hackers
 
Fewd week4 slides
Fewd week4 slidesFewd week4 slides
Fewd week4 slides
 
Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdf
 
JavaScript Presentation Frameworks and Libraries
JavaScript Presentation Frameworks and LibrariesJavaScript Presentation Frameworks and Libraries
JavaScript Presentation Frameworks and Libraries
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1
 
Web components Introduction
Web components IntroductionWeb components Introduction
Web components Introduction
 

Recently uploaded

What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
saastr
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 

Recently uploaded (20)

What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 

Terrific Composer Workshop

  • 1.
  • 3. Agenda Concept Terrific Composer ‣ Installation ‣ Twig ‣ Pages ‣ Modules & Skins ‣ Layout ‣ Dev -> Prod Remo Brunschwiler 10. July 2012 # 3
  • 4. Github Take it. Make it better. Together.
  • 5. Repositories TerrificJS ‣ https://github.com/brunschgi/terrificjs Terrific Composer (Symfony2 Edition) ‣ https://github.com/brunschgi/terrific-composer Terrific Symfony2 Bundles ‣ https://github.com/brunschgi/TerrificCoreBundle ‣ https://github.com/brunschgi/TerrificComposerBundle Remo Brunschwiler 10. July 2012 # 5
  • 7. Remo Brunschwiler 14. August 2012 # 7
  • 9. Hold on a minute! Before we dive deeper into the Terrific Composer… Remo Brunschwiler # 9
  • 10. Hold on a minute! Before we dive deeper into the Terrific Composer… Lets refresh our Terrific knowledge! http://www.slideshare.net/brunschgi/terrific-frontends Remo Brunschwiler # 9
  • 12. Terrific Composer Frontend Development Framework ‣ Designed for building frontends / applications based on the Terrific concept ‣ Integrates TerrificJS ‣ Based on Symfony ‣ … still very young Remo Brunschwiler 10. July 2012 # 11
  • 13. Terrific Composer Frontend Development Framework ‣ Designed for building frontends / applications based on the Terrific concept ‣ Integrates TerrificJS ‣ Based on Symfony ‣ … still very young … melts dozens of best practices! Remo Brunschwiler 10. July 2012 # 11
  • 14. Documentation Terrific Composer ‣ Unfortunately, a specific documentation does not exist yet ‣ Any help is gladly appreciated!! Symfony Documentation ‣ http://symfony.com/doc/current/quick_tour/the_big_picture.html – quick tour ‣ http://symfony.com/doc/current/book/ – really great in-depth documentation! ‣ http://symfony.com/doc/current/cookbook/ – solutions and tutorials for common tasks ‣ http://symfony.com/doc/current/components/index.html – symfony components documentation Remo Brunschwiler 10. July 2012 # 12
  • 15. Installation Very fast setup for your project!
  • 16. Download it from: http://terrifically.org/composer/ Installation Remo Brunschwiler 10. July 2012 # 14
  • 17. Explore … the sidebar and their possibilities
  • 18. Create Add new Modules & Skins to your project. The Skeleton is generated for you so that you can start right away. Remo Brunschwiler 10. July 2012 # 16
  • 19. Open The Open dialog provides you fast access to all of your Modules and Pages. Remo Brunschwiler 10. July 2012 # 17
  • 20. Inspect The inspect mode shows you which modules are in use on the current page. Remo Brunschwiler 10. July 2012 # 18
  • 21. Twig The flexible, fast, and secure template engine for PHP
  • 22. Twig Symfony comes with a powerful templating language called Twig ‣ http://symfony.com/doc/current/book/templating.html ‣ http://twig.sensiolabs.org/documentation …I couldn’t have explained it better, so have a look at the links above :-) Remo Brunschwiler 10. July 2012 # 20
  • 23. IDE Integration Twig is a quite young project, but there is already support for several IDEs: ‣ PhpStorm (native as of 2.1) – recommended!! ‣ Textmate via the Twig bundle ‣ Vim via the Jinja syntax plugin ‣ Netbeans via the Twig syntax plugin ‣ Eclipse via the Twig plugin ‣ Sublime Text via the Twig bundle ‣ Coda 2 via the other Twig syntax mode Remo Brunschwiler 10. July 2012 # 21
  • 24. Hands on! Terrific Composer – Step by Step
  • 25. Step by Step Common Tasks ‣ Create a new page ‣ Create a new Module / Skin ‣ Create a new layout ‣ Development -> Productive Remo Brunschwiler 10. July 2012 # 23
  • 27. … Let’s see it in action Remo Brunschwiler 10. July 2012 # 25
  • 28. Create a new page Things to do 1. Create a new or extend an existing controller 2. Create an action in the controller 3. Set annotations (@Template, @Route, @Composer) 4. Create a view (twig file) in /Resources/views/ Remo Brunschwiler 10. July 2012 # 26
  • 29. 1. Create / Extend Controller <?php namespace TerrificCompositionController; use SymfonyBundleFrameworkBundleControllerController; use TerrificComposerBundleAnnotationComposer; use SensioBundleFrameworkExtraBundleConfigurationRoute; use SensioBundleFrameworkExtraBundleConfigurationTemplate; class DefaultController extends Controller { } Things to consider ‣ PHP 5.3 namespace describes where the class is located ‣ Filename = ClassName, eg. DefaultController.php -> needed for classloading ‣ PHP 5.3 use statements for base controller and annotations Remo Brunschwiler 10. July 2012 # 27
  • 30. 2. Create Action class DefaultController extends Controller { /** * @Composer("Welcome") * @Route("/", name="home") * @Template() */ public function indexAction() { return array(); } } Things to consider ‣ action name must end in Action ‣ return statement of an action is a Response object -> in our case it is and array: because of @Template() Remo Brunschwiler 10. July 2012 # 28
  • 31. 3. Set Annotations /** * @Composer("Welcome") * @Route("/", name="home") * @Template() */ public function indexAction() { return array(); } @Composer(<name>) ‣ The given name will appear in the open dialog @Route(“<path>”, name=”<name”) ‣ Describes the path under which the page is available ‣ For more options have a look at @Route @Template() ‣ Specifies which template should be rendered (@Template documentation) Remo Brunschwiler 10. July 2012 # 29
  • 32. 4. Create Twig View /Resources/views/<ControllerName>/<actionName>.html.twig {% extends 'TerrificComposition::base.html.twig' %} {% block title %}Terrific Composer - Welcome{% endblock %} {% block body %} <div class="page"> … here comes your stuff … </div> {% endblock %} Things to consider ‣ Extend the layout of your choice ‣ Override / Extend the twig blocks you need Remo Brunschwiler 10. July 2012 # 30
  • 33. Twig Blocks Provided from TerrificCoreBundle::base.html.twig ‣ title – content of the <title> element ‣ meta – for meta tags (<meta charset="UTF-8"/> is always set) ‣ styles – the place for your stylesheets ‣ body_class – allows you to give your body a class ‣ composition – your content goes here ‣ jquery – jquery script element ‣ terrificjs – terrificjs script element ‣ scripts – the place for your javascripts ‣ bootstrap – the default terrificjs bootstrap Remo Brunschwiler 10. July 2012 # 31
  • 34. Hands on! Create a new page that… ‣ is available under /workshop ‣ appears in the open dialog as “Workshop” ‣ has the same content as the homepage Remo Brunschwiler 10. July 2012 # 32
  • 35. Hands on! Create a new page that… ‣ is available under /workshop ‣ appears in the open dialog as “Workshop” ‣ has the same content as the homepage Enhance the page, so that… ‣ you can type an URL like /workshop/{title} ‣ the {title} is displayed as heading before the Intro module ‣ and if no title is given, “Terrific Composer” should be displayed instead Remo Brunschwiler 10. July 2012 # 32
  • 36. Twig Module Macro {# Renders terrific modules. @param name {String} name of the module @param view {String} name of the view to render (without html.twig suffix) [optional] @param skins {Array} contains the skins to apply [optional] @param connectors {Array} contains the channel ids to connect to [optional] @param attrs {Object} contains the additional html attributes for the module [optional] @param data {Object} contains the data to pass to embedded controllers [optional] #} {% macro module(name, view, skins, connectors, attrs, data) %} To consider ‣ Twig 1.x does not support things like: {{ tc.module('Intro', attrs={'data-name' : 'einstein'}) }} -> this is going to change with Twig 2.0 Remo Brunschwiler 10. July 2012 # 33
  • 37. Render Modules #1 Simple views without logic {# this render the template with the same name (intro.html.twig) #} {{ tc.module('Intro') }} {# this renders the mrterrific template from the Hero Module #} {{ tc.module('Hero', 'mrterrific')}} {# the 3rd param is the Skins array, ie. Mr. Terrific is getting decorated with the Stealth Skin #} {{ tc.module('Hero', 'mrterrific', [ 'Stealth' ])}} {# the 4th param is an array with communication channel ids, ie. all modules with the same id can talk with each other #} {{ tc.module('Hero', 'mrterrific', ['Stealth'], ['talk'])}} {# the 5th param is the attrs object #} {{ tc.module('Hero', 'mrterrific', null, null, { ‘data-name’ : ‘Mr. Terrific‘})}} Remo Brunschwiler 10. July 2012 # 34
  • 38. Render Modules #2 Complex views ‣ the concept is – thanks to TWIG – very simple http://symfony.com/doc/current/book/ templating.html#embedding-controllers ‣ have their own controllers, actions & templates ‣ gives you Multi-MVC out-of-the-box ‣ are used rarely in plain “templating” projects {{ tc.module('Filter','Filter:overspeed', null, null, null, {'segment':'washing'})}} embeds the view of the FilterController/ the data passed to the overspeedAction in the Filter module overspeedAction Remo Brunschwiler 10. July 2012 # 35
  • 39. Hands on! Enhance your workshop page, so that… ‣ only two of the heroes can talk with each other ‣ the {title} is rendered inside the speech bubble of Einstein Remo Brunschwiler 10. July 2012 # 36
  • 40. Modules & Skins Get more flexibility…
  • 41. What we want to achieve Create a new «Victim» module, that… ‣ consists of a normal image (drowning man) & a background image (bubble) ‣ uses less for better code ‣ is able to call our heroes for help Remo Brunschwiler 10. July 2012 # 38
  • 42. Markup <div class="bubble"> <span class="message">help!</span> </div> <img src=" {{ asset("bundles/terrificmodulevictim/img/drowning-victim.png") }} "/> <a class="base" href="#help">Call for help!</a> links to image asset in /web/bundles/… But how is the drowning-victim.png got there? ‣ The composer copies all module images on the fly to /web/bundles/<bundle>/img/ (configurable in config_dev.yml) How did you come up with that path? ‣ Symfony standard: app/console assets:install Remo Brunschwiler 10. July 2012 # 39
  • 43. Import directive (mixins, variables etc.) /* import.less */ @import "colors.less"; @import "mixins.less"; /* colors.less */ @text: #74AE00; variable /* mixins.less*/ .scale(@ratio) { mixin function -webkit-transform: scale(@ratio); -moz-transform: scale(@ratio); -ms-transform: scale(@ratio); -o-transform: scale(@ratio); transform: scale(@ratio); } Remo Brunschwiler 10. July 2012 # 40
  • 44. /* @group Module: victim */ @import "../../../../../Composition/Resources/public/css/import.less"; @media screen { cascaded import – import.less has other imports .mod-victim { position: relative; .bubble { nested rules -> .mod-victim .bubble { … } background: transparent url('../bubble.png') no-repeat 0 0; ... } access variable relative to less file .message { color: @text; font-size: 36 / 16em; ... } calculation ... } } Remo Brunschwiler 10. July 2012 # 41
  • 45. There is even more to less! Have a look at the documentation ‣ http://lesscss.org Remo Brunschwiler 10. July 2012 # 42
  • 46. TerrificJS on:function (callback) { var self = this, $ctx = this.$ctx; $('a', $ctx).on('click', function() { var message = $('.message', $ctx).text(); self.fire('message', { name: 'drowner', message: message }); return false; }); callback(); } Nothing special here, but mention the new naming of the hooks in TerrificJS v2.0 Remo Brunschwiler 10. July 2012 # 43
  • 47. Hands on! Create a skin for your Victim that lets him drown when there is no help from one of the heroes ‣ Create skin “Drown” for your Victim ‣ Write a simple drown functionality (eg. fadeOut) ‣ Trigger this functionality automatically after ~5 seconds ‣ Do not let your Victim drown when he calls for help within the given time frame Remo Brunschwiler 10. July 2012 # 44
  • 48. Layouts Let’s say thanks to TWIG & Assetic
  • 49. Layouts A layouts job is to do stuff that is common to several pages ‣ javascripts ‣ styles ‣ meta tags ‣ header, footer, sidebar etc. Thanks to TWIG & Assetic, layouts are no longer a big & inflexible thing… Remo Brunschwiler 10. July 2012 # 46
  • 50. Twig Layout Approach In Twig a layout is nothing more than an inherited template ‣ http://symfony.com/doc/current/book/templating.html#template- inheritance-and-layouts In your page: this is your layout {% extends 'TerrificComposition::base.html.twig' %} {% block title %}Terrific Composer - Welcome{% endblock %} {% block body %} <div class="page"> … here comes your stuff … </div> {% endblock %} Remo Brunschwiler 10. July 2012 # 47
  • 51. Twig Layout Approach In TerrificComposition::base.html.twig {% extends 'TerrificCoreBundle::base.html.twig' %} Terrific Core Layout {% block title %}Terrific Composer{% endblock %} … {# content that is the same on every page goes into composition #} {% block composition %} {# your page content goes into body #} {% block body %} this block is overridden in your page {% endblock %} {% endblock %} … Remo Brunschwiler 10. July 2012 # 48
  • 52. Including JavaScripts Symfony comes bundled with a very nice Assetic integration Including JavaScripts has never been easier concatenates – and minifies in production {% block scripts %} mode – all files in this directory {# here comes your scripts #} {% javascripts '@TerrificComposition/Resources/public/js/*.*' output='js/compiled/statics.js' the name of the compiled file %} <script src="{{ asset_url }}" type="text/javascript"></script> {% endjavascripts %} {# scripts from parent (terrific core) layout #} {{ parent() }} includes the content of the parent block {% endblock %} Remo Brunschwiler 10. July 2012 # 49
  • 53. Including Stylesheets … and the same for stylesheets concatenates – and minifies in production mode – all of the given files {% 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" the name of the compiled file %} <link rel="stylesheet" href="{{ asset_url }}" /> {% endstylesheets %} {# styles from parent (terrific core) layout #} {{ parent() }} includes the content of the parent block {% endblock %} Remo Brunschwiler 10. July 2012 # 50
  • 54. Dev -> Prod Prepare your assets for the real world
  • 55. Productive The productive version is… ‣ available under / (instead of /app_dev.php) Dumping assets ‣ php app/console assets:install web Compile CSS / JS ‣ php app/console assetic:dump --env=prod Remo Brunschwiler 10. July 2012 # 52
  • 58. More… Lets keep talking ‣ http://terrifically.org ‣ remo@terrifically.org ‣ https://github.com/brunschgi ‣ http://twitter.com/#!/brunschgi Remo Brunschwiler 10. July 2012 # 55
  • 59. Remo Brunschwiler 10. July 2012 # 56