• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Dan Holevoet, Google
 

Dan Holevoet, Google

on

  • 1,094 views

Presentation by Dan Holevote (Google) at the #inboxlove conference

Presentation by Dan Holevote (Google) at the #inboxlove conference

Statistics

Views

Total Views
1,094
Views on SlideShare
1,094
Embed Views
0

Actions

Likes
0
Downloads
7
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Dan Holevoet, Google Dan Holevoet, Google Presentation Transcript

    • Dan Holevoet Developer Relations Deep Dive: Contextual Gadgets
    • Why gadgets?
    • Why gadgets?
        • Gadgets bring your application into Google Apps
        • People spend  a lot  of time in Google Apps
        • Embeddable pieces of functionality
    • Why contextual gadgets?
    • Why contextual gadgets?
    • Why contextual gadgets?
    • What is a gadget?
    • What is a gadget? <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?>  <Module>    <ModulePrefs title=&quot;hello world example&quot; />     <Content type=&quot;html&quot;>      <![CDATA[         Hello, world!      ]]>    </Content>  </Module>
    • What is a gadget?
        • 'dynamic-height' allows the gadget to grow and shrink depending on content
        • 'views' allow multiple facets of an application
          • 'home' and 'canvas' views in most implementations
        • osapi.http allows remote data access
          • Provides OAuth signing
          • Supports multiple HTTP methods
          • Supports JSON parsing of responses
        • google.contentmatch() for contextual behavior
    • What do contextual gadgets do?
    • What do contextual gadgets do?
        • Match on fields of an incoming email, eg:
          • To
          • From
          • Subject
          • Message body
        • Matches trigger a gadget to display, and provide context
    • What do contextual gadgets do?
    • What do contextual gadgets do?
    • What makes a contextual gadget?
    • Contextual gadgets | components
        • Each contextual gadget is made up of:
          • A gadget
          • One or more extractors
          • Associated descriptions in the application manifest
    • Contextual gadgets | google.contentmatch var matches =    google.contentmatch.getContentMatches(); var context = {}; for (var match in matches) {    for (var key in matches[match]) {      context[key] = matches[match][key];    } } // Subject is now stored in context.subject
    • Contextual gadgets | extractors
        • Extractors are regular expressions, using RE2 (supports most of PCRE)
        • Google provides a set of pre-canned extractors that developers can use in their gadgets
        • Some of the pre-canned extractors:
          • EmailAddressExtractor
          • EmailBodyExtractor
          • EmailTimeExtractor
          • HttpLinkExtractor
          • MessageIDExtractor
          • RecipientEmailExtractor
          • SenderEmailExtractor
          • SubjectExtractor
          • USPhoneExtractor
    • Contextual gadgets | extractors
        • Pre-canned extractors may be filtered to apply only on a subset of emails
        • An example:
          • SubjectExtractor will match on all emails
          • Filtering allows only a subset of subjects to trigger the gadget
          • Filters are applied by using a regular expression on a field of the extractor
      <Extension id=&quot;SubjectExtractor&quot;    type=&quot;contextExtractor&quot;>    <Url>google.com:SubjectExtractor</Url>    <Param name=&quot;subject&quot;      value=&quot;Hello World.*&quot;/>    <Triggers ref=&quot;MyGadget&quot;/>    <Container name=&quot;mail&quot;/> </Extension>
    • Contextual gadgets | application manifest
        • The manifest describes the components of the contextual gadget:
          • The extractors
          • Filters on pre-canned extractors
          • The gadgets to trigger
          • Scopes for data access
    • Contextual gadgets | application manifest … <Extension id=&quot;testExtractor&quot;    type=&quot;contextExtractor&quot;>    <Url>TestExtractorId</Url>    <Param name=&quot;extractedField&quot; value=&quot;regexp&quot;/>    <Triggers ref=&quot;exampleGadget&quot;/>    <Scope ref=&quot;exampleScope&quot;/>    <Container name=&quot;mail&quot;/> </Extension> <Extension id=&quot;exampleGadget&quot; type=&quot;gadget&quot;>    <Url>http://example.com/mygadget.xml</Url>    <Container name=&quot;mail&quot;/> </Extension> …
    • Contextual gadgets | application manifest … <Extension id=&quot;testExtractor&quot;    type=&quot;contextExtractor&quot;>    <Url>TestExtractorId</Url>    <Param name=&quot;extractedField&quot; value=&quot;regexp&quot;/>    <Triggers ref=&quot;exampleGadget&quot;/>    <Scope ref=&quot;exampleScope&quot;/>    <Container name=&quot;mail&quot;/> </Extension> <Extension  id=&quot;exampleGadget&quot;  type=&quot;gadget&quot;>    <Url>http://example.com/mygadget.xml</Url>    <Container name=&quot;mail&quot;/> </Extension> …
    • Contextual gadgets | application manifest … <Extension id=&quot;testExtractor&quot;    type=&quot;contextExtractor&quot;>    <Url>TestExtractorId</Url>    <Param name=&quot;extractedField&quot; value=&quot;regexp&quot;/>    <Triggers ref=&quot;exampleGadget&quot;/>    <Scope ref=&quot;exampleScope&quot;/>    <Container name=&quot;mail&quot;/> </Extension> <Extension id=&quot;exampleGadget&quot; type=&quot;gadget&quot;>    <Url>http://example.com/mygadget.xml</Url>    <Container name=&quot;mail&quot;/> </Extension> …
    • Contextual gadgets | application manifest … <Scope id=&quot; exampleScope &quot;>    <Url>tag:google.com,2010:      auth/contextual/extractor/SUBJECT</Url>    <Reason>This gadget uses the subject line to      determine context</Reason> </Scope> …
    • Contextual gadgets | application manifest … <Scope id=&quot;exampleScope&quot;>    <Url>tag:google.com,2010:      auth/contextual/extractor/SUBJECT</Url>    <Reason>This gadget uses the subject line to      determine context</Reason> </Scope> …
    • Contextual gadgets | application manifest
    • Best practices
    • Best practices | matching and extraction
        • Be contextual — try and match on as few emails as possible
        • Use the minimum number of scopes necessary
    • Best practices | safe gadgets
        • Stick to HTML and CSS specs
        • Use supported frameworks:
          • JQuery
          • ECMAScript 5 Strict
      • Good:
      •    jQuery('#content').append('hello world!');
      •    document.getElementById('content').
      •      appendChild(document.createTextNode(
      •        'hello world!'));
      • Bad:
      •    document.write('hello world!');
      • Ugly:
      •    window.parent.location = mySite;
    • Best practices | complicated email logic
        • Use IMAP when extractors don't offer enough
          • MessageIDExtractor supplies message IDs
          • IMAP + OAuth:
            • http://code.google.com/p/google-mail-xoauth-tools/
          • Marketplace access to IMAP
            • Scope: https://mail.google.com/
    • Testing and distribution
    • Testing and distribution
        • Log into the Google Apps Marketplace: http://google.com/enterprise/marketplace/
        • Create a vendor profile if you don't have one
        • Create a listing
        • Enter an application manifest
        • Deploy to your domain
    • Getting started
    • Getting started
        • Developer documentation:
          • Gmail: http://code.google.com/apis/gmail/
          • Marketplace: http://code.google.com/googleapps/marketplace/
        • Developer forum:
          • http://code.google.com/googleapps/support/gadgets/
        • RE2:
          • http://code.google.com/p/re2/
    • Questions?