pop - “platform of platforms”: framework for building single-page application wordpress...

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

Upload: leonardo-losoviz

Post on 20-Mar-2017

833 views

Category:

Software


0 download

TRANSCRIPT

Page 1: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

PoP - “Platform of Platforms”

Leonardo Losovizhttps://getpop.org

Page 2: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

URLsPoP

https://getpop.org

PoP Demo

https://demo.getpop.org

GitHub

https://github.com/leoloso/PoP

Page 3: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

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”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

How does it work?Front-end Back-end

Page 5: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

How does it work?

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

Front-end Back-endRequest: AJAX

Request

Page 6: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

How does it work?

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

Front-end Back-endRequest: AJAX

Data

Request

Page 7: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

How does it work?

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

Front-end Back-endRequest: AJAX

Response: JSON

Data

Request

Page 8: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

How does it work?

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

Front-end Back-endRequest: AJAX

Response: JSON

Data

Request

HTML

Page 9: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

How does it work?

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

Front-end Back-endRequest: AJAX

Response: JSON

Data

Request

HTMLResponse

Page 10: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Key design principles

Page 11: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

#1: API

PoP provides the WordPress website of its own API:

Available via HTTP

Simply by adding to any URL: output=json

Page 12: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

#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 13: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

What can we do with PoP?

Page 14: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Social network

Features taken from several social networks:

Twitter/Facebook/Medium/Reddit

Demo in https://demo.getpop.org

Page 15: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Decentralized social network

Demo between:

https://getpop.org

https://demo.getpop.org

Page 16: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

How can it be used?

Page 17: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

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 18: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Characteristics

Page 19: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Single-Page Application

loose: developer can select:

what pages are preloaded

which ones are retrieved from the server

Page 20: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

SPA Drawback

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

Slower first page load compared to server-based applications.

Page 21: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

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 22: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

(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 23: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Program execution flow

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

Different to javascript frameworks (eg: AngularJS)

Page 24: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Comparison with WP REST API

Page 25: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Similarities

Can export any piece of data:

/posts

/events

/users

/tags

Page 26: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

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 27: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Template hierarchy

Page 28: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Templates

topLevel,

pageSections,

blocks/blockGroups

modules

Page 29: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

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 30: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

topLevel

= WordPress Hierarchy

Home/Single/Page/Archive/etc

Page 31: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

topLevel

Page 32: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

pageSection

Is a physical/functional section on the website

Page 33: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

pageSections

Page 34: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

block

Is an independent component

Keeps its own state

Can be added to different pageSections, and customized for each

Page 35: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

blocks

Page 36: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

blockGroup

a special type of block

collects/wraps other blocks

synchronizes state among them

Page 37: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

blockGroups

Page 38: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Module

Either

An atomic/reusable functionality

A composition of modules

Page 39: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

modules

Page 40: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Modularity

Page 41: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Atomic/reusable module

A module is composed of:

PHP files

.tmpl Handlebars templates

.js files (jQuery)

Page 42: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Composable module

Modules can build upon each other

Separation of Concerns

Collaboration among developers

Page 43: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

JSON structure

Page 44: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Clean JSON structure

Database => unique per topLevel

Dataset => unique per block

State variables => unique per block

Configuration => unique per pageSection, block and module

Page 45: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Database

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

Cumulative

Allows to not fetch already-loaded data

Page 46: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Front-end features

Page 47: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Targets

Any page can be opened on any pageSection

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

Page 48: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

FormatsData can be visualized on multiple, customizable formats

Lists

Grids

Maps

Charts

Etc

Page 49: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Presentation

Multiple presentation styles

Minimum extra code can lead to provide different functions

Print

Embed

Page 50: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Tabs

Many pages can be opened simultaneously

Pages remain accessible until closed

Page 51: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

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 52: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Interceptors

Switches tab to an already-opened page

Renders a view instantly

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

Page 53: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Let’s see the code!

Page 54: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Handlebars Templates

Page 55: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 56: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 57: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Inner modules

Page 58: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 59: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 60: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Initializing attributes

Page 61: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 62: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Configuration

Page 63: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 64: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 65: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Executing Javascript

Page 66: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 67: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 68: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 69: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 70: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Loading data

Page 71: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 72: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 73: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Loading external data

Page 74: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 75: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 76: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Input/Output variables

Page 77: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 78: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 79: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Actions

Page 80: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 81: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 82: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Data fields

Page 83: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 84: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 85: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks

Changing object domain

Page 86: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 87: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks
Page 88: PoP - “Platform of Platforms”: Framework for building Single-Page Application WordPress websites, decentralized crowd-sourced platforms, and social networks