SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
Zotonic




A modern web framework and CMS


Arjan Scherpenisse
MiracleThings
arjan@miraclethings.nl
Overview


    Yet another CMS?
   Why Erlang?

    Inside Zotonic
   The future
Websites: a history


    First generation
       static text, images

    Second generation
       Database driven, templates, CMS.

    Now:
       Highly interactive, realtime, data exchange,
        personalization
Our wish list


    CMS
   Framework

    Connectivity
   Frontender friendly

    Efficient use of hardware
Now: <?php ?>


    Slow
       More code => slower

    Shared nothing
       Amnesia doesn't make it faster

    Big non threaded web server
       Forget long living connections...
Now: Python, Ruby...


    One process per core
   Multithreading? Better not

    No sharing of state and data
   Memcache is common state

    On failure your server crashes
Erlang?


    Website is communication hub
   Many kinds of data streams

    Many Parallel connections
   Lots of short requests

    Long living connections
   …this looks like a phone switch!
Why not Erlang?


    Esoteric language
       Greate error/failure handling
       Very compact
       Mature

    String processing?
       Data preprocessing, iolist()s
Demo time!
So, what's in the box?


    Multiple sites            
                                  Integrated e-mail
   Admin interface               sending + receiving (!)

    Member administration
                                 API OAuth
   Page management
                                 i18n

    Menu creator
                                 Atom feeds
   Commenting
                                 Import CSV /
                                  Wordpress
   Image scaling / preview   
                                  Mailinglist
   Video embedding
Getting technical


    Where we started
   Our data model

    Open source puzzle
   OTP hierarchy

    Modules
   URL dispatching
   The building blocks
Data model: everything is a thing

                    Article
                     Article




           author              depiction




          Person
           Person                Image
                                  Image
Full data model

                                                 identity
                                                   identity



                                                 medium
                                                  medium
    config
     config

                            rsc
                             rsc
                                                category
                                                 category
   persistent
    persistent
                       predicate
                                                 protect
                                                  protect
    module        subject          object
     module

                                            predicate_category
                                             predicate_category
                            edge
                             edge
Open source puzzle


    Webmachine
       Forked to webzmachine

    Nitrogen
   ErlyDTL

    Mochiweb, erlang-gettext, erlang-oauth, gen_smtp
   PostgreSQL driver: epgsql
   Imagemagick (cli)
Diagram


                      Modules
                       Modules



      Zotonic core
       Zotonic core   Sites
                       Sites           Webmachine
                                        Webmachine



      epgsql
       epgsql                  Webmachine
                                Webmachine
OTP hierarchy
                              zotonic.app




                              zotonic_sup




z_email_receive               z_sites_sup       wm_mochiweb_*       dispatcher          z_config                     z_ids



            z_email_server                                                                         z_media_preview



                             z_sites_sup
                              z_sites_sup
                                z_sites_sup
                                                                         z_pivot_rsc         z_dropbox                 z_installer




       z_depcache        z_module_manager          z_site_startup         z_session         z_template               z_trans_server



                                                                                            z_dispatcher         z_module_indexer
                             z_sites_sup
                              z_sites_sup
                             Module processes                       z_session_page
                                                                      z_session_page
                                                                       z_session_page                                  z_notifier
Modules


    Modules are self-contained:
        Dispatch rules, resources, templates, css, javascript,
         images, translations, template filters, actions, validators,
         API services, models, …
   Prioritized list
   File lookup mechanism
   Every module can be a gen_server
Notification system
   Is how modules extend and offer functionality
   gen_event-like
   Listen to notifications
   Send notifications:
       notify, notify1, fold, map, first
       Both sync and async
% @doc Check if the recipient is a known user, if so redirect the received e-
mail
observe_email_received(#email_received{localpart=Recipient} = Received,
Context) ->
     case m_identity:lookup_by_username(Recipient, Context) of
         undefined ->
             undefined;
         Props ->
             case proplists:get_value(is_verified, Props) of
                  true ->
URL dispatching


    Dispatch rules per site
       (and per module)

    Dispatch rules have names

    {contact,     [“contact”],   resource_template, [ {template,
    "contact.tpl"} ]},
The page controller


    Webmachine entrypoint for pages
   404 check

    Authorization check + logon redirect
   Template selection
Template system


    Extended ErlyDTL
       Expressions: {% if a + b > c %}
       Tuple and list data types
       Data access through models: {{ m.rsc[id].title }}

    Templates can be made more specific by category
    and/or unique page name
   Templates with the same name override each
    other
       Uses module priority
Template ex.: page.page_projects.tpl
{% extends "page.tpl" %}

{% block content_body %}
{% cache 7200 %}

{% for r in m.search[{archive_year cat='project'}] %}
    <div class="grid_9 alpha omega">
        <h2 class="year">{{ r.year }}</h2>
    </div>

   {% for group in m.search[{query publication_year=r.year|append:""
                         cat='project'
                         sort="-publication_start"}]|chunk:3 %}

    <div class="grid_9 alpha omega">

        {% for id in group %}
        {% catinclude "inc/listitem.tpl" id alpha=forloop.first
omega=forloop.last%}
        {% endfor %}

   </div>
   {% endfor %}

{% endfor %}

{% endcache %}
{% endblock %}
Scomps — screen components


    For when you need more logic than a template can
    handle
   Erlang module
   Cacheable
   Example: {% menu id=id %}
Javascript — Event handling


    Ajax postbacks
   Form submits

    Calls event/2 function
   Communicates back to browser by sending
    javascript
       Inspired by Nitrogen

{% button postback={click foo=”bar”} text=”click me” %}


event({postback, {click, Args}, _Trigger, _Target}, Context) ->
z_render:wire({alert, [{text,”hello”}]}, Context).
Javascript — Push connections


    Uses either Comet or WebSockets
   Attaches to the page process

    Transports Javascript to the UA
API services


    API method is an Erlang module
   /api/mymodule/mymethod

    In /services module directory
   JSON input / output

    Process GET and POST
Performance optimizations


    Caching (don't hit the database)
   Prevent data copying

    Memo-caching in process dict
   Pre-computed HTML

    Share computations between requests
Compute less


    Parallel requests have similar computations
   Only one time calculated

    Lightweight and simple optimization against /.
    effect
   Uses memo functionality of depcache
   Kind of caching, with 0 expire.
Future directions


    Information exchange hub
       PubSub (XMPP, pubsubhubub)
       Push & pull (feeds, atom, email)
   Scaling up.... Elastic Zotonic
       Distributed
       Fault tolerant
       Buzzword compliancy :-)
Elastic Zotonic goals


    Scalable
   Robust

    Fault tolerant
   Low maintainance

    Easy to setup
   KISS
   Time scale: first release Q4 2011
The community


    www.zotonic.com — always improving with latest
    documentation
   Great mailing list with helpful people
       zotonic-users@groups.google.com
   XMPP chat room
       zotonic@conference.zotonic.com
Thank you!


    Online resources:
       MiracleThings website
        http://miraclethings.nl/media/attachment/2011/8/13/arjan_miraclethings_789d763.zip
        Presentation slides
        http://miraclethings.nl/media/attachment/2011/8/13/20110813_erlangcamp.pdf

   … any questions?

Contenu connexe

Tendances

ActiveMQ Configuration
ActiveMQ ConfigurationActiveMQ Configuration
ActiveMQ Configuration
Ashish Mishra
 

Tendances (10)

ActiveMQ Configuration
ActiveMQ ConfigurationActiveMQ Configuration
ActiveMQ Configuration
 
스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용
스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용
스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용
 
J2 Ee Overview
J2 Ee OverviewJ2 Ee Overview
J2 Ee Overview
 
JavaOne 2010: OSGI Migrat
JavaOne 2010: OSGI MigratJavaOne 2010: OSGI Migrat
JavaOne 2010: OSGI Migrat
 
What's new in JMS 2.0 - OTN Bangalore 2013
What's new in JMS 2.0 - OTN Bangalore 2013What's new in JMS 2.0 - OTN Bangalore 2013
What's new in JMS 2.0 - OTN Bangalore 2013
 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
 
Wakanda: a new end-to-end JavaScript platform - JSConf Berlin 2009
Wakanda: a new end-to-end JavaScript platform - JSConf Berlin 2009Wakanda: a new end-to-end JavaScript platform - JSConf Berlin 2009
Wakanda: a new end-to-end JavaScript platform - JSConf Berlin 2009
 
Gentle Intro to Drupal Code
Gentle Intro to Drupal CodeGentle Intro to Drupal Code
Gentle Intro to Drupal Code
 
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGThe Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
 
Java Web Programming [7/9] : Struts2 Basics
Java Web Programming [7/9] : Struts2 BasicsJava Web Programming [7/9] : Struts2 Basics
Java Web Programming [7/9] : Struts2 Basics
 

En vedette

Arava Sites By Guy
Arava Sites By GuyArava Sites By Guy
Arava Sites By Guy
GZ-Israel
 
Israelair Photos 1214209899278185 8
Israelair Photos 1214209899278185 8Israelair Photos 1214209899278185 8
Israelair Photos 1214209899278185 8
GZ-Israel
 
Israel 1214781329718633 9
Israel 1214781329718633 9Israel 1214781329718633 9
Israel 1214781329718633 9
GZ-Israel
 
Alice Quick Guide
Alice Quick GuideAlice Quick Guide
Alice Quick Guide
KJSROSE
 
The State Of Israel And The Muslim World 22166
The State Of Israel And The Muslim World 22166The State Of Israel And The Muslim World 22166
The State Of Israel And The Muslim World 22166
GZ-Israel
 

En vedette (20)

Android workshop
Android workshopAndroid workshop
Android workshop
 
El Pueblo Gallego 1948
El Pueblo Gallego 1948El Pueblo Gallego 1948
El Pueblo Gallego 1948
 
O Meu Pequeno Pais
O Meu Pequeno PaisO Meu Pequeno Pais
O Meu Pequeno Pais
 
Seica o basilisco é animal de compaña
Seica o basilisco é animal de compañaSeica o basilisco é animal de compaña
Seica o basilisco é animal de compaña
 
Arava Sites By Guy
Arava Sites By GuyArava Sites By Guy
Arava Sites By Guy
 
Israelair Photos 1214209899278185 8
Israelair Photos 1214209899278185 8Israelair Photos 1214209899278185 8
Israelair Photos 1214209899278185 8
 
IPsec
IPsecIPsec
IPsec
 
Israel 1214781329718633 9
Israel 1214781329718633 9Israel 1214781329718633 9
Israel 1214781329718633 9
 
Tel Aviv 1920 1940
Tel Aviv 1920 1940Tel Aviv 1920 1940
Tel Aviv 1920 1940
 
Tweets polls surveys
Tweets polls surveysTweets polls surveys
Tweets polls surveys
 
Mark Chagall
Mark ChagallMark Chagall
Mark Chagall
 
Hello, world
Hello, worldHello, world
Hello, world
 
Alice Quick Guide
Alice Quick GuideAlice Quick Guide
Alice Quick Guide
 
Mediamatic Night Lab #2
Mediamatic Night Lab #2Mediamatic Night Lab #2
Mediamatic Night Lab #2
 
Road
RoadRoad
Road
 
O mar desde esa banda. De Carlos Penela
O mar desde esa banda. De Carlos PenelaO mar desde esa banda. De Carlos Penela
O mar desde esa banda. De Carlos Penela
 
Duo Disco - doing the Erlang dance
Duo Disco - doing the Erlang danceDuo Disco - doing the Erlang dance
Duo Disco - doing the Erlang dance
 
The State Of Israel And The Muslim World 22166
The State Of Israel And The Muslim World 22166The State Of Israel And The Muslim World 22166
The State Of Israel And The Muslim World 22166
 
Rami Meiri
Rami MeiriRami Meiri
Rami Meiri
 
Maketechwork4u
Maketechwork4uMaketechwork4u
Maketechwork4u
 

Similaire à Zotonic presentation Erlang Camp Boston, august 2011

Flu3nt highlights
Flu3nt highlightsFlu3nt highlights
Flu3nt highlights
dswork
 
Cloud Best Practices
Cloud Best PracticesCloud Best Practices
Cloud Best Practices
Eric Bottard
 
Architecting non-trivial browser applications (Jazoon 2012)
Architecting non-trivial browser applications (Jazoon 2012)Architecting non-trivial browser applications (Jazoon 2012)
Architecting non-trivial browser applications (Jazoon 2012)
Marc Bächinger
 
Web app and more
Web app and moreWeb app and more
Web app and more
faming su
 
Gordon Semantic Web 2008
Gordon Semantic Web 2008Gordon Semantic Web 2008
Gordon Semantic Web 2008
bosc_2008
 

Similaire à Zotonic presentation Erlang Camp Boston, august 2011 (20)

Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8
 
Intro to-html-backbone
Intro to-html-backboneIntro to-html-backbone
Intro to-html-backbone
 
Node.js for enterprise - JS Conference
Node.js for enterprise - JS ConferenceNode.js for enterprise - JS Conference
Node.js for enterprise - JS Conference
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh Gundecha
 
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
 
Flu3nt highlights
Flu3nt highlightsFlu3nt highlights
Flu3nt highlights
 
Virtual Classroom
Virtual ClassroomVirtual Classroom
Virtual Classroom
 
Cloud Best Practices
Cloud Best PracticesCloud Best Practices
Cloud Best Practices
 
Architecting non-trivial browser applications (Jazoon 2012)
Architecting non-trivial browser applications (Jazoon 2012)Architecting non-trivial browser applications (Jazoon 2012)
Architecting non-trivial browser applications (Jazoon 2012)
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutions
 
Introducing spring
Introducing springIntroducing spring
Introducing spring
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Web app and more
Web app and moreWeb app and more
Web app and more
 
JS Single-Page Web App Essentials
JS Single-Page Web App EssentialsJS Single-Page Web App Essentials
JS Single-Page Web App Essentials
 
Gordon Semantic Web 2008
Gordon Semantic Web 2008Gordon Semantic Web 2008
Gordon Semantic Web 2008
 
Java Framework for Database-Centric Web Engineering
Java Framework for Database-Centric Web EngineeringJava Framework for Database-Centric Web Engineering
Java Framework for Database-Centric Web Engineering
 
Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2
 
Vue.js basics
Vue.js basicsVue.js basics
Vue.js basics
 
Reversing & malware analysis training part 2 introduction to windows internals
Reversing & malware analysis training part 2   introduction to windows internalsReversing & malware analysis training part 2   introduction to windows internals
Reversing & malware analysis training part 2 introduction to windows internals
 

Plus de Arjan (7)

De Naakte Noorderlingen
De Naakte NoorderlingenDe Naakte Noorderlingen
De Naakte Noorderlingen
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & Performance
 
Zotonic tutorial EUC 2013
Zotonic tutorial EUC 2013Zotonic tutorial EUC 2013
Zotonic tutorial EUC 2013
 
Erlang: Software for a Concurrent world
Erlang: Software for a Concurrent worldErlang: Software for a Concurrent world
Erlang: Software for a Concurrent world
 
Physical Computing with Android and IOIO
Physical Computing with Android and IOIOPhysical Computing with Android and IOIO
Physical Computing with Android and IOIO
 
Open-CI for beginners
Open-CI for beginnersOpen-CI for beginners
Open-CI for beginners
 
OBG Presentatie Mediamatic Salon
OBG Presentatie Mediamatic SalonOBG Presentatie Mediamatic Salon
OBG Presentatie Mediamatic Salon
 

Dernier

Dernier (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Zotonic presentation Erlang Camp Boston, august 2011

  • 1. Zotonic A modern web framework and CMS Arjan Scherpenisse MiracleThings arjan@miraclethings.nl
  • 2. Overview  Yet another CMS?  Why Erlang?  Inside Zotonic  The future
  • 3. Websites: a history  First generation  static text, images  Second generation  Database driven, templates, CMS.  Now:  Highly interactive, realtime, data exchange, personalization
  • 4. Our wish list  CMS  Framework  Connectivity  Frontender friendly  Efficient use of hardware
  • 5. Now: <?php ?>  Slow  More code => slower  Shared nothing  Amnesia doesn't make it faster  Big non threaded web server  Forget long living connections...
  • 6. Now: Python, Ruby...  One process per core  Multithreading? Better not  No sharing of state and data  Memcache is common state  On failure your server crashes
  • 7. Erlang?  Website is communication hub  Many kinds of data streams  Many Parallel connections  Lots of short requests  Long living connections  …this looks like a phone switch!
  • 8. Why not Erlang?  Esoteric language  Greate error/failure handling  Very compact  Mature  String processing?  Data preprocessing, iolist()s
  • 10. So, what's in the box?  Multiple sites  Integrated e-mail  Admin interface sending + receiving (!)  Member administration  API OAuth  Page management  i18n  Menu creator  Atom feeds  Commenting  Import CSV / Wordpress  Image scaling / preview  Mailinglist  Video embedding
  • 11. Getting technical  Where we started  Our data model  Open source puzzle  OTP hierarchy  Modules  URL dispatching  The building blocks
  • 12. Data model: everything is a thing Article Article author depiction Person Person Image Image
  • 13. Full data model identity identity medium medium config config rsc rsc category category persistent persistent predicate protect protect module subject object module predicate_category predicate_category edge edge
  • 14. Open source puzzle  Webmachine  Forked to webzmachine  Nitrogen  ErlyDTL  Mochiweb, erlang-gettext, erlang-oauth, gen_smtp  PostgreSQL driver: epgsql  Imagemagick (cli)
  • 15. Diagram Modules Modules Zotonic core Zotonic core Sites Sites Webmachine Webmachine epgsql epgsql Webmachine Webmachine
  • 16. OTP hierarchy zotonic.app zotonic_sup z_email_receive z_sites_sup wm_mochiweb_* dispatcher z_config z_ids z_email_server z_media_preview z_sites_sup z_sites_sup z_sites_sup z_pivot_rsc z_dropbox z_installer z_depcache z_module_manager z_site_startup z_session z_template z_trans_server z_dispatcher z_module_indexer z_sites_sup z_sites_sup Module processes z_session_page z_session_page z_session_page z_notifier
  • 17. Modules  Modules are self-contained:  Dispatch rules, resources, templates, css, javascript, images, translations, template filters, actions, validators, API services, models, …  Prioritized list  File lookup mechanism  Every module can be a gen_server
  • 18. Notification system  Is how modules extend and offer functionality  gen_event-like  Listen to notifications  Send notifications:  notify, notify1, fold, map, first  Both sync and async % @doc Check if the recipient is a known user, if so redirect the received e- mail observe_email_received(#email_received{localpart=Recipient} = Received, Context) -> case m_identity:lookup_by_username(Recipient, Context) of undefined -> undefined; Props -> case proplists:get_value(is_verified, Props) of true ->
  • 19. URL dispatching  Dispatch rules per site  (and per module)  Dispatch rules have names {contact, [“contact”], resource_template, [ {template, "contact.tpl"} ]},
  • 20. The page controller  Webmachine entrypoint for pages  404 check  Authorization check + logon redirect  Template selection
  • 21. Template system  Extended ErlyDTL  Expressions: {% if a + b > c %}  Tuple and list data types  Data access through models: {{ m.rsc[id].title }}  Templates can be made more specific by category and/or unique page name  Templates with the same name override each other  Uses module priority
  • 22. Template ex.: page.page_projects.tpl {% extends "page.tpl" %} {% block content_body %} {% cache 7200 %} {% for r in m.search[{archive_year cat='project'}] %} <div class="grid_9 alpha omega"> <h2 class="year">{{ r.year }}</h2> </div> {% for group in m.search[{query publication_year=r.year|append:"" cat='project' sort="-publication_start"}]|chunk:3 %} <div class="grid_9 alpha omega"> {% for id in group %} {% catinclude "inc/listitem.tpl" id alpha=forloop.first omega=forloop.last%} {% endfor %} </div> {% endfor %} {% endfor %} {% endcache %} {% endblock %}
  • 23. Scomps — screen components  For when you need more logic than a template can handle  Erlang module  Cacheable  Example: {% menu id=id %}
  • 24. Javascript — Event handling  Ajax postbacks  Form submits  Calls event/2 function  Communicates back to browser by sending javascript  Inspired by Nitrogen {% button postback={click foo=”bar”} text=”click me” %} event({postback, {click, Args}, _Trigger, _Target}, Context) -> z_render:wire({alert, [{text,”hello”}]}, Context).
  • 25. Javascript — Push connections  Uses either Comet or WebSockets  Attaches to the page process  Transports Javascript to the UA
  • 26. API services  API method is an Erlang module  /api/mymodule/mymethod  In /services module directory  JSON input / output  Process GET and POST
  • 27. Performance optimizations  Caching (don't hit the database)  Prevent data copying  Memo-caching in process dict  Pre-computed HTML  Share computations between requests
  • 28. Compute less  Parallel requests have similar computations  Only one time calculated  Lightweight and simple optimization against /. effect  Uses memo functionality of depcache  Kind of caching, with 0 expire.
  • 29. Future directions  Information exchange hub  PubSub (XMPP, pubsubhubub)  Push & pull (feeds, atom, email)  Scaling up.... Elastic Zotonic  Distributed  Fault tolerant  Buzzword compliancy :-)
  • 30. Elastic Zotonic goals  Scalable  Robust  Fault tolerant  Low maintainance  Easy to setup  KISS  Time scale: first release Q4 2011
  • 31. The community  www.zotonic.com — always improving with latest documentation  Great mailing list with helpful people  zotonic-users@groups.google.com  XMPP chat room  zotonic@conference.zotonic.com
  • 32. Thank you!  Online resources:  MiracleThings website http://miraclethings.nl/media/attachment/2011/8/13/arjan_miraclethings_789d763.zip Presentation slides http://miraclethings.nl/media/attachment/2011/8/13/20110813_erlangcamp.pdf  … any questions?