pop - “platform of platforms” · 2016. 8. 29. · .tmpl handlebars templates.js files (jquery)...

49
PoP - “Platform of Platforms” Leonardo Losoviz https://getpop.org

Upload: others

Post on 26-Sep-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

PoP - “Platform of Platforms”

Leonardo Losovizhttps://getpop.org

Page 2: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

URLsPoP

https://getpop.org

PoP Demo

https://demo.getpop.org

GitHub

https://github.com/leoloso/PoP

Page 3: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

What is PoP?

PoP creates Single-Page Application websites, by combining Wordpress and Handlebars into an MVC architecture framework:

Wordpress is the model/back-end

Handlebars templates are the view/front-end

the PoP engine is the controller

Page 4: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

How does it work?

1 PoP intercepts the user request in the front-end and delivers it to the webserver using AJAX.

2 Wordpress processes the request, and provides the results to the PoP controller.

3 PoP generates a response in JSON, and feeds this JSON code back to the front-end

Page 5: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

How does it work?

4 Handlebars templates transform the JSON code into HTML, and passes it back to PoP

5 PoP appends the HTML into the DOM and executes user-defined javascript functions on the new elements.

Page 6: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Key design principles

Page 7: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

#1: API

PoP provides the WordPress website of its own API:

Available via HTTP

Simply by adding to any URL: output=json

Page 8: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

#2: Decentralized

The response is a uniform JSON code

All PoP websites can communicate among themselves

Fetch/process data in real time.

POST requests

User-generated content is stored on the source website.

Page 9: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

What can we do with PoP?

Page 10: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Social network

Features taken from several social networks:

Twitter/Facebook/Medium/Reddit

Demo in https://demo.getpop.org

Page 11: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Decentralized social network

Demo between:

https://getpop.org

https://demo.getpop.org

Page 12: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

How can it be used?

Page 13: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Niche/decentralized social network => Twitter/Facebook/Medium/Reddit

(with WooCommerce) Decentralized market-place => Amazon

Content aggregator => Digg

Server back-end for mobile apps

Microservices

Potential uses

Page 14: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Characteristics

Page 15: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Single-Page Application

loose: developer can select:

what pages are preloaded

which ones are retrieved from the server

Page 16: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

SPA Drawback

The first load has to download the framework and the application code.

Slower first page load compared to server-based applications.

Page 17: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Application state

Read operations: state kept in front-end

Create/Update/Delete operations: handled in the server

no dual state, no state synchronization needed

Page 18: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

(Non)logged-in user state

Rich experience for both logged-in and non logged-in users

Coherent among stateful/less pages

Synchronized among tabs

Page 19: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Program execution flow

Model and Controller (application logic, program execution flow) in back-end

Different to javascript frameworks (eg: AngularJS)

Page 20: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Comparison with WP REST API

Page 21: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Similarities

Can export any piece of data:

/posts

/events

/users

/tags

Page 22: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

DifferencesNot RESTful (at least not currently, but it can be done)

Links keep the same URL as in WordPress

Search engine optimization friendly

Documentation-less API

The public API is automatically generated

Developers can focus on making the website

Page 23: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Template hierarchy

Page 24: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Templates

topLevel,

pageSections,

blocks/blockGroups

modules

Page 25: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

HierarchyTop-down hierarchy:

1 topLevel contains N pageSections

1 pageSection contains N blocks/blockGroups

1 blockGroup contains N blocks/blockGroups

1 block contains N modules

1 module contains N modules (ad infinitum)

Page 26: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

topLevel

= WordPress Hierarchy

Home/Single/Page/Archive/etc

Page 27: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

topLevel

Page 28: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

pageSection

Is a physical/functional section on the website

Page 29: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

pageSections

Page 30: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

block

Is an independent component

Keeps its own state

Can be added to different pageSections, and customized for each

Page 31: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

blocks

Page 32: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

blockGroup

a special type of block

collects/wraps other blocks

synchronizes state among them

Page 33: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

blockGroups

Page 34: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Module

Either

An atomic/reusable functionality

A composition of modules

Page 35: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

modules

Page 36: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Modularity

Page 37: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Atomic/reusable module

A module is composed of:

PHP files

.tmpl Handlebars templates

.js files (jQuery)

Page 38: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Composable module

Modules can build upon each other

Separation of Concerns

Collaboration among developers

Page 39: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

JSON structure

Page 40: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Clean JSON structure

Database => unique per topLevel

Dataset => unique per block

State variables => unique per block

Configuration => unique per pageSection, block and module

Page 41: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Database

Keeps relationships among objects (not a flat, single-level structure)

Cumulative

Allows to not fetch already-loaded data

Page 42: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Front-end features

Page 43: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Targets

Any page can be opened on any pageSection

Simply specify attribute “target” in the link, pointing to the pageSection

Page 44: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

FormatsData can be visualized on multiple, customizable formats

Lists

Grids

Maps

Charts

Etc

Page 45: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Presentation

Multiple presentation styles

Minimum extra code can lead to provide different functions

Print

Embed

Page 46: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Tabs

Many pages can be opened simultaneously

Pages remain accessible until closed

Page 47: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Background (pre)loadingPre-loaded pages, user state, client-server synchronization

Initial views

User logged-in status

Page-related user state

User notifications

Non-cacheable data (eg: posts' comment count)

Page 48: PoP - “Platform of Platforms” · 2016. 8. 29. · .tmpl Handlebars templates.js files (jQuery) Composable module Modules can build upon each other Separation of Concerns Collaboration

Interceptors

Switches tab to an already-opened page

Renders a view instantly

Allows deep-linking of javascript functions, using an actual, reachable URL