Your SlideShare is downloading. ×
Dan Holevoet, Google
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Dan Holevoet, Google

866

Published on

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

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

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
866
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Dan Holevoet Developer Relations Deep Dive: Contextual Gadgets
  • 2. Why gadgets?
  • 3. Why gadgets?
      • Gadgets bring your application into Google Apps
      • People spend  a lot  of time in Google Apps
      • Embeddable pieces of functionality
  • 4. Why contextual gadgets?
  • 5. Why contextual gadgets?
  • 6. Why contextual gadgets?
  • 7. What is a gadget?
  • 8. 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>
  • 9. 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
  • 10. What do contextual gadgets do?
  • 11. 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
  • 12. What do contextual gadgets do?
  • 13. What do contextual gadgets do?
  • 14. What makes a contextual gadget?
  • 15. Contextual gadgets | components
      • Each contextual gadget is made up of:
        • A gadget
        • One or more extractors
        • Associated descriptions in the application manifest
  • 16. 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
  • 17. 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
  • 18. 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>
  • 19. 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
  • 20. 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> …
  • 21. 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> …
  • 22. 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> …
  • 23. 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> …
  • 24. 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> …
  • 25. Contextual gadgets | application manifest
  • 26. Best practices
  • 27. Best practices | matching and extraction
      • Be contextual — try and match on as few emails as possible
      • Use the minimum number of scopes necessary
  • 28. 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;
  • 29. 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/
  • 30. Testing and distribution
  • 31. 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
  • 32. Getting started
  • 33. 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/
  • 34. Questions?

×