[drupalday2017] - decoupled frontend con drupal 8 e openui 5

36
Decoupled frontend with Drupal 8 e OpenUI 5 DrupalDay 2017 - Rome, 03/03/2017

Upload: drupalday

Post on 21-Mar-2017

36 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Decoupled frontend with Drupal 8 e OpenUI 5

DrupalDay 2017 - Rome, 03/03/2017

Page 2: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Whaaat?

Page 3: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Whaaat?

Page 4: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

About me

Name: Donato RotunnoAge: 42Birthplace: Lucania (Basilicata), ItalyProfession: Frontend developer and Web Content Accessibility passionateCompany: Liip AG, Fribourg, SwitzerlandGithub: ralf57Twitter: ralf57

Page 5: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

About my nickname

The Greatest American Hero, a.k.a Ralph supermaxieroe

Page 6: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Agenda

Decoupled frontend: why and what?

A quick look at Drupal 8 REST implementation

Discovering OpenUI 5

Demo

Questions

Page 7: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

What is a decoupled frontend?

An application which interacts with another application exposing data via external API

(REST, SOAP, etc)

Page 8: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Why a decoupled frontend?

Page 9: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Fully customizable frontend

Twig templating engine

Easily override default markup

Free to adopt any assets (JS, CSS, Images, etc) management strategy. Built-in or external tools

Page 10: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Why a decoupled frontend?

Page 11: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Innovation, desire to move on

Page 12: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Better performance

Page 13: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Only expose what you need

(regardless of user permissions)

Page 14: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Implement a completely different UI pattern

Page 15: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Make the migration to a “Drupal as Content Repository”

easier

Page 16: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Traditional Drupal setup

FrontendBackend

+ Editor

Page 17: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

API-driven Drupal setup

FrontendBackend

+Editor

REST API

Page 18: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

API-driven Drupal setup + decoupled Editor

FrontendBackend(content

repository)

REST API

Editor

Page 19: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

The attack of API-first CMSes

Page 20: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

The attack of API-first CMSes

● Different targets: from newbie (Wix) to developer (Contentful)

● Offered as SaaS, with subscription-based business model

● Pros: low setup costs, SDK, rapid Frontend scaffolding

● Cons: data in the Cloud, technology (service) lock-in

Page 21: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

RESTful API’s with Drupal 8

https://www.drupal.org/docs/8/core/modules/rest/overview

Page 22: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

● Already possible in Drupal 7 via Via RESTful Web Services module

● In Drupal 8 it builds on top of Symfony Components

● In D8 core (although better use Views to expose resources)

Page 23: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

RESTful features

Multiple formats (JSON, XML, HAL+JSON, CSV)

Multiple Authentication mechanisms (Cookie, OAuth, OAuth 2.0 Token Bearer, HTTP Basic Authentication)

Most HTTP verbs supported, except PUT

(De)Serialization

Page 24: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Useful modules and tools

https://www.drupal.org/project/rest_api_docAutomatically generate API docs

https://www.getpostman.com/Develop and Test your API

https://www.drupal.org/project/develEspecially “Devel generate” in order to add some (dummy) content

Page 25: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

An introduction to OpenUI 5

http://openui5.org

Page 26: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Yet Another Framework?

http://todomvc.com/

Page 27: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5
Page 28: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Motivations (my guess)

● Hey, it’s 2015!● Many products are being moving to the cloud● The need to provide a solid User Experience, regardless of the device● Keep the technology lock-in

Page 29: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

OpenUI 5 key features

● MVC pattern implementation● Built-in support for several data model types (JSON, XML, OData)● Extensible● Comes with 200 UI controls● Responsive● Very good Accessibility support● (almost)Fully tested and good support for custom extensions testing● Backed by SAP

Page 30: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

OpenUI 5 key features

● No EcmaScript 6● Uses jQuery● Themeable via Less pre-processing● Support for different view formats (XML, HTML, Javascript, JSON)● Free and open source, hackable on Github

Page 31: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Love at first “define”

sap.ui.define([

'jquery.sap.global',

'sap/ui/core/Element',

'sap/ui/core/library'

], function(jQuery, Element, library) {

"use strict";

………});

https://raw.githubusercontent.com/SAP/openui5/master/src/sap.ui.core/src/sap/ui/core/search/SearchProvider.js

Page 32: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Love at first “define”

define([

'./cart',

'./inventory'

], function(cart, inventory) {

….

});

http://requirejs.org/docs/api.html#define

Page 33: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

VS

Page 34: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Showtime!!!

Page 35: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Questions?

Page 36: [drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5

Thank you all!

DrupalDay 2017 - Rome, 03/03/2017