SlideShare ist ein Scribd-Unternehmen logo
1 von 60
Downloaden Sie, um offline zu lesen
Cross Domain Web
Mashups with JQuery
and Google App Engine




Andy McKay. Clearwind Consulting
http://clearwind.ca
Also known as
A bunch of cool buzz words to try and describe
    some of the stuff I’m doing these days
   and get me in to talk at cool conferences
Cross Domain
   JQuery
 App Engine
Cross Domain
   JQuery
 App Engine
mashup
“a web page or application that combines data
  from two or more external online sources”
reusable web applications
that aren't SOAP and WSDL

quot;The three chief virtues of a programmer are: Laziness,
         Impatience and Hubris”. Larry Wall
back in time...
Zope 2
Plone
 Rails
Django
rewriting things constantly
 is good for billable hours
small web applications
    returning xml
Ajax


 browser: rails.site.ca


                                 server: another.ca

browser: django.site.ca
there's a problem
Single origin policy
browser: clearwind.ca                           server: some.other.ca

The same origin policy prevents document or script loaded from one origin from getting
or setting properties of a document from a different origin.
-- From http://www.mozilla.org/projects/security/components/same-origin.html
1. proxy


browser: clearwind.ca   server: clearwind.ca   server: some.other.ca
2. hacks

  flash
 iframe
document
  script
3. JSONP

JavaScript Object Notation
       with Padding
Example: json-time
                 By Simon Willison
           http://json-time.appspot.com/
http://github.com/simonw/json-time/tree/master
JSON
{
    quot;tzquot;: quot;America/Chicagoquot;,
    quot;hourquot;: 3,
    quot;datetimequot;: quot;Tue, 19 May 2009 03:06:50 -0500quot;,
    quot;secondquot;: 50,
    quot;errorquot;: false,
    quot;minutequot;: 6
}
JSONP

process_time({
  quot;tzquot;: quot;America/Chicagoquot;,
  quot;hourquot;: 3,
  quot;datetimequot;: quot;Tue, 19 May 2009 03:09:09 -0500quot;,
  quot;secondquot;: 9,
  quot;errorquot;: false,
  quot;minutequot;: 9
})
Cross Domain
   JQuery
 App Engine
JQuery for json-time


var url = quot;http://json-time.appspot.com/timezones.json?quot;

$.getJSON(url + quot;callback=?quot;,
        function (json) {
          ...
        });
JSON time demo
Complete JSON time demo
$(document).ready(function() {
    var url = quot;http://json-time.appspot.comquot;;

      function showTime(data) {
          $.getJSON(url + quot;/time.json?tz=quot; + $(quot;#zonesquot;).val() + '&callback=?',
              function (json){
                  $(quot;#zones-msgquot;).text('The time is now ' + json[quot;datetimequot;] + '.');
              });
      };

      $.getJSON(url + quot;/timezones.json?callback=?quot;,
          function (json) {
              var zones = $(quot;#zonesquot;);
              for (var k = 0; k < json.length; k++) {
                  zones.append(quot;<option>quot; + json[k] + quot;</option>quot;);
              };
              zones.bind(quot;changequot;, showTime)
          });
});
Cross Domain
   JQuery
 App Engine
Easiest deployment
  Best scalability
  Minimal effort
Not straight Python
Has it's limitations and quirks
And it's free
Example Mashup
  The coolest technology of 2006
          Google Maps
The most hyped technology of 2009
               Twitter
Twitter messages with a map
 by hash tag eg: #owv2009
Step 1:
Assign hash tag to location
geohashtag.appspot.com




browser: geohashtag.appspot.com   server: geohashtag.appspot.com
Model

from google.appengine.ext import db

class Tag(db.Model):
    name = db.StringProperty(required=True)
    geostring = db.StringProperty(required=True)
Issue
You cannot do an inequality test on two fields in one query.
                     Or use GeoPt.

               GeoHash solves this problem:
           http://en.wikipedia.org/wiki/Geohash
JSON

     tag.json (returns location for a tag)
bounds.json (returns all the tags in a rectangle)
Geohashtag demo
Step 2:
Parse RSS into JSONP
atomtojsonp.appspot.com




browser: atomtojsonp.appspot.com                 server: search.twitter.com
                         server: atomtojsonp.appspot.com
Proxy?
    Because twitter doesn't have JSON export
Other services like Google RSS or Yahoo YQL have
                     problems

  But checkout: http://developer.yahoo.com/yql/
   and http://code.google.com/apis/ajaxfeeds/
No Model

Quite common for
  App Engine
Just feedparser
                  http://www.feedparser.org/


class JSONHandler(webapp.RequestHandler):
    def get(self):
        url = self.request.get(quot;urlquot;)
        data = feedparser.parse(url)
        if self.request.get(quot;callbackquot;):
            data = quot;%s(%s)quot; % (self.request.get(quot;callbackquot;), data)
        self.response.out.write(data)
JSON

twitter.json (smaller twitter version for a search term)
         atom.json (a whole atom file for a url)
Atomtwojsonp demo
Step 3:
Mash it up
geojsontweet.appspot.com


browser: geojsontweet.appspot.com   server: maps.google.com




browser: geojsontweet.appspot.com
geojsontweet.appspot.com


browser: geojsontweet.appspot.com     server: maps.google.com




browser: geojsontweet.appspot.com   server: geohashtag.appspot.com




browser: geojsontweet.appspot.com
geojsontweet.appspot.com


browser: geojsontweet.appspot.com                server: maps.google.com




browser: geojsontweet.appspot.com              server: geohashtag.appspot.com




browser: geojsontweet.appspot.com                server: search.twitter.com
                         server: atomtojsonp.appspot.com
No Model
In fact, completely static HTML
  (with JS, no server side code)
Some Javascript
function move() {
        var bounds = map.getBounds();
        var sw = bounds.getSouthWest();
        var ne = bounds.getNorthEast();

       var url = map_details.tags_domain + '/bounds.json?nelat=';
       url += ne.lat() + '&nelon=' + ne.lng();
       url += '&swlon=' + sw.lng() + '&swlat=' + sw.lat() + '&callback=?'

       if (map_details.last_url != url) {
           map_details.last_url = url
           $.getJSON(url,
               function(json) {
                   if (json) {
                       for (var k = 0; k < json.length; k++) {
                           ...
Some more Javascript

function twitter() {
    var tag = null;
    for (var obj in tags) {
        var url = map_details.atom_domain + '/twitter.json?tag=' + obj +
'&callback=?'
        $.getJSON(url,
            function(json) {
                var tweet = null;
                for (var k = 0; k < json.length; k++) {
                     ....
Slideshow
     http://flowplayer.org/tools/scrollable.html


$(quot;#tweets-quot; + tweet[quot;tagquot;]).parent().scrollable({
    interval: 4000,
    loop: true,
    speed: 600,
    onBeforeSeek: function() {
        this.getItems().fadeTo(300, 0.2);	 	
    },
    onSeek: function() {
        this.getItems().fadeTo(300, 1);
    }
});
Geojsontweet demo
Serious issues
Trust
You are executing someone else's JavaScript
     in your site. Better be trustworthy.
Single points of failure?
Single points of failure?
Enterprise
Internal servers?
Questions?
Code: http://svn.clearwind.ca/public/projects/presentations
                 Email: andy@clearwind.ca

Weitere ähnliche Inhalte

Was ist angesagt?

Async. and Realtime Geo Applications with Node.js
Async. and Realtime Geo Applications with Node.jsAsync. and Realtime Geo Applications with Node.js
Async. and Realtime Geo Applications with Node.js
Shoaib Burq
 
Doctype htm1
Doctype htm1Doctype htm1
Doctype htm1
Eddy_TKJ
 
Apache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux FestApache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux Fest
Myles Braithwaite
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simpler
Alexander Mostovenko
 

Was ist angesagt? (20)

Rethink Async With RXJS
Rethink Async With RXJSRethink Async With RXJS
Rethink Async With RXJS
 
Downloading the internet with Python + Scrapy
Downloading the internet with Python + ScrapyDownloading the internet with Python + Scrapy
Downloading the internet with Python + Scrapy
 
async/await in Swift
async/await in Swiftasync/await in Swift
async/await in Swift
 
Code is Cool - Products are Better
Code is Cool - Products are BetterCode is Cool - Products are Better
Code is Cool - Products are Better
 
Async. and Realtime Geo Applications with Node.js
Async. and Realtime Geo Applications with Node.jsAsync. and Realtime Geo Applications with Node.js
Async. and Realtime Geo Applications with Node.js
 
Doctype htm1
Doctype htm1Doctype htm1
Doctype htm1
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016
 
Scrapy workshop
Scrapy workshopScrapy workshop
Scrapy workshop
 
Apache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux FestApache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux Fest
 
Fun with Python
Fun with PythonFun with Python
Fun with Python
 
Web Crawling Modeling with Scrapy Models #TDC2014
Web Crawling Modeling with Scrapy Models #TDC2014Web Crawling Modeling with Scrapy Models #TDC2014
Web Crawling Modeling with Scrapy Models #TDC2014
 
Pydata-Python tools for webscraping
Pydata-Python tools for webscrapingPydata-Python tools for webscraping
Pydata-Python tools for webscraping
 
Webscraping with asyncio
Webscraping with asyncioWebscraping with asyncio
Webscraping with asyncio
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simpler
 
React for Beginners
React for BeginnersReact for Beginners
React for Beginners
 
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
 
Create responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSCreate responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJS
 
Logstash for SEO: come monitorare i Log del Web Server in realtime
Logstash for SEO: come monitorare i Log del Web Server in realtimeLogstash for SEO: come monitorare i Log del Web Server in realtime
Logstash for SEO: come monitorare i Log del Web Server in realtime
 
Large Scale Log Analytics with Solr (from Lucene Revolution 2015)
Large Scale Log Analytics with Solr (from Lucene Revolution 2015)Large Scale Log Analytics with Solr (from Lucene Revolution 2015)
Large Scale Log Analytics with Solr (from Lucene Revolution 2015)
 

Andere mochten auch (7)

Introduction To Backbone JS
Introduction To Backbone JSIntroduction To Backbone JS
Introduction To Backbone JS
 
Modern iframe programming
Modern iframe programmingModern iframe programming
Modern iframe programming
 
Introduction to Backbone.js
Introduction to Backbone.jsIntroduction to Backbone.js
Introduction to Backbone.js
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017
 
TEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkTEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of Work
 
Build Features, Not Apps
Build Features, Not AppsBuild Features, Not Apps
Build Features, Not Apps
 

Ähnlich wie Cross Domain Web
Mashups with JQuery and Google App Engine

CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges
 
Socket applications
Socket applicationsSocket applications
Socket applications
João Moura
 
Build web application by express
Build web application by expressBuild web application by express
Build web application by express
Shawn Meng
 

Ähnlich wie Cross Domain Web
Mashups with JQuery and Google App Engine (20)

huhu
huhuhuhu
huhu
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Os Pruett
Os PruettOs Pruett
Os Pruett
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QA
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gears
 
Implementing Comet using PHP
Implementing Comet using PHPImplementing Comet using PHP
Implementing Comet using PHP
 
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
 
Socket applications
Socket applicationsSocket applications
Socket applications
 
OneRing @ OSCamp 2010
OneRing @ OSCamp 2010OneRing @ OSCamp 2010
OneRing @ OSCamp 2010
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)
 
Non Conventional Android Programming En
Non Conventional Android Programming EnNon Conventional Android Programming En
Non Conventional Android Programming En
 
Ajax for dummies, and not only.
Ajax for dummies, and not only.Ajax for dummies, and not only.
Ajax for dummies, and not only.
 
Build web application by express
Build web application by expressBuild web application by express
Build web application by express
 
Rotzy - Building an iPhone Photo Sharing App on Google App Engine
Rotzy - Building an iPhone Photo Sharing App on Google App EngineRotzy - Building an iPhone Photo Sharing App on Google App Engine
Rotzy - Building an iPhone Photo Sharing App on Google App Engine
 
Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007
 
The Atmosphere Framework
The Atmosphere FrameworkThe Atmosphere Framework
The Atmosphere Framework
 
Introducing to node.js
Introducing to node.jsIntroducing to node.js
Introducing to node.js
 
Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous Merb
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
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
 
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
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

Cross Domain Web
Mashups with JQuery and Google App Engine