SlideShare una empresa de Scribd logo
1 de 51
Descargar para leer sin conexión
Advanced Gadget and UI
Development Using
Google’s AJAX APIs
Derek Collison
5/29/2008
Agenda
• The Application Concept
• Basic Building Blocks
• The Google AJAX APIs
  –   Background
  –   Google AJAX Search API
  –   Google AJAX Feed API
  –   Google AJAX Language API
• Goals
  – Utilize the Raw AJAX APIs and advanced features
  – Show how Reader and Google CSE are utilized
  – How to wrap the application as a gadget


                                                      3
The Application Concept
•   Showcase the content on all of Google’s Blogs
•   Provide a tag cloud view for categories
•   Also a hierarchical view of all blogs grouped by tag
•   Allow search over all blogs
•   Provide language translation where applicable
•   Deploy as an iGoogle gadget




                                                           4
The Basic Building Blocks
•   HTML/DOM
•   CSS
•   Javascript
•   Tools
    – Editor
    – Debugger - Firebug
    – Performance - YSlow
• The Google AJAX Apis
   – Search
   – Feed
   – Language
• Google Reader (www.google.com/reader)
• Google Custom Search Engines (www.google.com/cse)
• iGoogle


                                                      5
Tools
Firefox and Firebug (http://www.getfirebug.com/)
Don’t develop without them!




                                                   6
Google AJAX APIs
Delivering the Web to Your Applications (Search, Feeds, Language)

                      • RESTful data access layer
                         – JSON/JSON-P
  AJAX APIs           • JavaScript Runtime
                         – Designed for ease of use
                      • JavaScript Controls and UI elements
                         – Custom integration and styling




                                                            7
Google AJAX APIs Background
• Comprehensive access to Google Systems (Search, Feeds, Language)
• End to end API stack:
   – Data Access via JavaScript Methods and REST
   – Built in Native UI and Large Suite of Advanced Controls
• Large, diverse customer base
   – Sites: Long Tail and Short Tail Sites (100 pv/d – 10m+ pv/d)
   – Developers: Pro Web Developers – Scripters – Bloggers
• High Speed, Low Latency, Globally Available


         JavaScript Controls and UI

              JavaScript Runtime
                                                               AJAX
             RESTful Data Access

                                                                      8
Google AJAX Search API
•   Web
•   Video
•   News
•   Image
•   Local
•   Book
•   Blog




                         9
Google AJAX Feed API
• Load
• Find
• Lookup




                       10
Google AJAX Language API
• Translation
• Language Detection




                           11
The Application Prototype




                            12
Prototype Demo
What we saw
•   The tag cloud view
•   A detail entry/snippet view
•   The hierarchical blog view
•   Search control and results
•   Translation capabilities




                                  14
How do we build it?
• Building Blocks
   – Google Reader (content feeds)
   – Custom Search Engine
   – AJAX APIs (Feed, Search, Language)
• Getting Started
   – Build standalone HTML/CSS/JS
   – google.load()
   – google.setOnLoadCallback()
• Putting it all together
   – Application details
• Making an iGoogle Gadget
   – Wrapping things into iGoogle

                                          15
Building The Application
Building Blocks - Google Reader - www.google.com/reader
• Subscriptions
  – Blog management
• Tags
  – Grouping Subscriptions/Blogs
  – Tag based pages
  – Tag based feeds
• Tag Cloud
  – All blogs top 20
• Hierarchical View
  – All categorized blogs



                                                          16
Building The Application
Building Blocks - Google Reader - www.google.com/reader
Tags and Categorization




                                                          17
Building The Application
Building Blocks - Google Reader - www.google.com/reader
Tags and Sharing Feeds




                                                          18
Building The Application
Building Blocks - Google Reader - www.google.com/reader
Tags and Sharing Feeds




                                                          19
Building The Application
Building Blocks - Google Reader - www.google.com/reader
Tags and Sharing Feeds - Ads Verticals Example
http://www.google.com/reader/shared/user/X/label/Ads%20Verticals




                                                                   20
Building The Application
Building Blocks - Google Reader - www.google.com/reader
Tags and Sharing Feeds - Ads Verticals Feed
http://www.google.com/reader/public/atom/user/X/label/Ads%20Verticals




                                                                  21
Building The Application
Building Blocks - Custom Search - www.google.com/cse
• CSE
  –   Custom Search Engine
  –   Better alternative than site restriction for large # of sites
  –   Enables search of all blogs
  –   All Google Blogs > 100 blogs
  –   Integrates directly with AJAX WebSearch




                                                                      22
Building The Application
Building Blocks - Custom Search - www.google.com/cse




                                                       23
Building The Application
Building Blocks - The Google AJAX APIs
• Feed API
  – Utilize Google Reader’s tag based feeds
  – Mixed Format (XML and JSON) for tag cloud
  – FeedControl for HTML generation
• Search API
  – Blog or Web Search
  – Customer Search Engine
  – Why not Blog Search?
• Language API
  – Detecting non-native languages
  – Allow translation


                                                24
Building The Application
Getting Started - The HTML and CSS
<div id='container' class='container'>
  <div id='tabs' class='tabs'>
    <div id='categories' class='tabHeader tabActive'>
       Categories
    </div>
    <div id='blogs' class='tabHeader tabInactive'>
       Blogs
    </div>
    <div id='search' class='tabHeader tabInactive'>
       Search
    </div>
  </div>
  <div id='tabView' class='tabView'>
    <div id='tabContentFrame' class='tabContentFrame'></div>
  </div>
  <div id='feedView' class='feedView'>
    <div id='feedContentView' class='feedContentView'></div>
  </div>
  <div id='searchView' class='searchView'></div>
</div>


                                                         25
Building The Application
Getting Started - The HTML and CSS


      Tabs


    TabView




   DetailView


     Search

                                     26
Building The Application
  Getting Started - The Google AJAX APIs
  • Bootstrapping the APIs and the application

<script src=quot;http://www.google.com/jsapiquot; type=quot;text/javascriptquot;>
</script>

<script type=quot;text/javascriptquot;>

  google.load('feeds', '1');
  google.load('search', '1');
  google.load('language', '1');
  google.setOnLoadCallback(ogbInit);

</script>




                                                            27
Building The Application
  Getting Started - The Google AJAX APIs
  • Initializing the application
function ogbInit() {
   initData();
   hookUI();
   bootTagWeights();
};



  • Boot the top articles over all blogs using Google Reader Tag
     – Reader tag ‘officialgoogleblogs-all’
     – Utilize mixed format (XML and JSON) for source identifier
     – Generate tag weights based on time and number of entries



                                                              28
Building The Application
  The Google AJAX Feed API
  • The top entries for tag cloud generation

function bootTagWeights() {
   var url = urlFromLabel('officialgoogleblogs-all');
   var feed = createFeed(url, google.feeds.Feed.MIXED_FORMAT);
   feed.load(tagWeightsLoaded);
};

function createFeed(url, opt_format) {
   var format = (opt_format || google.feeds.Feed.JSON_FORMAT);
   var feed = new google.feeds.Feed(url);
   feed.setResultFormat(format);
   feed.setNumEntries(30);
   return feed;
};




                                                             29
Building The Application
     The Google AJAX Feed API
     • tagWeightsLoaded callback

function tagWeightsLoaded(result) {

  ...
  // Pull out source from top blog entries..
  var ns = 'http://www.w3.org/2005/Atom';
  var entries = result.feed.entries;
  for (var i=0; i <entries.length; i++) {
    var e = entries[i];
    var sns=google.feeds.getElementsByTagNameNS(e.xmlNode,ns,'source');
    var ins= google.feeds.getElementsByTagNameNS(sns[0], ns, 'id');
    var id = ins[0].firstChild.nodeValue;
    ...
  }
  ...

};



                                                             30
Building The Application
The Google AJAX Feed API
• tagWeightsLoaded callback - source




                                       31
Building The Application
The Tag Cloud and Tag selection




  TagView




                                  32
Building The Application
  The Google AJAX Feed API
  • Loading and Displaying the Blog Feeds
function ogbShowFeed(url) {
   showStatus('Loading...');
   var feed = createFeed(url);
   feed.load(function(result) {
     feedLoaded(result, url);
   });
};

function feedLoaded(result, url) {
   var entries = result.feed.entries;
   for (var i=0; i <entries.length; i++) {
     feedControl.createHtml(entries[i]);
     if (entries[i].html) {
       feedView.appendChild(entries[i].html);
     }
   }
};



                                                33
Building The Application
  The Google AJAX Feed API - FeedControl

  •   The FeedControl and HTML generation
  •   Change JSON entry into standardized HTML nodes
  •   HTML attached to the JSON entry
  •   Applicable CSS classes

function feedLoaded(result, url) {
   var entries = result.feed.entries;
   for (var i=0; i <entries.length; i++) {
     feedControl.createHtml(entries[i]);
     if (entries[i].html) {
       feedView.appendChild(entries[i].html);
     }
   }
};



                                                       34
Building The Application
The Google AJAX Feed API - FeedControl




 HTML



                                         35
Building The Application
        The Google AJAX Feed API - FeedControl

        • Override the default CSS class rules
        • Base Structure
        <!-- One .gf-result per entry -->

                <div class=quot;gf-resultquot;>
                  <!-- Hyperlinked Entry Title -->
                  <div class=quot;gf-titlequot;>
                    <a class=quot;gf-titlequot;></a>
                  </div>
                  <!-- Author (Only if entry.author is present -->
                  <div class=quot;gf-authorquot;></div>
                  <!-- Published Date (Only if entry.publishedDate is present -->
                  <div class=quot;gf-relativePublishedDatequot;></div>
                  <!-- Snippet entry.contentSnippet -->
                  <div class=quot;gf-snippetquot;></div>
                </div>




                                                                             36
Building The Application
The Google AJAX Feed API - FeedControl

• Override the default CSS class rules
#feedContentView .gs-title {
   text-decoration : none;
 }
 #feedContentView .gf-result, #feedContentView .gs-result {
   padding-bottom : 8px;
   width : 90%;
   overflow : hidden;
 }
 #feedContentView .gf-title a, #feedContentView .gs-title a {
   font-size : 16px;
   color : #DD8800;
 }
 #feedContentView .gf-snippet, #feedContentView .gs-snippet {
   color : #DDDDDD;
   padding-left : 5px;
 }




                                                                37
Building The Application
The Blogs View




  Blogs




                           38
Building The Application
  The Blogs View

 • Custom JSON Objects
     – Maps all blogs to tags
     – Build view based on all tags and corresponding blogs
     – Tag selection and blog selection both generate detail view
var blogs = [
   {
     'id': 'feed/http://feeds.feedburner.com/GoogleAdsenseChinaBlog',
     'title': 'AdSense-u4e2du6587',
     'alternate': {
      'href': 'http://adsense.googlechinablog.com/',
      'type': 'text/html'
     },
     tags : ['publishers']
   },
   ....
];


                                                                39
Building The Application
 The Google AJAX Search API




SearchControl
                              40
Building The Application
The Google AJAX Search API

• Search Control
   – Place into DIV
• Searcher
   – CSE
   – searchComplete callback
// Generate Search Form and Searcher
searchForm = new google.search.SearchForm(false, searchView);
searchForm.setOnSubmitCallback(null, searchSubmit);

searcher = new google.search.WebSearch();
searcher.setResultSetSize(google.search.Search.LARGE_RESULTSET);
searcher.setSiteRestriction('000333901043914979043:yiaplyr6ps0');
searcher.setSearchCompleteCallback(null, searchComplete);




                                                          41
Building The Application
  The Search Results View




Search Results




                             42
Building The Application
The Google AJAX Language API - Translation




   Original




                                             43
Building The Application
The Google AJAX Language API - Translation




Translated




                                             44
Building The Application
    The Google AJAX Language API - Translation

    • Detecting Language
      – Load feed and then detect language of each entry
      – If not equal to CurrentLocale, add Translate icon
{
    feedControl.createHtml(entries[i]);
    feedView.appendChild(entries[i].html)
    var cb = detectCallbackFunction(url, i);
    // Check for translation by detecting snippet
    google.language.detect(entries[i].contentSnippet, cb);
}

function detectCallback(result, url, i) {
   var entry = feedView.entries[i];
   if (result.language != google.language.CurrentLocale) {
     log('Entry can be translated');
     addTranslateIcon(entry);
   }
};

                                                             45
Building The Application
  The Google AJAX Language API - Translation

 • Translating an entry
     – Translate icon triggers translation of title and snippet
     – Callback will replace contents appropriately
     – Icon will toggle back and forth
function processTranslation(index, elementId, result) {
   // Grab the correct item and replace..
   var entry = feedView.childNodes[index];
   var node;
   if (elementId == 'title') {
     node = entry.title();
   } else {
     node = entry.snippet();
   }
   node.innerHTML = result.translation;
};



                                                                  46
Building The iGoogle Gadget
iGoogle Gadget




                              47
Building The iGoogle Gadget
  The template
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?>
<Module>
    <ModulePrefs
         title=quot;All Google Blogsquot;
         directory_title=quot;All Google Blogsquot;
         title_url=quot;http://googleblog.blogspot.comquot;
         author=quot;Derek C.quot;
         author_affiliation=quot;Googlequot;
         author_location=quot;Bay Area, CAquot;
         author_email=quot;googlemodules+ogb@google.comquot;
         scrolling=quot;falsequot;
         category=quot;toolsquot;
         height=quot;450quot; >
    </ModulePrefs>
<Content type=quot;htmlquot;> <![CDATA[
 <<HTML version inserted here>>
]]>
</Content>
</Module>



                                                       48
Building The iGoogle Gadget
     Assets and absolute paths

    • All iGoogle gadgets run through intermediary hosts
       – gmodules.com
       – Assets, like backgrounds and images and JS files, need to be
         accessible.
.container {
   width:360px;
   height:450px;
   margin-top : 5px;
   margin-left : auto;
   margin-right : auto;
   position:relative;

    background:transparent url(background.png); ==>

    background:transparent url (http://foo.com/googleio/background.png);
}



                                                                 49
Reference
• General Documentation
  – http://code.google.com/apis/ajaxsearch
  – http://code.google.com/apis/ajaxfeeds
  – http://code.google.com/apis/ajaxlanguage
• FeedControl
  – http://code.google.com/apis/ajaxfeeds/documentation/
    reference.html#FeedControl
• Development Tools
  – Firebug
     • http://getfirebug.com
  – Firebug Tutorial
     • http://code.google.com/support/bin/answer.py?
       answer=94630&topic=11530


                                                           50
Advanced Gadget And Ui Development Using Googles Ajax Ap Is

Más contenido relacionado

La actualidad más candente

HTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input ValidationHTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input Validation
Todd Anglin
 

La actualidad más candente (20)

Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
 
HTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input ValidationHTML5 Mullet: Forms & Input Validation
HTML5 Mullet: Forms & Input Validation
 
The WebView Role in Hybrid Applications
The WebView Role in Hybrid ApplicationsThe WebView Role in Hybrid Applications
The WebView Role in Hybrid Applications
 
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
 
HTML5 and web technology update
HTML5 and web technology updateHTML5 and web technology update
HTML5 and web technology update
 
HTML5
HTML5HTML5
HTML5
 
What is HTML 5?
What is HTML 5?What is HTML 5?
What is HTML 5?
 
HTML5DevConf 2013 (October): WebGL is a game changer!
HTML5DevConf 2013 (October): WebGL is a game changer!HTML5DevConf 2013 (October): WebGL is a game changer!
HTML5DevConf 2013 (October): WebGL is a game changer!
 
HTML5 JS APIs
HTML5 JS APIsHTML5 JS APIs
HTML5 JS APIs
 
Real World Web Standards
Real World Web StandardsReal World Web Standards
Real World Web Standards
 
Amp by Google: The Present And Future Of Quick Content Delivery
Amp by Google: The Present And Future Of Quick Content DeliveryAmp by Google: The Present And Future Of Quick Content Delivery
Amp by Google: The Present And Future Of Quick Content Delivery
 
Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)
 
An Introduction To HTML5
An Introduction To HTML5An Introduction To HTML5
An Introduction To HTML5
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015
 
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
 
Building mobile applications with DrupalGap
Building mobile applications with DrupalGapBuilding mobile applications with DrupalGap
Building mobile applications with DrupalGap
 
Building Mobile Applications with Ionic
Building Mobile Applications with IonicBuilding Mobile Applications with Ionic
Building Mobile Applications with Ionic
 
Data binding 入門淺談
Data binding 入門淺談Data binding 入門淺談
Data binding 入門淺談
 
Diy frozen snow globe
Diy frozen snow globeDiy frozen snow globe
Diy frozen snow globe
 
The Rich Standard: Getting Familiar with HTML5
The Rich Standard: Getting Familiar with HTML5The Rich Standard: Getting Familiar with HTML5
The Rich Standard: Getting Familiar with HTML5
 

Destacado (20)

Benim IçIn Efes
Benim IçIn EfesBenim IçIn Efes
Benim IçIn Efes
 
Kvazar Micro Rebranding
Kvazar Micro RebrandingKvazar Micro Rebranding
Kvazar Micro Rebranding
 
Spa Packaging Design: Labeling
Spa Packaging Design: LabelingSpa Packaging Design: Labeling
Spa Packaging Design: Labeling
 
廖上鈿
廖上鈿廖上鈿
廖上鈿
 
2009年地方醫學會口頭報告–「方向變換性逆地型眼振的可能機轉」
2009年地方醫學會口頭報告–「方向變換性逆地型眼振的可能機轉」2009年地方醫學會口頭報告–「方向變換性逆地型眼振的可能機轉」
2009年地方醫學會口頭報告–「方向變換性逆地型眼振的可能機轉」
 
An Introduction To Android
An Introduction To AndroidAn Introduction To Android
An Introduction To Android
 
Teoria Musical
Teoria  MusicalTeoria  Musical
Teoria Musical
 
Christmas Carol Songbook Voice, Satb Various
Christmas Carol Songbook   Voice, Satb   VariousChristmas Carol Songbook   Voice, Satb   Various
Christmas Carol Songbook Voice, Satb Various
 
Dancing in the distraction factory
Dancing in the distraction factoryDancing in the distraction factory
Dancing in the distraction factory
 
PowertPoint lana
PowertPoint lanaPowertPoint lana
PowertPoint lana
 
陳省帆
陳省帆陳省帆
陳省帆
 
Boozefish Campaign
Boozefish CampaignBoozefish Campaign
Boozefish Campaign
 
1st Tanzania visit to Livingston Mtns
1st Tanzania visit to Livingston Mtns1st Tanzania visit to Livingston Mtns
1st Tanzania visit to Livingston Mtns
 
Hotel Californi The Eagles
Hotel Californi The EaglesHotel Californi The Eagles
Hotel Californi The Eagles
 
陳意茗
陳意茗陳意茗
陳意茗
 
陳靜如
陳靜如陳靜如
陳靜如
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
Nlf References
Nlf ReferencesNlf References
Nlf References
 
Comenius project_Intercultural dialogue
Comenius project_Intercultural dialogueComenius project_Intercultural dialogue
Comenius project_Intercultural dialogue
 
Blogger
BloggerBlogger
Blogger
 

Similar a Advanced Gadget And Ui Development Using Googles Ajax Ap Is

Frank Mantek Google G Data
Frank Mantek Google G DataFrank Mantek Google G Data
Frank Mantek Google G Data
deimos
 
Google G Data Reading And Writing Data On The Web
Google G Data Reading And Writing Data On The WebGoogle G Data Reading And Writing Data On The Web
Google G Data Reading And Writing Data On The Web
QConLondon2008
 
Google G Data Reading And Writing Data On The Web 1
Google G Data Reading And Writing Data On The Web 1Google G Data Reading And Writing Data On The Web 1
Google G Data Reading And Writing Data On The Web 1
QConLondon2008
 
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
mfrancis
 
A World Beyond Ajax Accessing Googles Ap Is From Flash And Non Java Script En...
A World Beyond Ajax Accessing Googles Ap Is From Flash And Non Java Script En...A World Beyond Ajax Accessing Googles Ap Is From Flash And Non Java Script En...
A World Beyond Ajax Accessing Googles Ap Is From Flash And Non Java Script En...
GoogleTecTalks
 

Similar a Advanced Gadget And Ui Development Using Googles Ajax Ap Is (20)

Using the Google AJAX APIs
Using the Google AJAX APIsUsing the Google AJAX APIs
Using the Google AJAX APIs
 
Google AJAX APIs
Google  AJAX APIsGoogle  AJAX APIs
Google AJAX APIs
 
Integrating Google APIs into Your Applications
Integrating Google APIs into Your ApplicationsIntegrating Google APIs into Your Applications
Integrating Google APIs into Your Applications
 
Frank Mantek Google G Data
Frank Mantek Google G DataFrank Mantek Google G Data
Frank Mantek Google G Data
 
Google Ajax APIs
Google Ajax APIsGoogle Ajax APIs
Google Ajax APIs
 
Google G Data Reading And Writing Data On The Web
Google G Data Reading And Writing Data On The WebGoogle G Data Reading And Writing Data On The Web
Google G Data Reading And Writing Data On The Web
 
Google G Data Reading And Writing Data On The Web 1
Google G Data Reading And Writing Data On The Web 1Google G Data Reading And Writing Data On The Web 1
Google G Data Reading And Writing Data On The Web 1
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Writing an extensible web testing framework ready for the cloud slide share
Writing an extensible web testing framework ready for the cloud   slide shareWriting an extensible web testing framework ready for the cloud   slide share
Writing an extensible web testing framework ready for the cloud slide share
 
Google I/O 2012 - Protecting your user experience while integrating 3rd party...
Google I/O 2012 - Protecting your user experience while integrating 3rd party...Google I/O 2012 - Protecting your user experience while integrating 3rd party...
Google I/O 2012 - Protecting your user experience while integrating 3rd party...
 
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
 
OSGi and Spring Data for simple (Web) Application Development
OSGi and Spring Data  for simple (Web) Application DevelopmentOSGi and Spring Data  for simple (Web) Application Development
OSGi and Spring Data for simple (Web) Application Development
 
Google Cloud Platform 2014Q1 - Starter Guide
Google Cloud Platform   2014Q1 - Starter GuideGoogle Cloud Platform   2014Q1 - Starter Guide
Google Cloud Platform 2014Q1 - Starter Guide
 
A World Beyond Ajax Accessing Googles Ap Is From Flash And Non Java Script En...
A World Beyond Ajax Accessing Googles Ap Is From Flash And Non Java Script En...A World Beyond Ajax Accessing Googles Ap Is From Flash And Non Java Script En...
A World Beyond Ajax Accessing Googles Ap Is From Flash And Non Java Script En...
 
GAE_20100112
GAE_20100112GAE_20100112
GAE_20100112
 
Intro to Google's AJAX apis @ Rich Web Experience East 08
Intro to Google's AJAX apis @ Rich Web Experience East 08Intro to Google's AJAX apis @ Rich Web Experience East 08
Intro to Google's AJAX apis @ Rich Web Experience East 08
 
Google App Engine for PHP
Google App Engine for PHP Google App Engine for PHP
Google App Engine for PHP
 
Making Chrome Extension with AngularJS
Making Chrome Extension with AngularJSMaking Chrome Extension with AngularJS
Making Chrome Extension with AngularJS
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
Google Chronicles: Analytics And Chrome
Google Chronicles: Analytics And ChromeGoogle Chronicles: Analytics And Chrome
Google Chronicles: Analytics And Chrome
 

Más de GoogleTecTalks

Web Hooks And The Programmable World Of Tomorrow
Web Hooks And The Programmable World Of TomorrowWeb Hooks And The Programmable World Of Tomorrow
Web Hooks And The Programmable World Of Tomorrow
GoogleTecTalks
 
Using The Google Collections Library For Java
Using The Google Collections Library For JavaUsing The Google Collections Library For Java
Using The Google Collections Library For Java
GoogleTecTalks
 
Voice Browsing And Multimodal Interaction In 2009
Voice Browsing And Multimodal Interaction In 2009Voice Browsing And Multimodal Interaction In 2009
Voice Browsing And Multimodal Interaction In 2009
GoogleTecTalks
 
V Code And V Data Illustrating A New Framework For Supporting The Video Annot...
V Code And V Data Illustrating A New Framework For Supporting The Video Annot...V Code And V Data Illustrating A New Framework For Supporting The Video Annot...
V Code And V Data Illustrating A New Framework For Supporting The Video Annot...
GoogleTecTalks
 
New Media Mavericks Will The Revolution Be Spidered
New Media Mavericks Will The Revolution Be SpideredNew Media Mavericks Will The Revolution Be Spidered
New Media Mavericks Will The Revolution Be Spidered
GoogleTecTalks
 
Performance Improvements In Browsers
Performance Improvements In BrowsersPerformance Improvements In Browsers
Performance Improvements In Browsers
GoogleTecTalks
 
13353102 Putting The Fun In Functional Applying Game Mechanics To Functional ...
13353102 Putting The Fun In Functional Applying Game Mechanics To Functional ...13353102 Putting The Fun In Functional Applying Game Mechanics To Functional ...
13353102 Putting The Fun In Functional Applying Game Mechanics To Functional ...
GoogleTecTalks
 
Black Cloud Patterns Toward The Future
Black Cloud Patterns Toward The FutureBlack Cloud Patterns Toward The Future
Black Cloud Patterns Toward The Future
GoogleTecTalks
 
Advanced Ruby Scripting For Sketch Up
Advanced Ruby Scripting For Sketch UpAdvanced Ruby Scripting For Sketch Up
Advanced Ruby Scripting For Sketch Up
GoogleTecTalks
 
Keynote Client Connectivity And The Cloud
Keynote Client Connectivity And The CloudKeynote Client Connectivity And The Cloud
Keynote Client Connectivity And The Cloud
GoogleTecTalks
 

Más de GoogleTecTalks (11)

Web Hooks And The Programmable World Of Tomorrow
Web Hooks And The Programmable World Of TomorrowWeb Hooks And The Programmable World Of Tomorrow
Web Hooks And The Programmable World Of Tomorrow
 
Using The Google Collections Library For Java
Using The Google Collections Library For JavaUsing The Google Collections Library For Java
Using The Google Collections Library For Java
 
Voice Browsing And Multimodal Interaction In 2009
Voice Browsing And Multimodal Interaction In 2009Voice Browsing And Multimodal Interaction In 2009
Voice Browsing And Multimodal Interaction In 2009
 
V Code And V Data Illustrating A New Framework For Supporting The Video Annot...
V Code And V Data Illustrating A New Framework For Supporting The Video Annot...V Code And V Data Illustrating A New Framework For Supporting The Video Annot...
V Code And V Data Illustrating A New Framework For Supporting The Video Annot...
 
New Media Mavericks Will The Revolution Be Spidered
New Media Mavericks Will The Revolution Be SpideredNew Media Mavericks Will The Revolution Be Spidered
New Media Mavericks Will The Revolution Be Spidered
 
Performance Improvements In Browsers
Performance Improvements In BrowsersPerformance Improvements In Browsers
Performance Improvements In Browsers
 
13353102 Putting The Fun In Functional Applying Game Mechanics To Functional ...
13353102 Putting The Fun In Functional Applying Game Mechanics To Functional ...13353102 Putting The Fun In Functional Applying Game Mechanics To Functional ...
13353102 Putting The Fun In Functional Applying Game Mechanics To Functional ...
 
Black Cloud Patterns Toward The Future
Black Cloud Patterns Toward The FutureBlack Cloud Patterns Toward The Future
Black Cloud Patterns Toward The Future
 
Advanced Ruby Scripting For Sketch Up
Advanced Ruby Scripting For Sketch UpAdvanced Ruby Scripting For Sketch Up
Advanced Ruby Scripting For Sketch Up
 
Advanced Kml
Advanced KmlAdvanced Kml
Advanced Kml
 
Keynote Client Connectivity And The Cloud
Keynote Client Connectivity And The CloudKeynote Client Connectivity And The Cloud
Keynote Client Connectivity And The Cloud
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Advanced Gadget And Ui Development Using Googles Ajax Ap Is

  • 1.
  • 2. Advanced Gadget and UI Development Using Google’s AJAX APIs Derek Collison 5/29/2008
  • 3. Agenda • The Application Concept • Basic Building Blocks • The Google AJAX APIs – Background – Google AJAX Search API – Google AJAX Feed API – Google AJAX Language API • Goals – Utilize the Raw AJAX APIs and advanced features – Show how Reader and Google CSE are utilized – How to wrap the application as a gadget 3
  • 4. The Application Concept • Showcase the content on all of Google’s Blogs • Provide a tag cloud view for categories • Also a hierarchical view of all blogs grouped by tag • Allow search over all blogs • Provide language translation where applicable • Deploy as an iGoogle gadget 4
  • 5. The Basic Building Blocks • HTML/DOM • CSS • Javascript • Tools – Editor – Debugger - Firebug – Performance - YSlow • The Google AJAX Apis – Search – Feed – Language • Google Reader (www.google.com/reader) • Google Custom Search Engines (www.google.com/cse) • iGoogle 5
  • 6. Tools Firefox and Firebug (http://www.getfirebug.com/) Don’t develop without them! 6
  • 7. Google AJAX APIs Delivering the Web to Your Applications (Search, Feeds, Language) • RESTful data access layer – JSON/JSON-P AJAX APIs • JavaScript Runtime – Designed for ease of use • JavaScript Controls and UI elements – Custom integration and styling 7
  • 8. Google AJAX APIs Background • Comprehensive access to Google Systems (Search, Feeds, Language) • End to end API stack: – Data Access via JavaScript Methods and REST – Built in Native UI and Large Suite of Advanced Controls • Large, diverse customer base – Sites: Long Tail and Short Tail Sites (100 pv/d – 10m+ pv/d) – Developers: Pro Web Developers – Scripters – Bloggers • High Speed, Low Latency, Globally Available JavaScript Controls and UI JavaScript Runtime AJAX RESTful Data Access 8
  • 9. Google AJAX Search API • Web • Video • News • Image • Local • Book • Blog 9
  • 10. Google AJAX Feed API • Load • Find • Lookup 10
  • 11. Google AJAX Language API • Translation • Language Detection 11
  • 14. What we saw • The tag cloud view • A detail entry/snippet view • The hierarchical blog view • Search control and results • Translation capabilities 14
  • 15. How do we build it? • Building Blocks – Google Reader (content feeds) – Custom Search Engine – AJAX APIs (Feed, Search, Language) • Getting Started – Build standalone HTML/CSS/JS – google.load() – google.setOnLoadCallback() • Putting it all together – Application details • Making an iGoogle Gadget – Wrapping things into iGoogle 15
  • 16. Building The Application Building Blocks - Google Reader - www.google.com/reader • Subscriptions – Blog management • Tags – Grouping Subscriptions/Blogs – Tag based pages – Tag based feeds • Tag Cloud – All blogs top 20 • Hierarchical View – All categorized blogs 16
  • 17. Building The Application Building Blocks - Google Reader - www.google.com/reader Tags and Categorization 17
  • 18. Building The Application Building Blocks - Google Reader - www.google.com/reader Tags and Sharing Feeds 18
  • 19. Building The Application Building Blocks - Google Reader - www.google.com/reader Tags and Sharing Feeds 19
  • 20. Building The Application Building Blocks - Google Reader - www.google.com/reader Tags and Sharing Feeds - Ads Verticals Example http://www.google.com/reader/shared/user/X/label/Ads%20Verticals 20
  • 21. Building The Application Building Blocks - Google Reader - www.google.com/reader Tags and Sharing Feeds - Ads Verticals Feed http://www.google.com/reader/public/atom/user/X/label/Ads%20Verticals 21
  • 22. Building The Application Building Blocks - Custom Search - www.google.com/cse • CSE – Custom Search Engine – Better alternative than site restriction for large # of sites – Enables search of all blogs – All Google Blogs > 100 blogs – Integrates directly with AJAX WebSearch 22
  • 23. Building The Application Building Blocks - Custom Search - www.google.com/cse 23
  • 24. Building The Application Building Blocks - The Google AJAX APIs • Feed API – Utilize Google Reader’s tag based feeds – Mixed Format (XML and JSON) for tag cloud – FeedControl for HTML generation • Search API – Blog or Web Search – Customer Search Engine – Why not Blog Search? • Language API – Detecting non-native languages – Allow translation 24
  • 25. Building The Application Getting Started - The HTML and CSS <div id='container' class='container'> <div id='tabs' class='tabs'> <div id='categories' class='tabHeader tabActive'> Categories </div> <div id='blogs' class='tabHeader tabInactive'> Blogs </div> <div id='search' class='tabHeader tabInactive'> Search </div> </div> <div id='tabView' class='tabView'> <div id='tabContentFrame' class='tabContentFrame'></div> </div> <div id='feedView' class='feedView'> <div id='feedContentView' class='feedContentView'></div> </div> <div id='searchView' class='searchView'></div> </div> 25
  • 26. Building The Application Getting Started - The HTML and CSS Tabs TabView DetailView Search 26
  • 27. Building The Application Getting Started - The Google AJAX APIs • Bootstrapping the APIs and the application <script src=quot;http://www.google.com/jsapiquot; type=quot;text/javascriptquot;> </script> <script type=quot;text/javascriptquot;> google.load('feeds', '1'); google.load('search', '1'); google.load('language', '1'); google.setOnLoadCallback(ogbInit); </script> 27
  • 28. Building The Application Getting Started - The Google AJAX APIs • Initializing the application function ogbInit() { initData(); hookUI(); bootTagWeights(); }; • Boot the top articles over all blogs using Google Reader Tag – Reader tag ‘officialgoogleblogs-all’ – Utilize mixed format (XML and JSON) for source identifier – Generate tag weights based on time and number of entries 28
  • 29. Building The Application The Google AJAX Feed API • The top entries for tag cloud generation function bootTagWeights() { var url = urlFromLabel('officialgoogleblogs-all'); var feed = createFeed(url, google.feeds.Feed.MIXED_FORMAT); feed.load(tagWeightsLoaded); }; function createFeed(url, opt_format) { var format = (opt_format || google.feeds.Feed.JSON_FORMAT); var feed = new google.feeds.Feed(url); feed.setResultFormat(format); feed.setNumEntries(30); return feed; }; 29
  • 30. Building The Application The Google AJAX Feed API • tagWeightsLoaded callback function tagWeightsLoaded(result) { ... // Pull out source from top blog entries.. var ns = 'http://www.w3.org/2005/Atom'; var entries = result.feed.entries; for (var i=0; i <entries.length; i++) { var e = entries[i]; var sns=google.feeds.getElementsByTagNameNS(e.xmlNode,ns,'source'); var ins= google.feeds.getElementsByTagNameNS(sns[0], ns, 'id'); var id = ins[0].firstChild.nodeValue; ... } ... }; 30
  • 31. Building The Application The Google AJAX Feed API • tagWeightsLoaded callback - source 31
  • 32. Building The Application The Tag Cloud and Tag selection TagView 32
  • 33. Building The Application The Google AJAX Feed API • Loading and Displaying the Blog Feeds function ogbShowFeed(url) { showStatus('Loading...'); var feed = createFeed(url); feed.load(function(result) { feedLoaded(result, url); }); }; function feedLoaded(result, url) { var entries = result.feed.entries; for (var i=0; i <entries.length; i++) { feedControl.createHtml(entries[i]); if (entries[i].html) { feedView.appendChild(entries[i].html); } } }; 33
  • 34. Building The Application The Google AJAX Feed API - FeedControl • The FeedControl and HTML generation • Change JSON entry into standardized HTML nodes • HTML attached to the JSON entry • Applicable CSS classes function feedLoaded(result, url) { var entries = result.feed.entries; for (var i=0; i <entries.length; i++) { feedControl.createHtml(entries[i]); if (entries[i].html) { feedView.appendChild(entries[i].html); } } }; 34
  • 35. Building The Application The Google AJAX Feed API - FeedControl HTML 35
  • 36. Building The Application The Google AJAX Feed API - FeedControl • Override the default CSS class rules • Base Structure         <!-- One .gf-result per entry -->         <div class=quot;gf-resultquot;>           <!-- Hyperlinked Entry Title -->           <div class=quot;gf-titlequot;>             <a class=quot;gf-titlequot;></a>           </div>           <!-- Author (Only if entry.author is present -->           <div class=quot;gf-authorquot;></div>           <!-- Published Date (Only if entry.publishedDate is present -->           <div class=quot;gf-relativePublishedDatequot;></div>           <!-- Snippet entry.contentSnippet -->           <div class=quot;gf-snippetquot;></div>         </div> 36
  • 37. Building The Application The Google AJAX Feed API - FeedControl • Override the default CSS class rules #feedContentView .gs-title { text-decoration : none; } #feedContentView .gf-result, #feedContentView .gs-result { padding-bottom : 8px; width : 90%; overflow : hidden; } #feedContentView .gf-title a, #feedContentView .gs-title a { font-size : 16px; color : #DD8800; } #feedContentView .gf-snippet, #feedContentView .gs-snippet { color : #DDDDDD; padding-left : 5px; } 37
  • 38. Building The Application The Blogs View Blogs 38
  • 39. Building The Application The Blogs View • Custom JSON Objects – Maps all blogs to tags – Build view based on all tags and corresponding blogs – Tag selection and blog selection both generate detail view var blogs = [ { 'id': 'feed/http://feeds.feedburner.com/GoogleAdsenseChinaBlog', 'title': 'AdSense-u4e2du6587', 'alternate': { 'href': 'http://adsense.googlechinablog.com/', 'type': 'text/html' }, tags : ['publishers'] }, .... ]; 39
  • 40. Building The Application The Google AJAX Search API SearchControl 40
  • 41. Building The Application The Google AJAX Search API • Search Control – Place into DIV • Searcher – CSE – searchComplete callback // Generate Search Form and Searcher searchForm = new google.search.SearchForm(false, searchView); searchForm.setOnSubmitCallback(null, searchSubmit); searcher = new google.search.WebSearch(); searcher.setResultSetSize(google.search.Search.LARGE_RESULTSET); searcher.setSiteRestriction('000333901043914979043:yiaplyr6ps0'); searcher.setSearchCompleteCallback(null, searchComplete); 41
  • 42. Building The Application The Search Results View Search Results 42
  • 43. Building The Application The Google AJAX Language API - Translation Original 43
  • 44. Building The Application The Google AJAX Language API - Translation Translated 44
  • 45. Building The Application The Google AJAX Language API - Translation • Detecting Language – Load feed and then detect language of each entry – If not equal to CurrentLocale, add Translate icon { feedControl.createHtml(entries[i]); feedView.appendChild(entries[i].html) var cb = detectCallbackFunction(url, i); // Check for translation by detecting snippet google.language.detect(entries[i].contentSnippet, cb); } function detectCallback(result, url, i) { var entry = feedView.entries[i]; if (result.language != google.language.CurrentLocale) { log('Entry can be translated'); addTranslateIcon(entry); } }; 45
  • 46. Building The Application The Google AJAX Language API - Translation • Translating an entry – Translate icon triggers translation of title and snippet – Callback will replace contents appropriately – Icon will toggle back and forth function processTranslation(index, elementId, result) { // Grab the correct item and replace.. var entry = feedView.childNodes[index]; var node; if (elementId == 'title') { node = entry.title(); } else { node = entry.snippet(); } node.innerHTML = result.translation; }; 46
  • 47. Building The iGoogle Gadget iGoogle Gadget 47
  • 48. Building The iGoogle Gadget The template <?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?> <Module> <ModulePrefs title=quot;All Google Blogsquot; directory_title=quot;All Google Blogsquot; title_url=quot;http://googleblog.blogspot.comquot; author=quot;Derek C.quot; author_affiliation=quot;Googlequot; author_location=quot;Bay Area, CAquot; author_email=quot;googlemodules+ogb@google.comquot; scrolling=quot;falsequot; category=quot;toolsquot; height=quot;450quot; > </ModulePrefs> <Content type=quot;htmlquot;> <![CDATA[ <<HTML version inserted here>> ]]> </Content> </Module> 48
  • 49. Building The iGoogle Gadget Assets and absolute paths • All iGoogle gadgets run through intermediary hosts – gmodules.com – Assets, like backgrounds and images and JS files, need to be accessible. .container { width:360px; height:450px; margin-top : 5px; margin-left : auto; margin-right : auto; position:relative; background:transparent url(background.png); ==> background:transparent url (http://foo.com/googleio/background.png); } 49
  • 50. Reference • General Documentation – http://code.google.com/apis/ajaxsearch – http://code.google.com/apis/ajaxfeeds – http://code.google.com/apis/ajaxlanguage • FeedControl – http://code.google.com/apis/ajaxfeeds/documentation/ reference.html#FeedControl • Development Tools – Firebug • http://getfirebug.com – Firebug Tutorial • http://code.google.com/support/bin/answer.py? answer=94630&topic=11530 50