+ All Categories
Home > Technology > Mashing up JavaScript

Mashing up JavaScript

Date post: 15-Jan-2015
Category:
Upload: bastian-hofmann
View: 4,658 times
Download: 0 times
Share this document with a friend
Description:
Nowadays many modern web applications are solely relying on JavaScript to render their frontend. But if you want to create mashups, load data from many different places or include external widgets into your site, you are quickly running into boundaries because of browser and security restrictions. In this presentation I will talk about techniques helping you with such problems.
Popular Tags:
66
Mashing up JavaScript Advanced techniques for modern web applications Bastian Hofmann / VZnet Netzwerke Ltd.
Transcript
Page 1: Mashing up JavaScript

Mashing up JavaScriptAdvanced techniques for modern web applications

Bastian Hofmann / VZnet Netzwerke Ltd.

Page 2: Mashing up JavaScript

Wtf?

Page 3: Mashing up JavaScript
Page 4: Mashing up JavaScript
Page 5: Mashing up JavaScript
Page 6: Mashing up JavaScript
Page 7: Mashing up JavaScript

• JavaScript Apps

• CORS and OAuth2

• Local Storage

• OEmbed and Caja

• WebSockets, ActivityStrea.ms and PubsubHubbub

• OpenSocial

Page 8: Mashing up JavaScript
Page 9: Mashing up JavaScript
Page 10: Mashing up JavaScript
Page 11: Mashing up JavaScript

You?

Page 12: Mashing up JavaScript

Questions? Ask!

Page 15: Mashing up JavaScript

Let‘s write a JS App

Page 16: Mashing up JavaScript

Don‘t reinvent the wheel!

Page 17: Mashing up JavaScript

Open Source

}

Page 18: Mashing up JavaScript

Open Standards

Page 19: Mashing up JavaScript
Page 20: Mashing up JavaScript

DEMO

Page 21: Mashing up JavaScript

History & Bookmarking

Page 22: Mashing up JavaScript

http://sammyjs.org/

Page 23: Mashing up JavaScript

DEMO

Page 24: Mashing up JavaScript

API Access

Page 25: Mashing up JavaScript

Same Origin Policy

Page 26: Mashing up JavaScript

Cross-Origin Resource Sharing

Backendapi.twitter.com

Client client.net

AJAX

Access-Control-Allow-Origin: *

http://www.w3.org/TR/cors/

Page 27: Mashing up JavaScript

DEMO

Page 28: Mashing up JavaScript

var html="<ul>";for (var i=0; i < viewers.length; i++) {   html += "<li>" + viewers[i].displayName + "</li>";}html += "<ul>";document.getElementById("#div").innerHTML = html;

Page 29: Mashing up JavaScript

Templates

Page 30: Mashing up JavaScript

Mustache.JS

https://github.com/janl/mustache.js

}

Page 31: Mashing up JavaScript

DEMO

Page 32: Mashing up JavaScript

Authorization

Page 33: Mashing up JavaScript
Page 34: Mashing up JavaScript

+----------+ Client Identifier +----------------+ | |>---(A)-- & Redirection URI --->| | | | | | End <--+ - - - +----(B)-- User authenticates -->| Authorization | User | | | Server | | |<---(C)--- Redirect URI -------<| | | Client | with Access Token | | | in | in Fragment +----------------+ | Browser | | | +----------------+ | |>---(D)--- Redirect URI ------->| | | | without Fragment | Web Server | | | | with Client | | (F) |<---(E)--- Web Page with ------<| Resource | | Access | Script | | | Token | +----------------+ +----------+

User-Agent Profile

Page 35: Mashing up JavaScript

DEMO

Page 36: Mashing up JavaScript

Storing the access token

Page 37: Mashing up JavaScript

Cookie

Page 38: Mashing up JavaScript

Problem: Cookie is also sent to the backend

Page 39: Mashing up JavaScript

Local Storage

http://www.w3.org/TR/webstorage/

Page 40: Mashing up JavaScript

DEMO

Page 41: Mashing up JavaScript

Mash it up!

Page 43: Mashing up JavaScript

OEmbed• Retrieves embeddable content for a given link

http://www.flickr.com/services/oembed/?url=http%3A//www.flickr.com/photos/bees/2341623661/

{        "version": "1.0",        "type": "photo",        "width": 240,        "height": 160,        "title": "ZB8T0193",        "url": "http://farm4.static.flickr.com/3123/2341623661_7c99f48bbf_m.jpg",        "author_name": "Bees",        "author_url": "http://www.flickr.com/photos/bees/",        "provider_name": "Flickr",        "provider_url": "http://www.flickr.com/"}

http://oembed.com/

Page 44: Mashing up JavaScript

The embedded result

cool video:

Page 45: Mashing up JavaScript

OEmbed Aggregation

•embed.ly

•supports 218 services over one endpoint

•several libraries

•easy implementation

http://embed.ly/

Page 46: Mashing up JavaScript

DEMO

Page 47: Mashing up JavaScript
Page 48: Mashing up JavaScript

Caja

http://code.google.com/p/google-caja/

Page 49: Mashing up JavaScript

DEMO

Page 50: Mashing up JavaScript

Instant updates without reloading

Page 52: Mashing up JavaScript

<entry> <activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type> <id>http://status.net.xyz:8061/index.php/notice/20</id> <title>hello from client</title> <content type="html">hello from client</content> <link rel="alternate" type="text/html" href="http://status.net.xyz:8061/index.php/notice/20"/> <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb> <published>2011-05-23T21:07:33+00:00</published> <updated>2011-05-23T21:07:33+00:00</updated> <link rel="ostatus:conversation" href="http://status.net.xyz:8061/index.php/conversation/20"/> <georss:point>52.52437 13.41053</georss:point> <link rel="self" type="application/atom+xml"href="http://status.net.xyz:8061/index.php/api/statuses/show/20.atom"/> <link rel="edit" type="application/atom+xml"href="http://status.net.xyz:8061/index.php/api/statuses/show/20.atom"/> <statusnet:notice_info local_id="20" source="api" favorite="false"repeated="false"></statusnet:notice_info></entry>

Page 53: Mashing up JavaScript

http://activitystrea.ms/

Page 55: Mashing up JavaScript

PubSubHubbubretrieves Atom feed with Hub URL

Hub

posts sthpings everysubscriber

subscribes for feed

ackssubscription

http://code.google.com/p/pubsubhubbub/

Page 56: Mashing up JavaScript

http://nodejs.org/

Page 57: Mashing up JavaScript

WebSockets

http://dev.w3.org/html5/websockets/

Page 58: Mashing up JavaScript

Browser Notifications

Page 59: Mashing up JavaScript

Tying it together

retrieve Stream with Hub

Ajax: request Subscription

WebSockets:new Post

subscribe at hubchallenge

acknew post

Notification

new post

Page 60: Mashing up JavaScript

DEMO

Page 61: Mashing up JavaScript

Including widgets

Page 62: Mashing up JavaScript
Page 63: Mashing up JavaScript

GADGETapivz.net

CONTAINERmeinvz.net

Page 64: Mashing up JavaScript
Page 65: Mashing up JavaScript

DEMO


Recommended