Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Static Sites With Sculpin (TrueNorth PHP November 2013)

Static Sites With Sculpin (TrueNorth PHP November 2013)

Uncon talk about static sites, static site generators, and Sculpin.

Beau Simensen

November 09, 2013
Tweet

More Decks by Beau Simensen

Other Decks in Programming

Transcript

  1. Static Sites With Sculpin
    True North PHP Uncon
    November 9th, 2013

    View Slide

  2. @beausimensen
    simensen on Freenode
    #sculpin

    View Slide

  3. View Slide

  4. beau.io/tnphp2013

    View Slide

  5. beau.io/tnphp2013
    sculpin generate --watch --server

    View Slide

  6. • Jekyll (Octopress) — jekyllrb.com
    • Phrozn — phrozn.info
    • PieCrust — bolt80.com/piecrust
    • Sculpin — sculpin.io
    • ... too many to count
    beau.io/tnphp2013

    View Slide

  7. What Are Static Sites?
    beau.io/tnphp2013

    View Slide

  8. What Are Static Sites?
    • Plain ol’ HTML files
    • XML, JSON, CSS, etc
    • Assets
    • Not interpretted
    beau.io/tnphp2013

    View Slide

  9. Why Static Sites?
    beau.io/tnphp2013

    View Slide

  10. Why Static Sites?
    • Few restrictions on server environment
    • Easy to deploy (scp, rsync, GitHub)
    • No database dependencies
    • Less things to break
    • Should absorb traffic bursts more easily
    beau.io/tnphp2013

    View Slide

  11. Why Built Yet Another
    Static Site Generator?
    beau.io/tnphp2013

    View Slide

  12. Why Built Yet Another
    Static Site Generator?
    • Not Invented Here is a hard habit to kick
    • Contributed to Jekyll and Octopress
    • Tried working with Phrozn
    • Somehow managed to miss PieCrust
    • Lurking in #symfony and #symfony-dev
    • Found Composer
    beau.io/tnphp2013

    View Slide

  13. Why Is Sculpin Special?
    beau.io/tnphp2013

    View Slide

  14. Why Is Sculpin Special?
    • Symfony’s Kernel
    • React’s HTTP Server
    • Embedded Composer
    • Twig
    beau.io/tnphp2013

    View Slide

  15. Twig
    Doing Inheritance “Right”
    beau.io/tnphp2013

    View Slide

  16. ---
    layout: default
    ---
    # This is a markdown file with YAML frontmatter
    beau.io/tnphp2013

    View Slide

  17. ---
    layout: default
    ---
    # This is a markdown file with YAML frontmatter
    {% extends "default" %}
    {% block content %}
    # This is a markdown file with YAML frontmatter
    {% endblock %}
    beau.io/tnphp2013

    View Slide

  18. ---
    layout: default
    special_value: nice
    ---
    # This is a markdown file with YAML frontmatter
    beau.io/tnphp2013

    View Slide


  19. {% if page.special_value is defined %}
    Special value exists and is
    {{ page.special_value }}!.
    {% endif %}
    {% block content %}Fallback content{% endblock %}

    ---
    layout: default
    special_value: nice
    ---
    # This is a markdown file with YAML frontmatter
    beau.io/tnphp2013

    View Slide


  20. {% if page.special_value is defined %}
    Special value exists and is
    {{ page.special_value }}!.
    {% endif %}
    {% block content %}Fallback content{% endblock %}

    ---
    layout: default
    special_value: nice
    ---
    # This is a markdown file with YAML frontmatter
    beau.io/tnphp2013

    Special value exists and is nice!.
    This is a markdown file with YAML frontmatter

    View Slide

  21. beau.io/tnphp2013
    page.[something]
    References YAML frontmatter

    View Slide

  22. beau.io/tnphp2013
    site.[something]
    References app/config/sculpin_site.yml Values

    View Slide

  23. beau.io/tnphp2013
    {% if page.full_title %}
    {{ page.full_title|raw }}
    {% else %}

    {{ page.title }} —
    {{ site.title }} —
    {{ site.subtitle }}

    {% endif %}

    View Slide

  24. beau.io/tnphp2013
    Lifecycle
    • Generate (Generators)
    • Permalink Creation
    • Convert
    • Format
    • Output

    View Slide

  25. beau.io/tnphp2013
    Events
    • Sculpin\Core\Sculpin::EVENT_BEFORE_RUN
    • Sculpin\Core\Sculpin::EVENT_AFTER_RUN
    • Sculpin\Core\Sculpin::EVENT_BEFORE_CONVERT
    • Sculpin\Core\Sculpin::EVENT_AFTER_CONVERT
    • Sculpin\Core\Sculpin::EVENT_BEFORE_FORMAT
    • Sculpin\Core\Sculpin::EVENT_AFTER_FORMAT

    View Slide

  26. beau.io/tnphp2013
    Symfony Bundles

    View Slide

  27. beau.io/tnphp2013
    Data Sources and
    Sources

    View Slide

  28. beau.io/tnphp2013
    Data Providers
    PostsBundle is a great example

    View Slide

  29. beau.io/tnphp2013
    Generators

    View Slide

  30. beau.io/tnphp2013
    Extensions

    View Slide

  31. beau.io/tnphp2013
    Extensions
    Look at PostsBundle :)

    View Slide

  32. beau.io/tnphp2013
    Community
    #sculpin on Freenode
    @getsculpin

    View Slide

  33. Thanks!
    beau.io/tnphp2013
    @getsculpin
    @beausimensen

    View Slide