SlideShare a Scribd company logo
1 of 37
Download to read offline
How clean semantic
 markup in your HTML can
 power Facebook Connect
 Chris Thorpe




FACEBOOK DEVELOPER GARAGE FOWA EDITION


So this looks like a bit of an odd title
Semantic
                                         Web




FACEBOOK DEVELOPER GARAGE FOWA EDITION


Do I mean this? Well no not yet, although RDF and other forms of semantic markup are gaining ground
but some of the principles which underly RDF’s precursor - semantically marked up HTML or XHTML
FACEBOOK DEVELOPER GARAGE FOWA EDITION


Stuff more like this, either marked up in real microformats like hAtom or the wonderful hRecipe. If
more publishers can build these sorts of formats into their products then we’ll be able to make really
simple little bits of code which can extract, scrape and most importantly extend the information and
functionality of pages and sites
<ul id="clippings">
     
     <li class="a-clipping">
     
     
     <div class="clipping-contents" id="clipping-265621">
     
     
     
    <h2><a href="http://www.guardian.co.uk/media/2009/aug/26/big-brother-dropped-
     channel-4">Big Brother axed by Channel 4</a></h2>
     
     
     
    <div class="clipping-trail-text" id="clipping-trail-text-265621">Broadcaster
     confirms that reality show will be dropped after 11th series in 2010. By Mark Sweney and Leigh
     Holmwood</div>
     
     
     
    <p class="clipped-on" id="clipped-on-265621">Clipped on 26 August 2009&nbsp;
     
     
     
    
    <a class="show-edit-clipping" href="http://www.guardian.co.uk/tools/clipping/
     265621/edit">Edit</a>
     
     
     
    </p>
     
     
     </div>
     
     </li>
     
     <li class="a-clipping">
     
     
     <div class="clipping-contents" id="clipping-265614">
     
     
     
    <h2><a href="http://www.guardian.co.uk/world/2009/aug/26/us-senator-ted-kennedy-
     dies" >Senator Ted Kennedy dies aged 77</a></h2>
     
     
     
    <div id="clipping-trail-text-265614">One of the most influential and longest
     serving senators in US history had battled brain cancer since May 2008</div>
     
     
     
    <p class="clipped-on" id="clipped-on-265614">Clipped on 26 August 2009&nbsp;
     
     
     
    
    <a class="show-edit-clipping" href="http://www.guardian.co.uk/tools/clipping/
     265614/edit" name="&lid={yourClippings}{Edit}&lpos={yourClippings}{5}">Edit</a>
     
     
     
    </p>
     
     
     </div>
     
     </li>
     </ul>




FACEBOOK DEVELOPER GARAGE FOWA EDITION


But we can start today with HTML with some simple semantic markup telling us what each bit does, like
this rather simplified bit from The Guardian
FACEBOOK DEVELOPER GARAGE FOWA EDITION


Which outputs something which looks a bit like this
<ul>
       
     <li>
       
     
     <div>
       
     
     
     <h2><a href="">Title</a></h2>
       
     
     
     <div>Trail text</div>
       
     
     
     <p>Date
       
     
     
     
    <a href="">Edit</a>
       
     
     
     </p>
       
     
     </div>
       
     </li>
       </ul>




FACEBOOK DEVELOPER GARAGE FOWA EDITION


And if we simplify it further we get this... not too interesting or useful... and certainly not semantic, but
it shows the structure
URL          title


                                                          trail text


                                                          actions




FACEBOOK DEVELOPER GARAGE FOWA EDITION


What we get from this sort of structure is this
<ul id="clippings">
       
     <li class="a-clipping">
       
     
     <div class="clipping-contents" id="clipping-XXXXXX">
       
     
     
    <h2><a href="">Title</a></h2>
       
     
     
    <div class="clipping-trail-text" id="clipping-trail-text-XXXXXX">Trail text</div>
       
     
     
    <p class="clipped-on" id="clipped-on-XXXXXX">Date
       
     
     
    
    <a class="show-edit-clipping" href="">Edit</a>
       
     
     
    </p>
       
     
     </div>
       
     </li>
       </ul>




FACEBOOK DEVELOPER GARAGE FOWA EDITION


We can make it more semantic with a few id’s and classes which relate to the function of the text
contained within some of the nodes
URL   title


                                                   trail text




FACEBOOK DEVELOPER GARAGE FOWA EDITION


And when you look at it, this
FACEBOOK DEVELOPER GARAGE FOWA EDITION


has a lot in common with the sort of things you’d want to go into the stream
<ul id="clippings">
       
     <li class="a-clipping">
       
     
     <div class="clipping-contents" id="clipping-XXXXXX">
       
     
     
    <h2><a href="">Title</a></h2>
       
     
     
    <div class="clipping-trail-text" id="clipping-trail-text-XXXXXX">Trail text</div>
       
     
     
    <p class="clipped-on" id="clipped-on-XXXXXX">Date
       
     
     
    
    <a class="show-edit-clipping" href="">Edit</a>
       
     
     
    </p>
       
     
     </div>
       
     </li>
       </ul>




FACEBOOK DEVELOPER GARAGE FOWA EDITION


So how do we get from this on The Guardian
FACEBOOK DEVELOPER GARAGE FOWA EDITION


to this on Facebook
FACEBOOK DEVELOPER GARAGE FOWA EDITION


which brings us to this...

The Guardian is interested in all sorts of things to do with identity and distributed/aggregated identity
and one really great way to learn is to experiment and prototype
<ul id="clippings">
       
     <li class="a-clipping">
       
     
     <div class="clipping-contents" id="clipping-XXXXXX">
       
     
     
    <h2><a href="">Title</a></h2>
       
     
     
    <div class="clipping-trail-text" id="clipping-trail-text-XXXXXX">Trail text</div>
       
     
     
    <p class="clipped-on" id="clipped-on-XXXXXX">Date
       
     
     
    
    <a class="show-edit-clipping" href="">Edit</a>
       
     
     
    </p>
       
     
     </div>
       
     </li>
       </ul>




FACEBOOK DEVELOPER GARAGE FOWA EDITION


So if we want to go from this
FACEBOOK DEVELOPER GARAGE FOWA EDITION


to this sort of thing, how do we do it simply and in a prototype way, in say about an hour to test out
how it works so we can make a case for it to go into production and help the engineers
FACEBOOK DEVELOPER GARAGE FOWA EDITION


this is a good start, JQuery is a really lovely JavaScript framework and since at it’s most basic level
Facebook Connect is a client side development environment a good JavaScript libary is all we need to
build a prototype
<ul id="clippings">
       
     <li class="a-clipping">
       
     
     <div class="clipping-contents" id="clipping-XXXXXX">
       
     
     
    <h2><a href="">Title</a></h2>
       
     
     
    <div class="clipping-trail-text" id="clipping-trail-text-XXXXXX">Trail text</div>
       
     
     
    <p class="clipped-on" id="clipped-on-XXXXXX">Date
       
     
     
    
    <a class="show-edit-clipping" href="">Edit</a>
       
     
     
    </p>
       
     
     </div>
       
     </li>
       </ul>




FACEBOOK DEVELOPER GARAGE FOWA EDITION


So how do we get the good bits from this...
<ul id="clippings">
        
     <li class="a-clipping">
        
     
     <div class="clipping-contents" id="clipping-XXXXXX">
        
     
     
    <h2><a href="">Title</a></h2>
        
     
     
    <div class="clipping-trail-text" id="clipping-trail-text-XXXXXX">Trail text</div>
        
     
     
    <p class="clipped-on" id="clipped-on-XXXXXX">Date
        
     
     
    
    <a class="show-edit-clipping" href="">Edit</a>
        
     
     
    </p>
        
     
     </div>
        
     </li>
        </ul>





      var title = $('a', $('#clipping-'+ id)).html();

      var trailtext = $('#clipping-trail-text-'+ id).html();

      var href = $('a', $('#clipping-'+ id)).attr('href');




FACEBOOK DEVELOPER GARAGE FOWA EDITION


    it’s pretty easy, it’s actually about 3 lines of JQuery get us the relevant bits of content if the content is
    marked up well, so how do we put it together with Connect
actions




FACEBOOK DEVELOPER GARAGE FOWA EDITION


but how would we add some actions to post to Facebook
1
                            2
                                                                                        actions




FACEBOOK DEVELOPER GARAGE FOWA EDITION


well actually part of the clue is that within the UL there is an iterator waiting to be unlocked
<ul id="clippings">
     
     <li class="a-clipping">
     
     
     <div class="clipping-contents" id="clipping-XXXXXX">
     
     
     
    <h2><a href="">Title</a></h2>

    1
     
     
     
    <div class="clipping-trail-text" id="clipping-trail-text-XXXXXX">Trail text</div>
     
     
     
    <p class="clipped-on" id="clipped-on-XXXXXX">Date
     
     
     
    
    <a class="show-edit-clipping" href="">Edit</a>
     
     
     
    </p>
     
     
     </div>
     
     </li>
     
     <li class="a-clipping">
     
     
     <div class="clipping-contents" id="clipping-YYYYYY">


    2
     
     
     
    <h2><a href="">Title</a></h2>
     
     
     
    <div class="clipping-trail-text" id="clipping-trail-text-YYYYYY">Trail text</div>
     
     
     
    <p class="clipped-on" id="clipped-on-YYYYYY">Date
     
     
     
    
    <a class="show-edit-clipping" href="">Edit</a>
     
     
     
    </p>
     
     
     </div>
     
     </li>
     </ul>




FACEBOOK DEVELOPER GARAGE FOWA EDITION


We can build the iterator out of the HTML and JQuery, within the UL which has the unique id of
clippings there are DIVs which have a class of clipping-contents

and because we’ve got the HTML maked up with the clipping id we can do something interesting with
this
<ul id="clippings">
     
     <li class="a-clipping">
     
     
     <div class="clipping-contents" id="clipping-265621">
     
     
     </div>
     
     </li>
     
     <li class="a-clipping">
     
     
     <div class="clipping-contents" id="clipping-265614">
     
     
     </div>
     
     </li>
     </ul>


     $("#clippings .clipping-contents").each( function() {
     
    var currentid = $(this).attr('id').replace('clipping-', '');
     
    $('#clipped-on-'+ currentid).append(" | <a href="javascript:onPost("+ currentid +")">share
     on Facebook</a>");
     });




FACEBOOK DEVELOPER GARAGE FOWA EDITION


like this, which basically says for each time you find a something with a class of clipping-contents then
get the content id of it through a bit of JavaScript string manipulation
<ul id="clippings">
     
     <li class="a-clipping">
     
     
     <div class="clipping-contents" id="clipping-265621">
     
     
     </div>
     
     </li>
     
     <li class="a-clipping">
     
     
     <div class="clipping-contents" id="clipping-265614">
     
     
     </div>
     
     </li>
     </ul>


     $("#clippings .clipping-contents").each( function() {
     
    var currentid = $(this).attr('id').replace('clipping-', '');
     
    $('#clipped-on-'+ currentid).append(" | <a href="javascript:onPost("+ currentid +")">share
     on Facebook</a>");
     });




FACEBOOK DEVELOPER GARAGE FOWA EDITION




then in the node which has an id of clipped-on and that content id append a piece of HTML which gives
the link to share on Facebook
new actions



FACEBOOK DEVELOPER GARAGE FOWA EDITION




then in the node which has an id of clipped-on and that content id append a piece of HTML which gives
the link to share on Facebook
<script type="text/javascript">
     
     function onConnected() {
     
    
    
    $('#connectbutton').remove();
     
    
    
    $('#connectdetails').show();
     
    $("#clippings .clipping-contents").each( function() {
     
    var currentid = $(this).attr('id').replace('clipping-', '');
     
    $('#clipped-on-'+ currentid).append(" | <a href="javascript:onPost("+ currentid +")">share
     on Facebook</a>");
             
      });
     
    
    }

     
    
     FB.init("MY_API_KEY_FOR_MY_APP", "/xd_receiver.htm", {"ifUserConnected":onConnected});

     </script>




FACEBOOK DEVELOPER GARAGE FOWA EDITION


we can now add in some of the simple Connect stuff
<script type="text/javascript">
     
     function onConnected() {
     
    
    
    $('#connectbutton').remove();
     
    
    
    $('#connectdetails').show();
     
    $("#clippings .clipping-contents").each( function() {
     
    var currentid = $(this).attr('id').replace('clipping-', '');
     
    $('#clipped-on-'+ currentid).append(" | <a href="javascript:onPost("+ currentid +")">share
     on Facebook</a>");
             
      });
     
    
    }

     
    
     FB.init("MY_API_KEY_FOR_MY_APP", "/xd_receiver.htm", {"ifUserConnected":onConnected});

     </script>




FACEBOOK DEVELOPER GARAGE FOWA EDITION


we can now add in some of the simple Connect stuff
<script type="text/javascript">
     
     function onConnected() {
     
    
    
    $('#connectbutton').remove();
     
    
    
    $('#connectdetails').show();
     
    $("#clippings .clipping-contents").each( function() {
     
    var currentid = $(this).attr('id').replace('clipping-', '');
     
    $('#clipped-on-'+ currentid).append(" | <a href="javascript:onPost("+ currentid +")">share
     on Facebook</a>");
             
      });
     
    
    }

     
    
     FB.init("MY_API_KEY_FOR_MY_APP", "/xd_receiver.htm", {"ifUserConnected":onConnected});

     </script>




FACEBOOK DEVELOPER GARAGE FOWA EDITION


we can now add in some of the simple Connect stuff
<div id="connectbutton">
     
    <h2>Share your clippings with your friends on Facebook</h2>
     
    <fb:login-button size="large" background="white" length="long"></fb:login-button>
     </div>

     <div id="connectdetails">
     
    <fb:profile-pic uid="loggedinuser" facebook-logo="true" size="thumb" linked="true"></
     fb:profile-pic> <fb:name uid="loggedinuser" useyou="false"></fb:name>
     </div>



     <script type="text/javascript">
     
     function onConnected() {
     
    $('#connectbutton').remove();
     
    $('#connectdetails').show();
     
    $("#clippings .clipping-contents").each( function() {
     
    var currentid = $(this).attr('id').replace('clipping-', '');
     
    $('#clipped-on-'+ currentid).append(" | <a href="javascript:onPost("+ currentid +")">share
     on Facebook</a>");
             
      });
     
    
    }

     $('#connectdetails').hide();
     FB.init("MY_API_KEY_FOR_MY_APP", "/xd_receiver.htm", {"ifUserConnected":onConnected});

     </script>




FACEBOOK DEVELOPER GARAGE FOWA EDITION


and can add in a pair of divs to contain the Connect login button and the Connect details, we’ll hide the
Connect details div by default on page load and if the user connects or is connected we’ll hide the
Connect button div and show the Connect details one
function onPost(id) {
     
     var title = $('a', $('#clipping-'+ id)).html();
     
     var trailtext = $('#clipping-trail-text-'+ id).html();
     
     var href = $('a', $('#clipping-'+ id)).attr('href');
     
     var attachment = {
     
     
    
    
    
    'name': title,
     
     
    
    
    
    'href': href,
     
     
    
    
    
    'caption': '{*actor*} just clipped a link on The Guardian and shared
     it.',
     
     
    
    
    
    'description': trailtext,
     
     
    
    
    };
     
     FB.Connect.streamPublish('', attachment, null, null, 'Tell people about your
     clipping');
    
    
     }
     
     




FACEBOOK DEVELOPER GARAGE FOWA EDITION


and then we’ll roll up the pieces of JavaScript where we were assembling the content to go into the
stream into a handler for when the user clicks the link and pass them as an attachment to the
FB.Connect.streamPublish method
function onPost(id) {
     
     var title = $('a', $('#clipping-'+ id)).html();
     
     var trailtext = $('#clipping-trail-text-'+ id).html();
     
     var href = $('a', $('#clipping-'+ id)).attr('href');
     
     var attachment = {
     
     
    
    
    
    'name': title,
     
     
    
    
    
    'href': href,
     
     
    
    
    
    'caption': '{*actor*} just clipped a link on The Guardian and shared
     it.',
     
     
    
    
    
    'description': trailtext,
     
     
    
    
    };
     
     FB.Connect.streamPublish('', attachment, null, null, 'Tell people about your
     clipping');
    
    
     }
     
     




FACEBOOK DEVELOPER GARAGE FOWA EDITION


and then we’ll roll up the pieces of JavaScript where we were assembling the content to go into the
stream into a handler for when the user clicks the link and pass them as an attachment to the
FB.Connect.streamPublish method
FACEBOOK DEVELOPER GARAGE FOWA EDITION


and here’s how it works...
FACEBOOK DEVELOPER GARAGE FOWA EDITION


time to connect
FACEBOOK DEVELOPER GARAGE FOWA EDITION


click Share on Facebook
FACEBOOK DEVELOPER GARAGE FOWA EDITION


Up pops the feed box
FACEBOOK DEVELOPER GARAGE FOWA EDITION


Up pops the feed box
What next?
 Well we have an API for our
 content, so it could be that
 you could make socially
 connected content widgets
 for your site.



FACEBOOK DEVELOPER GARAGE FOWA EDITION
Thank you
 http://www.guardian.co.uk/open-platform
 Twitter: @openplatform

 chris.thorpe@guardian.co.uk




FACEBOOK DEVELOPER GARAGE FOWA EDITION

More Related Content

What's hot

10 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 201210 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 2012Bastian Grimm
 
Technical SEO: Crawl Space Management - SEOZone Istanbul 2014
Technical SEO: Crawl Space Management - SEOZone Istanbul 2014Technical SEO: Crawl Space Management - SEOZone Istanbul 2014
Technical SEO: Crawl Space Management - SEOZone Istanbul 2014Bastian Grimm
 
WordPress Performance Optimization for Mere Mortals
WordPress Performance Optimization for Mere MortalsWordPress Performance Optimization for Mere Mortals
WordPress Performance Optimization for Mere MortalsJohn Levandowski
 
Real World Web Standards
Real World Web StandardsReal World Web Standards
Real World Web Standardsgleddy
 
HTML5 workshop, part 1
HTML5 workshop, part 1HTML5 workshop, part 1
HTML5 workshop, part 1Robert Nyman
 
Advanced WordPress Optimization - iGaming Supershow 2012
Advanced WordPress Optimization - iGaming Supershow 2012Advanced WordPress Optimization - iGaming Supershow 2012
Advanced WordPress Optimization - iGaming Supershow 2012Bastian Grimm
 
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011brucelawson
 
HTML5 Introduction
HTML5 IntroductionHTML5 Introduction
HTML5 Introductiondynamis
 
Ss 36932418[1]
Ss 36932418[1]Ss 36932418[1]
Ss 36932418[1]Ya Jinda
 
Hardening WordPress - Friends of Search 2014 (WordPress Security)
Hardening WordPress - Friends of Search 2014 (WordPress Security)Hardening WordPress - Friends of Search 2014 (WordPress Security)
Hardening WordPress - Friends of Search 2014 (WordPress Security)Bastian Grimm
 
Extend Joomla Forms Using Plugins
Extend Joomla Forms Using PluginsExtend Joomla Forms Using Plugins
Extend Joomla Forms Using PluginsYireo
 
HTML5 - Introduction
HTML5 - IntroductionHTML5 - Introduction
HTML5 - IntroductionDavy De Pauw
 
Building mobile applications with DrupalGap
Building mobile applications with DrupalGapBuilding mobile applications with DrupalGap
Building mobile applications with DrupalGapAlex S
 
Web Standards: Fueling Innovation [Web Design World Boston '08]
Web Standards: Fueling Innovation [Web Design World Boston '08]Web Standards: Fueling Innovation [Web Design World Boston '08]
Web Standards: Fueling Innovation [Web Design World Boston '08]Aaron Gustafson
 
Structured Data & Schema.org - SMX Milan 2014
Structured Data & Schema.org - SMX Milan 2014Structured Data & Schema.org - SMX Milan 2014
Structured Data & Schema.org - SMX Milan 2014Bastian Grimm
 
State of jQuery '09
State of jQuery '09State of jQuery '09
State of jQuery '09jeresig
 

What's hot (20)

10 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 201210 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
 
Technical SEO: Crawl Space Management - SEOZone Istanbul 2014
Technical SEO: Crawl Space Management - SEOZone Istanbul 2014Technical SEO: Crawl Space Management - SEOZone Istanbul 2014
Technical SEO: Crawl Space Management - SEOZone Istanbul 2014
 
WordPress Performance Optimization for Mere Mortals
WordPress Performance Optimization for Mere MortalsWordPress Performance Optimization for Mere Mortals
WordPress Performance Optimization for Mere Mortals
 
Real World Web Standards
Real World Web StandardsReal World Web Standards
Real World Web Standards
 
HTML5 workshop, part 1
HTML5 workshop, part 1HTML5 workshop, part 1
HTML5 workshop, part 1
 
Advanced WordPress Optimization - iGaming Supershow 2012
Advanced WordPress Optimization - iGaming Supershow 2012Advanced WordPress Optimization - iGaming Supershow 2012
Advanced WordPress Optimization - iGaming Supershow 2012
 
HTML5 Essentials
HTML5 EssentialsHTML5 Essentials
HTML5 Essentials
 
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
 
HTML5 Introduction
HTML5 IntroductionHTML5 Introduction
HTML5 Introduction
 
Upload[1]
Upload[1]Upload[1]
Upload[1]
 
Ss 36932418[1]
Ss 36932418[1]Ss 36932418[1]
Ss 36932418[1]
 
Hardening WordPress - Friends of Search 2014 (WordPress Security)
Hardening WordPress - Friends of Search 2014 (WordPress Security)Hardening WordPress - Friends of Search 2014 (WordPress Security)
Hardening WordPress - Friends of Search 2014 (WordPress Security)
 
Extend Joomla Forms Using Plugins
Extend Joomla Forms Using PluginsExtend Joomla Forms Using Plugins
Extend Joomla Forms Using Plugins
 
HTML5 - Introduction
HTML5 - IntroductionHTML5 - Introduction
HTML5 - Introduction
 
[O'Reilly] HTML5 Design
[O'Reilly] HTML5 Design[O'Reilly] HTML5 Design
[O'Reilly] HTML5 Design
 
Lecture1and2
Lecture1and2Lecture1and2
Lecture1and2
 
Building mobile applications with DrupalGap
Building mobile applications with DrupalGapBuilding mobile applications with DrupalGap
Building mobile applications with DrupalGap
 
Web Standards: Fueling Innovation [Web Design World Boston '08]
Web Standards: Fueling Innovation [Web Design World Boston '08]Web Standards: Fueling Innovation [Web Design World Boston '08]
Web Standards: Fueling Innovation [Web Design World Boston '08]
 
Structured Data & Schema.org - SMX Milan 2014
Structured Data & Schema.org - SMX Milan 2014Structured Data & Schema.org - SMX Milan 2014
Structured Data & Schema.org - SMX Milan 2014
 
State of jQuery '09
State of jQuery '09State of jQuery '09
State of jQuery '09
 

Similar to How clean "semantic" markup can power simple Facebook Connect integrations

Practical progressive enhancement
Practical progressive enhancementPractical progressive enhancement
Practical progressive enhancementGraham Bird
 
TOSSUG HTML5 讀書會 新標籤與表單
TOSSUG HTML5 讀書會 新標籤與表單TOSSUG HTML5 讀書會 新標籤與表單
TOSSUG HTML5 讀書會 新標籤與表單偉格 高
 
Copy of-a-walk-around-westfall-plaza
Copy of-a-walk-around-westfall-plazaCopy of-a-walk-around-westfall-plaza
Copy of-a-walk-around-westfall-plazahelgawerth
 
2022 HTML5: The future is now
2022 HTML5: The future is now2022 HTML5: The future is now
2022 HTML5: The future is nowGonzalo Cordero
 
WordPress Accessibility: WordCamp Chicago
WordPress Accessibility: WordCamp ChicagoWordPress Accessibility: WordCamp Chicago
WordPress Accessibility: WordCamp ChicagoJoseph Dolson
 
Expression Engine Designer
Expression Engine   DesignerExpression Engine   Designer
Expression Engine DesignerMatias
 
Why ExpressionEngine is Great for Designers
Why ExpressionEngine is Great for DesignersWhy ExpressionEngine is Great for Designers
Why ExpressionEngine is Great for DesignersFortySeven Media
 
How to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public ReleaseHow to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public ReleaseDavid Yeiser
 
Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Stop reinventing the wheel: Build Responsive Websites Using BootstrapStop reinventing the wheel: Build Responsive Websites Using Bootstrap
Stop reinventing the wheel: Build Responsive Websites Using Bootstrapfreshlybakedpixels
 
HTML5+CSS3 (入門編)
HTML5+CSS3 (入門編)HTML5+CSS3 (入門編)
HTML5+CSS3 (入門編)博史 高木
 
Creating HTML Pages
Creating HTML PagesCreating HTML Pages
Creating HTML PagesMike Crabb
 
Take Your Markup to 11
Take Your Markup to 11Take Your Markup to 11
Take Your Markup to 11Emily Lewis
 
ViA Bootstrap 4
ViA Bootstrap 4ViA Bootstrap 4
ViA Bootstrap 4imdurgesh
 
Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Daniel Downs
 
Presentation html5 css3 by thibaut
Presentation html5 css3 by thibautPresentation html5 css3 by thibaut
Presentation html5 css3 by thibautThibaut Baillet
 
webcomponents (Jfokus 2015)
webcomponents (Jfokus 2015)webcomponents (Jfokus 2015)
webcomponents (Jfokus 2015)Hendrik Ebbers
 

Similar to How clean "semantic" markup can power simple Facebook Connect integrations (20)

Practical progressive enhancement
Practical progressive enhancementPractical progressive enhancement
Practical progressive enhancement
 
TOSSUG HTML5 讀書會 新標籤與表單
TOSSUG HTML5 讀書會 新標籤與表單TOSSUG HTML5 讀書會 新標籤與表單
TOSSUG HTML5 讀書會 新標籤與表單
 
Copy of-a-walk-around-westfall-plaza
Copy of-a-walk-around-westfall-plazaCopy of-a-walk-around-westfall-plaza
Copy of-a-walk-around-westfall-plaza
 
2022 HTML5: The future is now
2022 HTML5: The future is now2022 HTML5: The future is now
2022 HTML5: The future is now
 
WordPress Accessibility: WordCamp Chicago
WordPress Accessibility: WordCamp ChicagoWordPress Accessibility: WordCamp Chicago
WordPress Accessibility: WordCamp Chicago
 
Expression Engine Designer
Expression Engine   DesignerExpression Engine   Designer
Expression Engine Designer
 
Why ExpressionEngine is Great for Designers
Why ExpressionEngine is Great for DesignersWhy ExpressionEngine is Great for Designers
Why ExpressionEngine is Great for Designers
 
How to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public ReleaseHow to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public Release
 
Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Stop reinventing the wheel: Build Responsive Websites Using BootstrapStop reinventing the wheel: Build Responsive Websites Using Bootstrap
Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
 
HTML5+CSS3 (入門編)
HTML5+CSS3 (入門編)HTML5+CSS3 (入門編)
HTML5+CSS3 (入門編)
 
Creating HTML Pages
Creating HTML PagesCreating HTML Pages
Creating HTML Pages
 
[heweb11] HTML5 Makeover
[heweb11] HTML5 Makeover[heweb11] HTML5 Makeover
[heweb11] HTML5 Makeover
 
Take Your Markup to 11
Take Your Markup to 11Take Your Markup to 11
Take Your Markup to 11
 
ViA Bootstrap 4
ViA Bootstrap 4ViA Bootstrap 4
ViA Bootstrap 4
 
Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.
 
[edUi] HTML5 Workshop
[edUi] HTML5 Workshop[edUi] HTML5 Workshop
[edUi] HTML5 Workshop
 
Presentation html5 css3 by thibaut
Presentation html5 css3 by thibautPresentation html5 css3 by thibaut
Presentation html5 css3 by thibaut
 
Xxx
XxxXxx
Xxx
 
webcomponents (Jfokus 2015)
webcomponents (Jfokus 2015)webcomponents (Jfokus 2015)
webcomponents (Jfokus 2015)
 
iWebkit
iWebkitiWebkit
iWebkit
 

Recently uploaded

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Recently uploaded (20)

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

How clean "semantic" markup can power simple Facebook Connect integrations

  • 1. How clean semantic markup in your HTML can power Facebook Connect Chris Thorpe FACEBOOK DEVELOPER GARAGE FOWA EDITION So this looks like a bit of an odd title
  • 2. Semantic Web FACEBOOK DEVELOPER GARAGE FOWA EDITION Do I mean this? Well no not yet, although RDF and other forms of semantic markup are gaining ground but some of the principles which underly RDF’s precursor - semantically marked up HTML or XHTML
  • 3. FACEBOOK DEVELOPER GARAGE FOWA EDITION Stuff more like this, either marked up in real microformats like hAtom or the wonderful hRecipe. If more publishers can build these sorts of formats into their products then we’ll be able to make really simple little bits of code which can extract, scrape and most importantly extend the information and functionality of pages and sites
  • 4. <ul id="clippings"> <li class="a-clipping"> <div class="clipping-contents" id="clipping-265621"> <h2><a href="http://www.guardian.co.uk/media/2009/aug/26/big-brother-dropped- channel-4">Big Brother axed by Channel 4</a></h2> <div class="clipping-trail-text" id="clipping-trail-text-265621">Broadcaster confirms that reality show will be dropped after 11th series in 2010. By Mark Sweney and Leigh Holmwood</div> <p class="clipped-on" id="clipped-on-265621">Clipped on 26 August 2009&nbsp; <a class="show-edit-clipping" href="http://www.guardian.co.uk/tools/clipping/ 265621/edit">Edit</a> </p> </div> </li> <li class="a-clipping"> <div class="clipping-contents" id="clipping-265614"> <h2><a href="http://www.guardian.co.uk/world/2009/aug/26/us-senator-ted-kennedy- dies" >Senator Ted Kennedy dies aged 77</a></h2> <div id="clipping-trail-text-265614">One of the most influential and longest serving senators in US history had battled brain cancer since May 2008</div> <p class="clipped-on" id="clipped-on-265614">Clipped on 26 August 2009&nbsp; <a class="show-edit-clipping" href="http://www.guardian.co.uk/tools/clipping/ 265614/edit" name="&lid={yourClippings}{Edit}&lpos={yourClippings}{5}">Edit</a> </p> </div> </li> </ul> FACEBOOK DEVELOPER GARAGE FOWA EDITION But we can start today with HTML with some simple semantic markup telling us what each bit does, like this rather simplified bit from The Guardian
  • 5. FACEBOOK DEVELOPER GARAGE FOWA EDITION Which outputs something which looks a bit like this
  • 6. <ul> <li> <div> <h2><a href="">Title</a></h2> <div>Trail text</div> <p>Date <a href="">Edit</a> </p> </div> </li> </ul> FACEBOOK DEVELOPER GARAGE FOWA EDITION And if we simplify it further we get this... not too interesting or useful... and certainly not semantic, but it shows the structure
  • 7. URL title trail text actions FACEBOOK DEVELOPER GARAGE FOWA EDITION What we get from this sort of structure is this
  • 8. <ul id="clippings"> <li class="a-clipping"> <div class="clipping-contents" id="clipping-XXXXXX"> <h2><a href="">Title</a></h2> <div class="clipping-trail-text" id="clipping-trail-text-XXXXXX">Trail text</div> <p class="clipped-on" id="clipped-on-XXXXXX">Date <a class="show-edit-clipping" href="">Edit</a> </p> </div> </li> </ul> FACEBOOK DEVELOPER GARAGE FOWA EDITION We can make it more semantic with a few id’s and classes which relate to the function of the text contained within some of the nodes
  • 9. URL title trail text FACEBOOK DEVELOPER GARAGE FOWA EDITION And when you look at it, this
  • 10. FACEBOOK DEVELOPER GARAGE FOWA EDITION has a lot in common with the sort of things you’d want to go into the stream
  • 11. <ul id="clippings"> <li class="a-clipping"> <div class="clipping-contents" id="clipping-XXXXXX"> <h2><a href="">Title</a></h2> <div class="clipping-trail-text" id="clipping-trail-text-XXXXXX">Trail text</div> <p class="clipped-on" id="clipped-on-XXXXXX">Date <a class="show-edit-clipping" href="">Edit</a> </p> </div> </li> </ul> FACEBOOK DEVELOPER GARAGE FOWA EDITION So how do we get from this on The Guardian
  • 12. FACEBOOK DEVELOPER GARAGE FOWA EDITION to this on Facebook
  • 13. FACEBOOK DEVELOPER GARAGE FOWA EDITION which brings us to this... The Guardian is interested in all sorts of things to do with identity and distributed/aggregated identity and one really great way to learn is to experiment and prototype
  • 14. <ul id="clippings"> <li class="a-clipping"> <div class="clipping-contents" id="clipping-XXXXXX"> <h2><a href="">Title</a></h2> <div class="clipping-trail-text" id="clipping-trail-text-XXXXXX">Trail text</div> <p class="clipped-on" id="clipped-on-XXXXXX">Date <a class="show-edit-clipping" href="">Edit</a> </p> </div> </li> </ul> FACEBOOK DEVELOPER GARAGE FOWA EDITION So if we want to go from this
  • 15. FACEBOOK DEVELOPER GARAGE FOWA EDITION to this sort of thing, how do we do it simply and in a prototype way, in say about an hour to test out how it works so we can make a case for it to go into production and help the engineers
  • 16. FACEBOOK DEVELOPER GARAGE FOWA EDITION this is a good start, JQuery is a really lovely JavaScript framework and since at it’s most basic level Facebook Connect is a client side development environment a good JavaScript libary is all we need to build a prototype
  • 17. <ul id="clippings"> <li class="a-clipping"> <div class="clipping-contents" id="clipping-XXXXXX"> <h2><a href="">Title</a></h2> <div class="clipping-trail-text" id="clipping-trail-text-XXXXXX">Trail text</div> <p class="clipped-on" id="clipped-on-XXXXXX">Date <a class="show-edit-clipping" href="">Edit</a> </p> </div> </li> </ul> FACEBOOK DEVELOPER GARAGE FOWA EDITION So how do we get the good bits from this...
  • 18. <ul id="clippings"> <li class="a-clipping"> <div class="clipping-contents" id="clipping-XXXXXX"> <h2><a href="">Title</a></h2> <div class="clipping-trail-text" id="clipping-trail-text-XXXXXX">Trail text</div> <p class="clipped-on" id="clipped-on-XXXXXX">Date <a class="show-edit-clipping" href="">Edit</a> </p> </div> </li> </ul> var title = $('a', $('#clipping-'+ id)).html(); var trailtext = $('#clipping-trail-text-'+ id).html(); var href = $('a', $('#clipping-'+ id)).attr('href'); FACEBOOK DEVELOPER GARAGE FOWA EDITION it’s pretty easy, it’s actually about 3 lines of JQuery get us the relevant bits of content if the content is marked up well, so how do we put it together with Connect
  • 19. actions FACEBOOK DEVELOPER GARAGE FOWA EDITION but how would we add some actions to post to Facebook
  • 20. 1 2 actions FACEBOOK DEVELOPER GARAGE FOWA EDITION well actually part of the clue is that within the UL there is an iterator waiting to be unlocked
  • 21. <ul id="clippings"> <li class="a-clipping"> <div class="clipping-contents" id="clipping-XXXXXX"> <h2><a href="">Title</a></h2> 1 <div class="clipping-trail-text" id="clipping-trail-text-XXXXXX">Trail text</div> <p class="clipped-on" id="clipped-on-XXXXXX">Date <a class="show-edit-clipping" href="">Edit</a> </p> </div> </li> <li class="a-clipping"> <div class="clipping-contents" id="clipping-YYYYYY"> 2 <h2><a href="">Title</a></h2> <div class="clipping-trail-text" id="clipping-trail-text-YYYYYY">Trail text</div> <p class="clipped-on" id="clipped-on-YYYYYY">Date <a class="show-edit-clipping" href="">Edit</a> </p> </div> </li> </ul> FACEBOOK DEVELOPER GARAGE FOWA EDITION We can build the iterator out of the HTML and JQuery, within the UL which has the unique id of clippings there are DIVs which have a class of clipping-contents and because we’ve got the HTML maked up with the clipping id we can do something interesting with this
  • 22. <ul id="clippings"> <li class="a-clipping"> <div class="clipping-contents" id="clipping-265621"> </div> </li> <li class="a-clipping"> <div class="clipping-contents" id="clipping-265614"> </div> </li> </ul> $("#clippings .clipping-contents").each( function() { var currentid = $(this).attr('id').replace('clipping-', ''); $('#clipped-on-'+ currentid).append(" | <a href="javascript:onPost("+ currentid +")">share on Facebook</a>"); }); FACEBOOK DEVELOPER GARAGE FOWA EDITION like this, which basically says for each time you find a something with a class of clipping-contents then get the content id of it through a bit of JavaScript string manipulation
  • 23. <ul id="clippings"> <li class="a-clipping"> <div class="clipping-contents" id="clipping-265621"> </div> </li> <li class="a-clipping"> <div class="clipping-contents" id="clipping-265614"> </div> </li> </ul> $("#clippings .clipping-contents").each( function() { var currentid = $(this).attr('id').replace('clipping-', ''); $('#clipped-on-'+ currentid).append(" | <a href="javascript:onPost("+ currentid +")">share on Facebook</a>"); }); FACEBOOK DEVELOPER GARAGE FOWA EDITION then in the node which has an id of clipped-on and that content id append a piece of HTML which gives the link to share on Facebook
  • 24. new actions FACEBOOK DEVELOPER GARAGE FOWA EDITION then in the node which has an id of clipped-on and that content id append a piece of HTML which gives the link to share on Facebook
  • 25. <script type="text/javascript"> function onConnected() { $('#connectbutton').remove(); $('#connectdetails').show(); $("#clippings .clipping-contents").each( function() { var currentid = $(this).attr('id').replace('clipping-', ''); $('#clipped-on-'+ currentid).append(" | <a href="javascript:onPost("+ currentid +")">share on Facebook</a>"); }); } FB.init("MY_API_KEY_FOR_MY_APP", "/xd_receiver.htm", {"ifUserConnected":onConnected}); </script> FACEBOOK DEVELOPER GARAGE FOWA EDITION we can now add in some of the simple Connect stuff
  • 26. <script type="text/javascript"> function onConnected() { $('#connectbutton').remove(); $('#connectdetails').show(); $("#clippings .clipping-contents").each( function() { var currentid = $(this).attr('id').replace('clipping-', ''); $('#clipped-on-'+ currentid).append(" | <a href="javascript:onPost("+ currentid +")">share on Facebook</a>"); }); } FB.init("MY_API_KEY_FOR_MY_APP", "/xd_receiver.htm", {"ifUserConnected":onConnected}); </script> FACEBOOK DEVELOPER GARAGE FOWA EDITION we can now add in some of the simple Connect stuff
  • 27. <script type="text/javascript"> function onConnected() { $('#connectbutton').remove(); $('#connectdetails').show(); $("#clippings .clipping-contents").each( function() { var currentid = $(this).attr('id').replace('clipping-', ''); $('#clipped-on-'+ currentid).append(" | <a href="javascript:onPost("+ currentid +")">share on Facebook</a>"); }); } FB.init("MY_API_KEY_FOR_MY_APP", "/xd_receiver.htm", {"ifUserConnected":onConnected}); </script> FACEBOOK DEVELOPER GARAGE FOWA EDITION we can now add in some of the simple Connect stuff
  • 28. <div id="connectbutton"> <h2>Share your clippings with your friends on Facebook</h2> <fb:login-button size="large" background="white" length="long"></fb:login-button> </div> <div id="connectdetails"> <fb:profile-pic uid="loggedinuser" facebook-logo="true" size="thumb" linked="true"></ fb:profile-pic> <fb:name uid="loggedinuser" useyou="false"></fb:name> </div> <script type="text/javascript"> function onConnected() { $('#connectbutton').remove(); $('#connectdetails').show(); $("#clippings .clipping-contents").each( function() { var currentid = $(this).attr('id').replace('clipping-', ''); $('#clipped-on-'+ currentid).append(" | <a href="javascript:onPost("+ currentid +")">share on Facebook</a>"); }); } $('#connectdetails').hide(); FB.init("MY_API_KEY_FOR_MY_APP", "/xd_receiver.htm", {"ifUserConnected":onConnected}); </script> FACEBOOK DEVELOPER GARAGE FOWA EDITION and can add in a pair of divs to contain the Connect login button and the Connect details, we’ll hide the Connect details div by default on page load and if the user connects or is connected we’ll hide the Connect button div and show the Connect details one
  • 29. function onPost(id) { var title = $('a', $('#clipping-'+ id)).html(); var trailtext = $('#clipping-trail-text-'+ id).html(); var href = $('a', $('#clipping-'+ id)).attr('href'); var attachment = { 'name': title, 'href': href, 'caption': '{*actor*} just clipped a link on The Guardian and shared it.', 'description': trailtext, }; FB.Connect.streamPublish('', attachment, null, null, 'Tell people about your clipping'); } FACEBOOK DEVELOPER GARAGE FOWA EDITION and then we’ll roll up the pieces of JavaScript where we were assembling the content to go into the stream into a handler for when the user clicks the link and pass them as an attachment to the FB.Connect.streamPublish method
  • 30. function onPost(id) { var title = $('a', $('#clipping-'+ id)).html(); var trailtext = $('#clipping-trail-text-'+ id).html(); var href = $('a', $('#clipping-'+ id)).attr('href'); var attachment = { 'name': title, 'href': href, 'caption': '{*actor*} just clipped a link on The Guardian and shared it.', 'description': trailtext, }; FB.Connect.streamPublish('', attachment, null, null, 'Tell people about your clipping'); } FACEBOOK DEVELOPER GARAGE FOWA EDITION and then we’ll roll up the pieces of JavaScript where we were assembling the content to go into the stream into a handler for when the user clicks the link and pass them as an attachment to the FB.Connect.streamPublish method
  • 31. FACEBOOK DEVELOPER GARAGE FOWA EDITION and here’s how it works...
  • 32. FACEBOOK DEVELOPER GARAGE FOWA EDITION time to connect
  • 33. FACEBOOK DEVELOPER GARAGE FOWA EDITION click Share on Facebook
  • 34. FACEBOOK DEVELOPER GARAGE FOWA EDITION Up pops the feed box
  • 35. FACEBOOK DEVELOPER GARAGE FOWA EDITION Up pops the feed box
  • 36. What next? Well we have an API for our content, so it could be that you could make socially connected content widgets for your site. FACEBOOK DEVELOPER GARAGE FOWA EDITION
  • 37. Thank you http://www.guardian.co.uk/open-platform Twitter: @openplatform chris.thorpe@guardian.co.uk FACEBOOK DEVELOPER GARAGE FOWA EDITION