<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>olussier.net</title>
	
	<link>http://olussier.net</link>
	<description>Dev, tech and other geeky stuff :)</description>
	<lastBuildDate>Wed, 09 Mar 2011 19:47:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/olussier" /><feedburner:info uri="olussier" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>olussier</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Facebook Social Plugins with IE8 [Fix]</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/kHYWq4bnvTI/</link>
		<comments>http://olussier.net/2010/09/20/facebook-social-plugins-with-ie8/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 03:57:37 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[IE8]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Social Plugins]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=468</guid>
		<description><![CDATA[Many people reported that my Facebook Social Plugins WordPress plugin didn&#8217;t work with Internet Explorer 8. However, it was working fine with IE8 on most blogs and I didn&#8217;t have enough information to be able to reproduce the problem. Today, while helping a friend with her blog, I finally came across the problem and was [...]]]></description>
			<content:encoded><![CDATA[<p>Many people reported that my <a href="http://olussier.net/demo/facebook-social-plugins/">Facebook Social Plugins WordPress plugin</a> didn&#8217;t work with Internet Explorer 8. However, it was working fine with IE8 on most blogs and I didn&#8217;t have enough information to be able to reproduce the problem. Today, while helping a friend with <a href="http://lageeke.com/">her blog</a>, I finally came across the problem and was able to figure out how to fix it. Here is the explanation of the problem and what to do to fix it.</p>
<p><span id="more-468"></span></p>
<p>First, the problem occurs only when using the XFBML version of the plugin by providing an application ID. When using this, the plugin inserts non-standard Facebook-specific HTML tags. IE8 simply discards unknown tags, so the inserted code is simply discarded and the plugins can&#8217;t load. Other browsers apparently do not discard such tags (though they can report a warning).</p>
<p>Fortunately, HTML can be extended and the browser be instructed to recognize non-standard tags.  This is precisely what the plugin does. However, some themes miss a function call that is required for this to work. To fix it, log into your WordPress dashboard and go to <strong>Editor</strong>, under <strong>Appearance</strong>. On the right, there is a list of the files that make your theme. Click on <strong>Header (header.php)</strong>. The code for that file loads. Near the top, there is a line that begins with <strong>&lt;html</strong>. This is the line that will need to be edited.</p>
<p>If you see <strong>language_attributes</strong> in that line, then the code is already correct and the problem is something else. If however, you don&#8217;t see this, keep reading.</p>
<p>If you see <strong>dir=&#8221;ltr&#8221;</strong> on that line, remove it. Also remove <strong>lang=&#8221;en-US&#8221;</strong> (or another language code instead of <strong>en-US</strong> if your blog isn&#8217;t in US English) if it appears on that line. Next, add the following exactly as is at the end of the line, right before the <strong>&gt;</strong>:</p>
<pre class="brush: xml; light: true; title: ;">&amp;lt;?php language_attributes(); ?&amp;gt;</pre>
<p>Make sure there is a space before that code. The final result may look like this, though it can differ too as themes are all different:</p>
<pre class="brush: xml; light: true; title: ;">&amp;lt;html xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; &amp;lt;?php language_attributes(); ?&amp;gt;&amp;gt;</pre>
<p>Then click the <strong>Update File</strong> button at the bottom. Reload your blog in IE8. If everything went well, you should now see the Social Plugins. If it doesn&#8217;t work or if this is too complicated for you to do yourself, post a comment and I&#8217;ll see how I can help you.<strong><br />
</strong></p>

<p><a href="http://feedads.g.doubleclick.net/~a/UUYRG8OrG31jTGoMVfJi3wcS6GY/0/da"><img src="http://feedads.g.doubleclick.net/~a/UUYRG8OrG31jTGoMVfJi3wcS6GY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/UUYRG8OrG31jTGoMVfJi3wcS6GY/1/da"><img src="http://feedads.g.doubleclick.net/~a/UUYRG8OrG31jTGoMVfJi3wcS6GY/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/kHYWq4bnvTI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/09/20/facebook-social-plugins-with-ie8/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/09/20/facebook-social-plugins-with-ie8/</feedburner:origLink></item>
		<item>
		<title>Eavify Your World! [jQuery Plugin + EA Tools 0.3]</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/VbM1nf3y7N0/</link>
		<comments>http://olussier.net/2010/08/04/eavify-your-world/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 23:45:42 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[badge]]></category>
		<category><![CDATA[Eavify]]></category>
		<category><![CDATA[Empire Avenue]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[ticker]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=449</guid>
		<description><![CDATA[Empire Avenue is gaining in popularity and many WordPress bloggers seem to enjoy the Empire Avenue plugin I released about two weeks ago. I am pleased to see that it is proving useful to some of you. Today, I am however even more pleased to announce not only version 0.3 of EA Tools, but a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.empireavenue.com/">Empire Avenue</a> is gaining in popularity and many WordPress bloggers seem to enjoy the <a href="http://olussier.net/empire-avenue-plugin/">Empire Avenue plugin</a> I released about two weeks ago. I am pleased to see that it is proving useful to some of you. Today, I am however even more pleased to announce not only version 0.3 of <a title="Empire Avenue Tools" href="http://olussier.net/empire-avenue-plugin/">EA Tools</a>, but a brand new jQuery plugin named <a href="http://olussier.net/eavify/">Eavify</a>, which can be used on ANY web page &#8211; not only WordPress blogs.<br />
<span id="more-449"></span><br />
Just like EA Tools, Eavify converts (e)<span>TICKER</span> into a pretty link to the user&#8217;s EA profile. It also features the EA badge as a tooltip. Please visit the <a href="http://olussier.net/eavify/">Eavify&#8217;s page</a> for more information and to install it.</p>
<p>If you are a WordPress blogger, you still want to use the EA Tools plugin. As of version 0.3, it integrates Eavify to convert tickers into links, instead of changing the post contents as it did so far. This also means that it no longer only works on posts, but on the whole page. You can customize this to fit your needs. Visit <a href="http://olussier.net/eavify/">Eavify&#8217;s page</a> for more information on customization.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/tn4IGD-eLl7mF2ZRNgUY_LBCc7Y/0/da"><img src="http://feedads.g.doubleclick.net/~a/tn4IGD-eLl7mF2ZRNgUY_LBCc7Y/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/tn4IGD-eLl7mF2ZRNgUY_LBCc7Y/1/da"><img src="http://feedads.g.doubleclick.net/~a/tn4IGD-eLl7mF2ZRNgUY_LBCc7Y/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/VbM1nf3y7N0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/08/04/eavify-your-world/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/08/04/eavify-your-world/</feedburner:origLink></item>
		<item>
		<title>EA Tools 0.2: Ticker Links Meet Badges</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/h3WGIpfdHdQ/</link>
		<comments>http://olussier.net/2010/07/27/ea-tools-0-2-ticker-links-meet-badges/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 03:12:09 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[badge]]></category>
		<category><![CDATA[Empire Avenue]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[ticker]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=412</guid>
		<description><![CDATA[A new update is available for the Empire Avenue Tools plugin for WordPress. It introduces a tooltip on the ticker links that show the badge for that ticker. Update the plugin from your dashboard or download it from the plugin&#8217;s page. There are more features coming soon and ideas are most welcome!]]></description>
			<content:encoded><![CDATA[<p><a href="http://olussier.net/wp-content/uploads/2010/07/ticker-tooltip.png"><img class="alignright size-full wp-image-416" title="Tooltip" src="http://olussier.net/wp-content/uploads/2010/07/ticker-tooltip.png" alt="" width="127" height="138" /></a>A new update is available for the <a href="http://olussier.net/empire-avenue-plugin/">Empire Avenue Tools plugin</a> for WordPress. It introduces a tooltip on the ticker links that show the badge for that ticker.</p>
<p>Update the plugin from your dashboard or download it from the <a href="http://olussier.net/empire-avenue-plugin/">plugin&#8217;s page</a>.</p>
<p>There are more features coming soon and ideas are most welcome!</p>

<p><a href="http://feedads.g.doubleclick.net/~a/_mDkPo4rspkEIjdz5fOH4USskpU/0/da"><img src="http://feedads.g.doubleclick.net/~a/_mDkPo4rspkEIjdz5fOH4USskpU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/_mDkPo4rspkEIjdz5fOH4USskpU/1/da"><img src="http://feedads.g.doubleclick.net/~a/_mDkPo4rspkEIjdz5fOH4USskpU/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/h3WGIpfdHdQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/07/27/ea-tools-0-2-ticker-links-meet-badges/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/07/27/ea-tools-0-2-ticker-links-meet-badges/</feedburner:origLink></item>
		<item>
		<title>Empire Avenue: The Influence Market [Plus: New WP Plugin]</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/yay89Lz-uOI/</link>
		<comments>http://olussier.net/2010/07/22/empire-avenue-the-influence-market/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 01:42:41 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[badge]]></category>
		<category><![CDATA[Empire Avenue]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Flickr]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[influence]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[social media]]></category>
		<category><![CDATA[stock exchange]]></category>
		<category><![CDATA[ticker]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=376</guid>
		<description><![CDATA[You may have heard about it. You may even be annoyed by some people tweeting too much about it. It&#8217;s called Empire Avenue, and it can be highly addictive! Let me tell you more about what it is and what it can do for you. Also, I&#8217;ll introduce a new WordPress plugin I made to [...]]]></description>
			<content:encoded><![CDATA[<p>You may have <a href="http://mashable.com/2010/06/04/empire-avenue/">heard</a> about it. You may even be annoyed by some people <a href="http://search.twitter.com/search?q=%23EmpireAvenue+OR+%23EmpireAv+OR+%23Eav+OR+%40EmpireAvenue">tweeting</a> too much about it. It&#8217;s called <a href="http://www.empireavenue.com">Empire Avenue</a>, and it can be highly addictive! Let me tell you more about what it is and what it can do for you. Also, I&#8217;ll introduce a new WordPress plugin I made to integrate EA (Empire Avenue) in your blog.<br />
<span id="more-376"></span></p>
<h3>What is Empire Avenue?</h3>
<p><a href="http://www.empireavenue.com/"><img class="alignright size-medium wp-image-382" title="Empire Avenue" src="http://olussier.net/wp-content/uploads/2010/07/logo-empireavenue-300x39.png" alt="" width="300" height="39" /></a>Empire Avenue is a stock exchange game based on online influence. Unlike the actual stock exchange, on EA, not only companies can have stocks, but individuals too. You can finally buy and sell shares in your friends, family or anyone in the world. EA is a game and no actual money is used, instead all transactions are made using &#8220;eaves&#8221;, the EA virtual currency.</p>
<p>Share prices are based on various variables all related to the user&#8217;s online influence, including the amount of activity on social media websites (blogs, Facebook, Twitter, Flickr), the number of friends on Facebook, the number of followers on Twitter, the amount of traffic on the user&#8217;s blog(s), the number of replies/retweets of the user&#8217;s posts&#8230; What happens on the EA website itself also influences the user&#8217;s share price. The more a user&#8217;s shares are sold, the higher the price gets.</p>
<p>There are many ways users can earn eaves that they can then invest in someone by buying their shares. First, every time a user&#8217;s shares are sold, the user receives part of the eaves. Everyday, when the market closes, an amount of eaves is given to every user based on their activity during that day. Part of this money is divided among the user&#8217;s shareholders as dividends. Finally, there are many achievements that a user can unlock, such as having a given amount of outstanding shares. Some of those achievements come with a reward in eaves.</p>
<h3>Only a Game?</h3>
<p>Is Empire Avenue only a game or can it be of any use to individuals or companies? It certainly is more than a game. It is an awesome way for individuals to quickly make connections with many interesting people and to discover companies and their products.</p>
<p>Companies can also get a lot from using EA. On this matter, <a href="http://carmengerea.com/">Carmen Gerea</a> ((e)CGBW2) on EA wrote a <a href="http://carmengerea.com/2010/07/20/empire-avenue-quel-interet-pour-les-entreprises-et-les-marques/">great article</a> (in French) stating interesting ways companies can use EA: finding influential people, targeting people who like a brand, create communities and more. As with the other social media tools, creativity will be the key to finding new ways to take advantage of it.</p>
<h3>Where Do I Sign Up?</h3>
<p>Empire Avenue is still in beta and in invitation-only mode. However it will open up to everyone on July 28. In the meantime, I have some invitations left, so contact me on <a href="http://twitter.com/olussier">Twitter</a> or leave a comment if you&#8217;re interested and I&#8217;ll send you an invitation. By the way, my ticker on EA is (e)OL so you can follow me (and buy my shares of course).</p>
<h3>New WordPress Plugin</h3>
<p>If you have a WordPress blog and use EA, you may be interested in the <a href="http://olussier.net/empire-avenue-plugin/">new plugin</a> I have created. For now, it includes two features. First, it automatically convert EA tickers written as (e)<span>TICKER</span> to a link to the user&#8217;s EA page. For example, (e)<span>OL</span> is converted to (e)OL.</p>
<p>The second feature is a widget to easily add the <a href="http://apidocs.empireavenue.com/badge">EA badge</a> to your blog. See at the bottom of the sidebar on this page for an example.</p>
<p>Please visit the <a href="http://olussier.net/empire-avenue-plugin/">plugin page</a> if you are interested.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/6WFe2UbOSNrhPYNXeW5qjMgoOLM/0/da"><img src="http://feedads.g.doubleclick.net/~a/6WFe2UbOSNrhPYNXeW5qjMgoOLM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/6WFe2UbOSNrhPYNXeW5qjMgoOLM/1/da"><img src="http://feedads.g.doubleclick.net/~a/6WFe2UbOSNrhPYNXeW5qjMgoOLM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/yay89Lz-uOI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/07/22/empire-avenue-the-influence-market/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/07/22/empire-avenue-the-influence-market/</feedburner:origLink></item>
		<item>
		<title>WordPress 3.0 Is Here!</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/x5_gTfvjCTE/</link>
		<comments>http://olussier.net/2010/06/17/wordpress-3-0-is-here/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 23:20:05 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Social Plugins]]></category>
		<category><![CDATA[Thelonious]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=368</guid>
		<description><![CDATA[As you probably know, WordPress 3.0 was released today, with a bunch of new features and improvements. Watch the video below for a preview of what&#8217;s new. For those of you wondering about FB Social Plugins, my plugin works fine with 3.0. Actually, most plugins from 2.9 should still work with 3.0. Let me know [...]]]></description>
			<content:encoded><![CDATA[<p>As you probably know, <a href="http://wordpress.org/development/2010/06/thelonious/">WordPress 3.0 was released</a> today, with a bunch of new features and improvements. Watch the video below for a preview of what&#8217;s new.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="360" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="guid=BQtfIEY1&amp;width=640&amp;height=360&amp;locksize=no&amp;dynamicseek=false&amp;qc_publisherId=p-18-mFEk4J448M" /><param name="src" value="http://v.wordpress.com/wp-content/plugins/video/flvplayer.swf?ver=1.21" /><param name="wmode" value="transparent" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="360" src="http://v.wordpress.com/wp-content/plugins/video/flvplayer.swf?ver=1.21" allowfullscreen="true" wmode="transparent" flashvars="guid=BQtfIEY1&amp;width=640&amp;height=360&amp;locksize=no&amp;dynamicseek=false&amp;qc_publisherId=p-18-mFEk4J448M"></embed></object></p>
<p>For those of you wondering about FB Social Plugins, my <a href="http://olussier.net/demo/facebook-social-plugins/">plugin</a> works fine with 3.0. Actually, most plugins from 2.9 should still work with 3.0. Let me know if you encounter any plugin that doesn&#8217;t.</p>
<p>Go ahead and <a href="http://wordpress.org/download/">download</a> WordPress 3.0 now, or upgrade from your dashboard.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/RCls7UfilXzf1u80hS6ll0bZ_k4/0/da"><img src="http://feedads.g.doubleclick.net/~a/RCls7UfilXzf1u80hS6ll0bZ_k4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/RCls7UfilXzf1u80hS6ll0bZ_k4/1/da"><img src="http://feedads.g.doubleclick.net/~a/RCls7UfilXzf1u80hS6ll0bZ_k4/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/x5_gTfvjCTE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/06/17/wordpress-3-0-is-here/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/06/17/wordpress-3-0-is-here/</feedburner:origLink></item>
		<item>
		<title>How to Use Geolocation to Locate Your Visitors</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/tyZrQ7CDyC4/</link>
		<comments>http://olussier.net/2010/06/04/how-to-use-geolocation-to-locate-your-visitors/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 02:17:30 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Gears]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[GPS]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[W3C]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[Wi-Fi]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=352</guid>
		<description><![CDATA[With the increasing popularity of mobile devices such as smartphones and the iPad, location-aware applications are flourishing. On the other hand, with HTML5 and all of its amazing features, web applications seem to be the way to go. So, how exactly do you locate your web application visitors? Let&#8217;s start with a little background information [...]]]></description>
			<content:encoded><![CDATA[<p>With the increasing popularity of mobile devices such as smartphones and the iPad, location-aware applications are flourishing. On the other hand, with HTML5 and all of its amazing features, web applications seem to be the way to go. So, how exactly do you locate your web application visitors? Let&#8217;s start with a little background information on geolocation.<br />
<span id="more-352"></span></p>
<h3>Positioning Methods</h3>
<p><img class="alignright size-full wp-image-360" title="You are here" src="http://olussier.net/wp-content/uploads/2010/06/you-are-here.png" alt="You are here" width="138" height="150" />There are a few methods that can be used to find someone&#8217;s position. The first and least accurate one is IP location. It checks the user&#8217;s IP address against a database to find the location, which is usually the name of the city or region. Though not very accurate, it has been widely used for a while and has the benefit of being the only method you can use server-side.</p>
<p>The second method is specific to mobile phones (and other devices connecting to mobile networks). It calculates the approximate location by figuring out your approximate distance to cell antennas around you (according to the signal power). The accuracy varies depending on the density of antennas and is therefore more accurate in urban areas.</p>
<p>Another method uses Wi-Fi and can therefore work with most mobile devices, including laptops. It works kind of the same as the cell antennas method, but uses Wi-Fi access point and a huge database of their known location. Since the range of Wi-Fi is pretty limited and there can potentially be dozens of known access points around you, the accuracy is actually quite impressive. Of course though, it works only if you are within range of at least one known access point. In urban areas, this is likely, but outside the city, you may be out of luck.</p>
<p>The most accurate method is <abbr title="Global Positioning System">GPS</abbr>, which most modern mobile phones are capable of using. It uses signals from satellites all around the globe to calculate the exact location. Though incredibly accurate (down to a few meters), it has some limitations. First, it tends to consume a fair amount of energy, so many people may usually  keep it off on their phone. Also, it works well only in open spaces, where the sky is visible. It is inaccurate or unusable indoors and when near large buildings. To help, hybrid implementations of GPS and other methods are often used. So if GPS fails, maybe Wi-Fi or cell antennas will work.</p>
<p>Enough background data! How do you code it?</p>
<h3>Google Gears and W3C Geolocation API</h3>
<p>In 2008, Google added the <a href="http://code.google.com/apis/gears/api_geolocation.html">Geolocation API</a> to <a href="http://gears.google.com/">Gears</a>, a plug-in that extends browsers capabilities. It was now possible with a few lines of javascript to find the user&#8217;s location. Last year, the <a href="http://www.w3.org/">W3C</a> released its <a href="http://www.w3.org/TR/geolocation-API/">Geolocation API specifications</a>. In the past months, it has been implemented in the main browsers, but is not yet supported by all. It is meant to eventually completely replace Gears&#8217; API, but for now it&#8217;s a good thing to have both.</p>
<p>Fortunately, though the implementations aren&#8217;t exactly the same, they are a lot alike. Also, you don&#8217;t have to care about what method it uses to find the location, nor on what kind of device your application is used. All you have to check for is if W3C geolocation is supported and/or if Gears is installed. Now, let&#8217;s code!</p>
<h3>The Code</h3>
<p>First, we need some simple HTML. The W3C geolocation, if supported, is natively implemented by the browser, so it doesn&#8217;t require to include any external javascript. Gears however, requires to add the gears_init.js file which you can download <a href="http://code.google.com/apis/gears/gears_init.js">here</a>. Since we&#8217;ll also be using the Google Maps API, we&#8217;ll also include its library.</p>
<pre class="brush: xml; title: ;">

&lt;script type=&quot;text/javascript&quot; src=&quot;gears_init.js&quot;&gt;&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;http://maps.google.com/maps/api/js?sensor=true&quot;&gt;&lt;/script&gt;
</pre>
<p>Now, for the sake of this example, we are simply going to display a Google map of the location once it&#8217;s found. To do so, we&#8217;ll need to add a container in the body, with some text in it that will appear until the map is loaded:</p>
<pre class="brush: xml; light: true; title: ;">&lt;div id=&quot;TheMap&quot;&gt;Finding your location...&lt;/div&gt;</pre>
<p>That&#8217;s all for the HTML. Now let&#8217;s add some javascript. Finding the location can take a few seconds, so this call is made asynchronously. This means that we need to create a callback function that will receive the position information. Here&#8217;s a little function that will display this on a map, also showing the accuracy:</p>
<pre class="brush: jscript; title: ;">

/* Show the position on a map */
function showPosition(position) {
 var location = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
 var options = { center: location,
                 mapTypeId: google.maps.MapTypeId.HYBRID };
 var map = new google.maps.Map(document.getElementById('TheMap'), options);
 var circleOptions = { map: map,
                       center: location,
                       radius: position.coords.accuracy,
                       fillColor: '#0055ff',
                       fillOpacity: 0.2,
                       strokeColor: '#0055ff',
                       strokeWeight: 1,
                       strokeOpacity: 0.7 };
 var circle = new google.maps.Circle(circleOptions);
 map.fitBounds(circle.getBounds());
}
</pre>
<p>I won&#8217;t explain here how the Google Maps API works since it is not the point of this article. If you want more info about it, please check the <a href="http://code.google.com/apis/maps/documentation/javascript/basics.html">documentation</a>. Note that we receive a position object. This can be either the W3C or the Gears objects, which are slightly different. However, they both have a &#8220;coords&#8221; property that contains the information we care about: latitude, longitude and accuracy (in meters).</p>
<p>It is also possible to create another callback function to process errors from the APIs. Let&#8217;s create a really simple one:</p>
<pre class="brush: jscript; title: ;">

/* No location available */
function noLocation(err) {
 document.getElementById('TheMap').innerHTML = 'No location available';
}
</pre>
<p>An error object is received as a parameter which contains information about the error. Here we simply display a message in our container stating that no location information is available, but of course you could do much more.</p>
<p>Let&#8217;s now create the function that will actually do the call. First it needs to get an object either from the W3C API or from Gears. Then, using that object it can call one of two methods: <strong>getCurrentPosition</strong> and <strong>watchPosition</strong>. The first simply gets the position once and calls the callback function. The latter periodically retrieves the position and calls the callback method if the position changed significantly since the last time. Let&#8217;s make a function that will enable to do both depending on a parameter.</p>
<p>Also, since the call is asynchronous, we can&#8217;t use a try-catch block to catch any runtime error, so just in case something goes wrong, we&#8217;ll set a timeout that will call the error callback function if no location was found yet. There is actually a known issue with the current latest release of Firefox 3.6 when no Wi-Fi is available that will generate such a runtime error.</p>
<pre class="brush: jscript; title: ;">

/* Timeout in case something goes wrong */
var locationTimeout = null;

/* Get the location */
function getLocation(watch) {
 var geo = null;

 if (navigator.geolocation) {  /* Check for W3C geolocation support */
   geo = navigator.geolocation;
 } else if (google.gears) {  /* Check for Google Gears */
   geo = google.gears.factory.create('beta.geolocation');
 }

 if (geo != null) {
   var geoTimeout = setTimeout(noLocation, 5000);

 if (watch) {  /* Watch for location */
   geo.watchPosition(function(position) { clearTimeout(geoTimeout); showPosition(position); }, noLocation);
 } else {  /* Get location once */
   geo.getCurrentPosition(function(position) { clearTimeout(geoTimeout); showPosition(position); }, noLocation);
 }

 } else {  /* Geolocation is not supported */
   noLocation();
 }
}

getLocation(false);
</pre>
<p>As you can see, we can test for W3C geolocation support by checking if <strong>navigator.geolocation</strong> is set and if Gears is installed by checking if <strong>google.gears</strong> is set. We can then set our geolocation object. If it&#8217;s not null (one of the method is supported), we then call one of the functions, depending on the value of the <strong>watch</strong> variable. Both methods take the success callback as the first parameter and the error callback as the second parameter. We use an anonymous function as the first parameter to clear the timeout before calling the success callback. If no geolocation method was supported, we simply call the error callback. Finally, we actually call the function requesting only to get the location once (false parameter).</p>
<p>You can see the final result on this <a href="http://olussier.net/demo/geolocation/">demo page</a>.</p>
<p><!-- EAVB_RMOEBZPJVK --></p>

<p><a href="http://feedads.g.doubleclick.net/~a/dX3kBGvbuGi81Me1kagxMtnd9eU/0/da"><img src="http://feedads.g.doubleclick.net/~a/dX3kBGvbuGi81Me1kagxMtnd9eU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/dX3kBGvbuGi81Me1kagxMtnd9eU/1/da"><img src="http://feedads.g.doubleclick.net/~a/dX3kBGvbuGi81Me1kagxMtnd9eU/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/tyZrQ7CDyC4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/06/04/how-to-use-geolocation-to-locate-your-visitors/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/06/04/how-to-use-geolocation-to-locate-your-visitors/</feedburner:origLink></item>
		<item>
		<title>Facebook Bug on New Like Buttons</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/CXZj1baD8Xo/</link>
		<comments>http://olussier.net/2010/05/31/facebook-bug-on-new-like-buttons/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 02:27:17 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Social Plugins]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=347</guid>
		<description><![CDATA[Earlier today, Dave H reported that he was getting an error when trying to use the Like button on his website. It appears that this error is widespread and is a bug coming from Facebook. When clicking on &#8220;Like&#8221; the user will see a red &#8220;Error&#8221; message and clicking on it will say that the [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier today, <a href="http://unlimitedsounds.com/blog/">Dave H</a> reported that he was getting an error when trying to use the Like button on his website. It appears that this error is widespread and is a bug coming from Facebook. When clicking on &#8220;Like&#8221; the user will see a red &#8220;Error&#8221; message and clicking on it will say that the page could not be reached. It seems to affect all newly created Like buttons. So, if you newly install the plugin, it will affect all your posts. If you already have the plugin, all your existing posts should be fine, but any new post should be affected (this includes the Like button on this very post&#8230; try it, you&#8217;ll probably get the error).<br />
<span id="more-347"></span></p>
<p>All we can do is wait for Facebook to fix this bug, hopefully soon. You can follow the <a href="http://forum.developers.facebook.com/viewtopic.php?pid=231720">thread about this bug</a> on Facebook Developers Forum or visit the <a href="http://bugs.developers.facebook.com/show_bug.cgi?id=10674">bug report page</a> for more information.</p>
<p><strong>Update:</strong> The bug is not marked as resolved yet, but I do not get it anymore. Let me know if you still get it. Also, you can find more info about the bug on <a href="http://mashable.com/2010/06/01/facebook-like-button-broken/">this post</a> from Mashable.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/3nyC9MxC1n-0vIbORORZpe1TM1Y/0/da"><img src="http://feedads.g.doubleclick.net/~a/3nyC9MxC1n-0vIbORORZpe1TM1Y/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/3nyC9MxC1n-0vIbORORZpe1TM1Y/1/da"><img src="http://feedads.g.doubleclick.net/~a/3nyC9MxC1n-0vIbORORZpe1TM1Y/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/CXZj1baD8Xo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/05/31/facebook-bug-on-new-like-buttons/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/05/31/facebook-bug-on-new-like-buttons/</feedburner:origLink></item>
		<item>
		<title>FB Social Plugins 1.2: Open Graph and Language</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/R2ZkgjZY2uI/</link>
		<comments>http://olussier.net/2010/05/14/fb-social-plugins-1-2-open-graph-and-language/#comments</comments>
		<pubDate>Sat, 15 May 2010 02:04:11 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[multilingual]]></category>
		<category><![CDATA[Open Graph]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Social Plugins]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=344</guid>
		<description><![CDATA[Version 1.2 of my plugin is out! The changes are quite minor this time though and you won&#8217;t even see any new setting here. I have added some basic Open Graph tags that improve the way the likes appear on Facebook profiles. The other change is for non-English blogs: the plugins will now automatically display [...]]]></description>
			<content:encoded><![CDATA[<p>Version 1.2 of my plugin is <a href="http://wordpress.org/extend/plugins/facebook-social-plugins/">out</a>! The changes are quite minor this time though and you won&#8217;t even see any new setting here. I have added some basic Open Graph tags that improve the way the likes appear on Facebook profiles. The other change is for non-English blogs: the plugins will now automatically display in the blog&#8217;s default language.</p>
<p><span id="more-344"></span></p>
<p>Until now, when clicking the Like button, the message posted only included a link based on the page&#8217;s title (what you see in your browser&#8217;s window title), something like &#8220;Bob likes <a href="http://olussier.net/2010/05/14/fb-social-plugins-1-2-open-graph-and-language/">FB Social Plugins 1.2: Open Graph and Locale &#8211; olussier.net</a>&#8220;. By adding some Open Graph tags, both the article title and blog name are specified. From now on, when someone clicks the button, the message on their profile will look like this: &#8220;Bob likes <a href="http://olussier.net/2010/05/14/fb-social-plugins-1-2-open-graph-and-language/">FB Social Plugins 1.2: Open Graph and Locale</a> on <a href="http://olussier.net/">olussier.net</a>&#8220;.</p>
<p>For those of you who have non-English blogs, you may have wished that the plugins were in the same language as your blog, since Facebook supports so many languages. With older versions, it wasn&#8217;t the case. If you are using XFBML, it was only in English, and if you are using iframes, it was according to the visitor&#8217;s language. Since you integrate the plugins in your blog, the newest version will match your blog&#8217;s default language, as long as it&#8217;s one of <a href="http://www.facebook.com/editaccount.php?language">Facebook&#8217;s supported languages</a>. Unfortunately, if your blog is multilingual this is not supported yet and only the default language will be used.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/vPDXdIMNZJOOetcx_E4huhXLnBI/0/da"><img src="http://feedads.g.doubleclick.net/~a/vPDXdIMNZJOOetcx_E4huhXLnBI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vPDXdIMNZJOOetcx_E4huhXLnBI/1/da"><img src="http://feedads.g.doubleclick.net/~a/vPDXdIMNZJOOetcx_E4huhXLnBI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/R2ZkgjZY2uI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/05/14/fb-social-plugins-1-2-open-graph-and-language/feed/</wfw:commentRss>
		<slash:comments>62</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/05/14/fb-social-plugins-1-2-open-graph-and-language/</feedburner:origLink></item>
		<item>
		<title>FB Social Plugins for WP 1.1 and Wow!</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/3hZjdP2fUH8/</link>
		<comments>http://olussier.net/2010/05/08/fb-social-plugins-for-wp-1-1-and-wow/#comments</comments>
		<pubDate>Sun, 09 May 2010 03:21:38 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Social Plugins]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=320</guid>
		<description><![CDATA[First of all, I must say a big WOW! When I started writing my Facebook Social Plugins WordPress plugin, it was simply a first attempt at a WordPress plugin and was only for my own usage. Still, I made it available to everyone who could be interested. I didn&#8217;t expect that much interest! There have [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, I must say a big WOW! When I started writing my <a href="http://olussier.net/demo/facebook-social-plugins/">Facebook Social Plugins WordPress plugin</a>, it was simply a first attempt at a WordPress plugin and was only for my own usage. Still, I made it available to everyone who could be interested. I didn&#8217;t expect that much interest! There have been <a href="http://wordpress.org/extend/plugins/facebook-social-plugins/stats/">many hundreds downloads</a> so far and I have received a good amount of positive comments. I am glad that the plugin proves useful to all of you!</p>
<p><span id="more-320"></span>The biggest surprise I had was yesterday when <a href="http://mashable.com/author/christina-warren/">Christina Warren</a> from <a href="http://mashable.com/">Mashable</a> wrote a <a href="http://mashable.com/2010/05/07/wordpress-facebook-like-buttons/">nice article about how to add the Like button to a WordPress blog</a>. Among other plugins, she mentioned mine and even says she likes it! <img src='http://olussier.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Sorry, I&#8217;m kind of excited! I really like Mashable but never expected to ever be mentioned in one of the posts of such a huge website. Anyways, thanks a lot to Christina!</p>
<p>All of this has given me quite some pressure to integrate the requests I have received. The most requested feature was to be able to display the Like button also on the main page. Well, I am pleased to announce version 1.1, which can do just that&#8230; and much more! You can now choose exactly where and how the Like button appears. You can now also put it at the top of the article instead of the bottom or both if you&#8217;d like. The settings page has completely changed. There is now a section to choose how the button should appear when it&#8217;s at the top and when it&#8217;s at the bottom. Then, you get a list of pretty much every kind of page you can get on your blog and, for each, you can choose whether to hide the like button or to show it at the top, bottom or both.</p>
<p>I also added a field for the content &#8220;pages&#8221; so you can enter a comma-separated list of IDs or slugs of pages you don&#8217;t want the button to appear on. This can be useful if you have multiple pages and generally want the button to appear on them except for one or a few ones.</p>
<p>Also, I had neglected one of the Like button settings: the layout. There are both the &#8220;standard&#8221; and the &#8220;button &amp; count&#8221; layouts. The first one is the most common one, with the button and the &#8220;X people like this&#8230;&#8221; message. The &#8220;button &amp; count&#8221; layout is a smaller one, with only the button and the number next to it. So, I added this setting.</p>
<p>Another detail: the Like button is now included within a &lt;p&gt; tag with the class &#8220;FacebookLikeButton&#8221;, no matter if it&#8217;s an iframe or an XFMBL tag. Using the class name you can edit your CSS and improve the way it appears on the page.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/IVikjGZg1E_KHulTp1Am-4ITkrw/0/da"><img src="http://feedads.g.doubleclick.net/~a/IVikjGZg1E_KHulTp1Am-4ITkrw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/IVikjGZg1E_KHulTp1Am-4ITkrw/1/da"><img src="http://feedads.g.doubleclick.net/~a/IVikjGZg1E_KHulTp1Am-4ITkrw/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/3hZjdP2fUH8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/05/08/fb-social-plugins-for-wp-1-1-and-wow/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/05/08/fb-social-plugins-for-wp-1-1-and-wow/</feedburner:origLink></item>
		<item>
		<title>Facebook Social Plugins for WordPress: New Version Available</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/HrkjEb_ah2o/</link>
		<comments>http://olussier.net/2010/04/30/facebook-social-plugins-for-wordpress-new-version-available/#comments</comments>
		<pubDate>Sat, 01 May 2010 03:49:19 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Social Plugins]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[XFBML]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=315</guid>
		<description><![CDATA[I am pleased to announce a new version of my Facebook Social Plugins WordPress plugin. You can now get the plugin from WordPress.org. The new version introduces the use of XFBML, which is an improvement over iframes. You can expect more added features with XFBML in the future. However, to make it work, you will [...]]]></description>
			<content:encoded><![CDATA[<p>I am pleased to announce a new version of my <a href="http://olussier.net/2010/04/23/facebooks-social-plugins-for-wordpress/">Facebook Social Plugins WordPress plugin</a>. You can now get the plugin from <a href="http://wordpress.org/extend/plugins/facebook-social-plugins/">WordPress.org</a>.</p>
<p><span id="more-315"></span></p>
<p>The new version introduces the use of XFBML, which is an improvement over iframes. You can expect more added features with XFBML in the future. However, to make it work, you will need to provide a Facebook application ID (which you can get <a href="http://developers.facebook.com/setup/">here</a>). If you don&#8217;t provide one, it will fall back to using iframes.</p>
<p>The new version also introduces 3 new widgets: Like Box, Comments and Recommendations. For more information and to see demos of the widgets, visit the <a href="http://olussier.net/demo/facebook-social-plugins/">plugin&#8217;s page</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Tr2JgpdH_PNij_vl0miAnQ9nRi0/0/da"><img src="http://feedads.g.doubleclick.net/~a/Tr2JgpdH_PNij_vl0miAnQ9nRi0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Tr2JgpdH_PNij_vl0miAnQ9nRi0/1/da"><img src="http://feedads.g.doubleclick.net/~a/Tr2JgpdH_PNij_vl0miAnQ9nRi0/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/HrkjEb_ah2o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/04/30/facebook-social-plugins-for-wordpress-new-version-available/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/04/30/facebook-social-plugins-for-wordpress-new-version-available/</feedburner:origLink></item>
		<item>
		<title>Facebook’s Social Plugins for WordPress</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/JiDFy0Wbfqg/</link>
		<comments>http://olussier.net/2010/04/23/facebooks-social-plugins-for-wordpress/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 02:43:21 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Graph API]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Social Plugins]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=311</guid>
		<description><![CDATA[On Wednesday, Facebook announced the new Graph API which enables developers to access Facebook&#8217;s data in a new and improved way. Another announce was Social Plugins. Those plugins let you add some of Facebook&#8217;s social features right into your website with little effort. Meanwhile, I started playing with WordPress plugins development so I thought this [...]]]></description>
			<content:encoded><![CDATA[<p>On Wednesday, Facebook announced the new <a href="http://developers.facebook.com/docs/api">Graph API</a> which enables developers to access Facebook&#8217;s data in a new and improved way. Another announce was <a href="http://developers.facebook.com/plugins">Social Plugins</a>. Those plugins let you add some of Facebook&#8217;s social features right into your website with little effort.</p>
<p><span id="more-311"></span></p>
<p>Meanwhile, I started playing with WordPress plugins development so I thought this was a good place to start. I have started working on a plugin that lets you easily add those social plugins to your WordPress blog. You can see what it looks like at the end of this post and in the &#8220;Recent Activity&#8221; box in my sidebar. Check out the <a href="/demo/facebook-social-plugins/">plugin&#8217;s page</a> for more information. Please remember that this is my very first attempt at a WordPress plugin so bare with me! <img src='http://olussier.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p><a href="http://feedads.g.doubleclick.net/~a/jE7qT1YhFn-7ZbGctBU9uluBBqY/0/da"><img src="http://feedads.g.doubleclick.net/~a/jE7qT1YhFn-7ZbGctBU9uluBBqY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/jE7qT1YhFn-7ZbGctBU9uluBBqY/1/da"><img src="http://feedads.g.doubleclick.net/~a/jE7qT1YhFn-7ZbGctBU9uluBBqY/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/JiDFy0Wbfqg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/04/23/facebooks-social-plugins-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/04/23/facebooks-social-plugins-for-wordpress/</feedburner:origLink></item>
		<item>
		<title>How to Use BackgroundWorker for Your Threading Needs</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/29mGkyGYJtY/</link>
		<comments>http://olussier.net/2010/04/18/how-to-use-backgroundworker-for-your-threading-needs/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 02:21:11 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[BackgroundWorker]]></category>
		<category><![CDATA[thread]]></category>
		<category><![CDATA[ThreadPool]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=289</guid>
		<description><![CDATA[When your application needs to perform time-consuming operations, you don&#8217;t want the interface to hang, so you need to use a separate thread for this operation. Still, if the operation takes some time to process, you may want to give the user some feedback about its progress. The .NET framework provides the Thread and ThreadPool [...]]]></description>
			<content:encoded><![CDATA[<p>When your application needs to perform time-consuming operations, you don&#8217;t want the interface to hang, so you need to use a separate thread for this operation. Still, if the operation takes some time to process, you may want to give the user some feedback about its progress. The .NET framework provides the <a href="http://msdn.microsoft.com/en-us/library/system.threading.thread.aspx">Thread</a> and <a href="http://msdn.microsoft.com/en-us/library/system.threading.threadpool.aspx">ThreadPool</a> classes to create and manage threads. They can be quite powerful and are a must for heavy threading operations. However, if you want a simpler solution, the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx">BackgroundWorker</a> class is your friend.</p>
<p><span id="more-289"></span></p>
<h3>The Basics</h3>
<p>BackgroundWorker uses the ThreadPool to manage threads, but makes your life much easier. For this tutorial, we will create a simple interface with one button named myButton and a progress bar named myProgressBar (make sure its maximum value is 100). Now, when clicking the button, we create a new BackgroundWorker, assign it something to do and launch it.</p>
<pre class="brush: csharp; title: ;">
private void myButton_Click(object sender, EventArgs e)
{
  BackgroundWorker worker = new BackgroundWorker();
  // Assigns something to do
  worker.DoWork += new DoWorkEventHandler(worker_DoWork);

  // Launches the worker
  worker.RunWorkerAsync();
}

private void worker_DoWork(object sender, DoWorkEventArgs e)
{
  // Time-consuming stuff
  long dummy = 0;

  for (int i = 0; i &lt; 100; i++)
  {
    for (int j = 0; j &lt; 10000; j++)
      dummy += i * j;
  }
}
</pre>
<p>The DoWork event is assigned a new callback method. The RunWorkerAsync method actually launches the worker, creating a new thread and calling our callback method within that thread.</p>
<h3>Sending Parameters to the Callback Method</h3>
<p>The RunWorkerAsync can also take any object as a parameter. If you need to send more than one parameter, that object can be an array of objects. In the callback method, you will be able to access the object using e.Argument.</p>
<pre class="brush: csharp; highlight: [9,15]; title: ;">
private void myButton_Click(object sender, EventArgs e)
{
  BackgroundWorker worker = new BackgroundWorker();

  // Assigns something to do
  worker.DoWork += new DoWorkEventHandler(worker_DoWork);

  // Launches the worker with a parameter
  worker.RunWorkerAsync(&quot;Hello, world!&quot;);
}

private void worker_DoWork(object sender, DoWorkEventArgs e)
{
  // Prints out the parameter
  Console.WriteLine(e.Argument.ToString());

  // Time-consuming stuff
  long dummy = 0;

  for (int i = 0; i &lt; 100; i++)
  {
    for (int j = 0; j &lt; 10000; j++)
      dummy += i * j;
  }
}
</pre>
<h3>Retrieving the Result</h3>
<p>When the work is done, you may have a result to send back to the main thread (and maybe display it somewhere). Let&#8217;s simply use a MessageBox to let the user know.</p>
<pre class="brush: csharp; highlight: [9,29,32,33,34,35,36]; title: ;">
private void myButton_Click(object sender, EventArgs e)
{
  BackgroundWorker worker = new BackgroundWorker();

  // Assigns something to do
  worker.DoWork += new DoWorkEventHandler(worker_DoWork);

  // A method to call when the work is done
  worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);

  // Launches the worker with a parameter
  worker.RunWorkerAsync(&quot;Hello, world!&quot;);
}

private void worker_DoWork(object sender, DoWorkEventArgs e)
{
  // Prints out the parameter
  Console.WriteLine(e.Argument.ToString());

  // Time-consuming stuff
  long dummy = 0;

  for (int i = 0; i &lt; 100; i++)
  {
    for (int j = 0; j &lt; 10000; j++)
      dummy += i * j;
  }

  e.Result = dummy;
}

void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
  // Lets the user know the result
  MessageBox.Show(e.Result.ToString());
}
</pre>
<p>RunWorkerCompleted takes a new callback method that will be called once the work is done. By the way, this method is called within the main thread, which means you can update any interface control without having to bother using Invoke. To pass on the work&#8217;s result to this method, we assign it to e.Result at the end of worker_DoWork. It is then accessible in the worker_RunWorkerCompleted method as e.Result. This result can be any object too, so it can hold pretty much anything you want.</p>
<h3>Reporting Progress</h3>
<p>The last step is to update our progress bar so the user knows what is going on.</p>
<pre class="brush: csharp; highlight: [12,13,25,36,48,51,52,53,54,55]; title: ;">
private void myButton_Click(object sender, EventArgs e)
{
  BackgroundWorker worker = new BackgroundWorker();

  // Assigns something to do
  worker.DoWork += new DoWorkEventHandler(worker_DoWork);

  // A method to call when the work is done
  worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);

  // Enables progress reporting
  worker.WorkerReportsProgress = true;
  worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);

  // Launches the worker with a parameter
  worker.RunWorkerAsync(&quot;Hello, world!&quot;);
}

private void worker_DoWork(object sender, DoWorkEventArgs e)
{
  // Prints out the parameter
  Console.WriteLine(e.Argument.ToString());

  // Reference to our worker
  BackgroundWorker worker = (BackgroundWorker)sender;

  // Time-consuming stuff
  long dummy = 0;

  for (int i = 0; i &lt; 100; i++)
  {
    for (int j = 0; j &lt; 10000; j++)
      dummy += i * j;

    // Reports current progress in percent
    worker.ReportProgress(i + 1);
  }

  e.Result = dummy;
}

void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
  // Lets the user know the result
  MessageBox.Show(e.Result.ToString());

  // Resets the progress bar
  myProgressBar.Value = 0;
}

private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
  // Updates the progress bar
  myProgressBar.Value = e.ProgressPercentage;
}
</pre>
<p>To enable progress reporting, we need to set WorkerReportsProgress to true and assign a new callback method to ProgressChanged. This method will be called within the main thread whenever we call the worker&#8217;s ReportProgress method. This method takes an integer from 0 to 100 as a parameter. It is the current progress in percent. In our example, we call it in the loop at every percent, then we assign its value to the progress bar using by retrieving it from e.ProgressPercentage. Note that ProgressChanged can also take any object as a second parameter that will be accessible from e.UserState (useful if you need to report more than the percentage).</p>
<p>BackgroundWorker can be a really nice tool to help implement simple threading. You could even manage multiple BackgroundWorkers at the same time. However, if it gets too heavy, you may want to consider using ThreadPool instead for better performances.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/P_HtQKVIDk2zQNaudXVx3reKwbQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/P_HtQKVIDk2zQNaudXVx3reKwbQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/P_HtQKVIDk2zQNaudXVx3reKwbQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/P_HtQKVIDk2zQNaudXVx3reKwbQ/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/29mGkyGYJtY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/04/18/how-to-use-backgroundworker-for-your-threading-needs/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/04/18/how-to-use-backgroundworker-for-your-threading-needs/</feedburner:origLink></item>
		<item>
		<title>Introducing Twitter’s @Anywhere</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/fiUQq9v9mZ8/</link>
		<comments>http://olussier.net/2010/04/14/introducing-twitters-anywhere/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 01:45:54 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[@Anywhere]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[hovercard]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=83</guid>
		<description><![CDATA[Last month at the SXSW, Twitter introduced a new platform named @Anywhere for website developers. It was launched today. The new platform makes it easy to integrate Twitter features within any website with only a few lines of Javascript. For now, you can automatically linkify Twitter usernames or add hovercards (like this: @olussier). You can [...]]]></description>
			<content:encoded><![CDATA[<p>Last month at the SXSW, Twitter introduced a new platform named <a href="http://dev.twitter.com/anywhere">@Anywhere</a> for website developers. It was <a href="http://mashable.com/2010/04/14/twitter-anywhere-launch/">launched today</a>. The new platform makes it easy to integrate Twitter features within any website with only a few lines of Javascript.</p>
<p><span id="more-83"></span></p>
<p>For now, you can automatically linkify Twitter usernames or add hovercards (like this: @<a class="tweep" href="http://twitter.com/olussier">olussier</a>). You can also create follow buttons and tweet boxes (to allow visitors to send tweets directly from your website). Finally, @Anywhere brings &#8220;Twitter Connect&#8221;, a method for your visitors to authenticate using Twitter (very similar to Facebook Connect actually).</p>
<p>To get you started quickly, you first need to <a href="http://dev.twitter.com/anywhere/apps/new">register an @Anywhere app</a> to get an API key. Then add this line of code to your website:</p>
<pre class="brush: xml; light: true; title: ;">&lt;script src=&quot;http://platform.twitter.com/anywhere.js?id=YourAPIKey&amp;v=1&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre>
<p>And then you can automatically add hovercards using:</p>
<pre class="brush: jscript; title: ;">
twttr.anywhere(function(twitter) {
 twitter.hovercards();
});
</pre>
<p><a href="http://jquery.com/">jQuery</a> fans will like to know that @Anywhere uses it and you can use jQuery&#8217;s selectors to choose what to apply hovercards to, like this:</p>
<pre class="brush: jscript; title: ;">
twttr.anywhere(function(twitter) {
 twitter('a.my-tweeps').hovercards();
});
</pre>
<p>Find more details on <a href="http://dev.twitter.com/anywhere/begin">Twitter&#8217;s developers website</a>!</p>

<p><a href="http://feedads.g.doubleclick.net/~a/tt_QdOZr3yXTBfeiEYDWyKsFLJA/0/da"><img src="http://feedads.g.doubleclick.net/~a/tt_QdOZr3yXTBfeiEYDWyKsFLJA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/tt_QdOZr3yXTBfeiEYDWyKsFLJA/1/da"><img src="http://feedads.g.doubleclick.net/~a/tt_QdOZr3yXTBfeiEYDWyKsFLJA/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/fiUQq9v9mZ8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/04/14/introducing-twitters-anywhere/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/04/14/introducing-twitters-anywhere/</feedburner:origLink></item>
		<item>
		<title>How to Extract Only the Content from a Web Page</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/wXpeTe2EJP8/</link>
		<comments>http://olussier.net/2010/04/10/how-to-extract-only-the-content-from-a-web-page/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 20:49:15 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Arc90]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[Evernote]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Readability]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=73</guid>
		<description><![CDATA[Have you ever visited a web page and actually had to take a moment to figure out where the content was because the page was so heavily loaded with non-content stuff? With the growing number of websites, with different designs, one may wish to simply read the page&#8217;s content without having to deal with all [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever visited a web page and actually had to take a moment to figure out where the content was because the page was so heavily loaded with non-content stuff? With the growing number of websites, with different designs, one may wish to simply read the page&#8217;s content without having to deal with all the extra stuff (navigation, ads, social features&#8230;).</p>
<p><span id="more-73"></span>The excellent folks at <a title="Arc90" href="http://arc90.com/">Arc90</a> have come up with a solution: the <a href="http://lab.arc90.com/experiments/readability/">Readability bookmarklet</a>. This easy-to-use bookmarklet extracts the main content from a web page and displays it in a simple yet pretty way. You can even customize the style, size and margins to make your reading as enjoyable as possible. The bookmarklet uses a generic algorithm that works on most pages that actually have content. While it is not 100% accurate, they do claim a <a href="http://blog.arc90.com/2010/01/26/introducing-readability-1-5/">success rate over 99%</a>. Try it yourself on this page by <a href="javascript:(function(){readStyle='style-newspaper';readSize='size-medium';readMargin='margin-x-narrow';_readability_script=document.createElement('SCRIPT');_readability_script.type='text/javascript';_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());document.getElementsByTagName('head')[0].appendChild(_readability_script);_readability_css=document.createElement('LINK');_readability_css.rel='stylesheet';_readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';_readability_css.type='text/css';_readability_css.media='all';document.getElementsByTagName('head')[0].appendChild(_readability_css);_readability_print_css=document.createElement('LINK');_readability_print_css.rel='stylesheet';_readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';_readability_print_css.media='print';_readability_print_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_readability_print_css);})();">clicking here</a>!</p>
<p>Here&#8217;s a short video that shows how simple and effective it is:<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=8798492&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=8798492&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Besides improving the reading experience, there are other great uses to this bookmarklet. First, websites do not always provide printer-friendly versions of their pages. With Readability, you get a clutter-free article ready to be printed. There even is a &#8220;Print&#8221; button. Also, if you use <a href="http://www.evernote.com">Evernote</a> with the Web Clipper, you should try using Readability on a page before clipping it. You will end up clipping only the article, which is more likely what you wanted to do!</p>
<h3>Using the Readability Algorithm in Your Applications</h3>
<p>You can even use the power of Readability if you need to extract web pages&#8217; content in your applications. Some nice folks <a href="http://blog.arc90.com/2009/06/20/readability-now-available-in-three-delicious-flavors/">have ported the algorithm to other languages</a>. See <a href="http://www.nirmalpatel.com/">Nirmal Patel</a>&#8216;s Python port <a href="http://nirmalpatel.com/fcgi/hn.py">here</a>, <a href="http://www.keyvan.net/">Keyvan Minoukadeh</a>&#8216;s PHP port <a href="http://bazaar.launchpad.net/~keyvan-k1m/fivefilters/content-only/annotate/head%3A/readability.php">here</a> and <a href="http://immortal.pl/">Immortal</a>&#8216;s C# port <a href="http://code.google.com/p/nreadability/">here</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Fs3M-1M-JbVcIFaJQPaxv53GJdE/0/da"><img src="http://feedads.g.doubleclick.net/~a/Fs3M-1M-JbVcIFaJQPaxv53GJdE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Fs3M-1M-JbVcIFaJQPaxv53GJdE/1/da"><img src="http://feedads.g.doubleclick.net/~a/Fs3M-1M-JbVcIFaJQPaxv53GJdE/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/wXpeTe2EJP8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/04/10/how-to-extract-only-the-content-from-a-web-page/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/04/10/how-to-extract-only-the-content-from-a-web-page/</feedburner:origLink></item>
		<item>
		<title>Improve Your Pages with Pseudo Class Selectors</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/jnoopsyy1fc/</link>
		<comments>http://olussier.net/2010/04/05/improve-your-pages-with-pseudo-class-selectors/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 22:39:41 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[pseudo class]]></category>
		<category><![CDATA[selector]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=62</guid>
		<description><![CDATA[CSS selectors are a powerful clean way of adding styles to your web pages. Pseudo classes are quite helpful when it comes to efficiently selecting which items to apply styles to. However, some interesting pseudo classes are little known. Chris Coyier, from CSS-Tricks, wrote an awesome article that introduces all the available pseudo class selectors [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Cascading Style Sheets" href="http://en.wikipedia.org/wiki/Cascading_Style_Sheets">CSS</a> selectors are a powerful clean way of adding styles to your web pages. Pseudo classes are quite helpful when it comes to efficiently selecting which items to apply styles to. However, some interesting pseudo classes are little known. <a title="Chris Coyier" href="http://chriscoyier.net/">Chris Coyier</a>, from <a title="CSS-Tricks" href="http://css-tricks.com/">CSS-Tricks</a>, wrote an <a title="Meet the Pseudo Class Selectors" href="http://css-tricks.com/pseudo-class-selectors/">awesome article</a> that introduces all the available pseudo class selectors available. Check out a demo of some of those selectors <a title="CSS Pseudo Classes Demo" href="http://olussier.net/demo/css-pseudo-classes/">here</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/aytERy0gvH8aOgEIsf686_5Bs3Q/0/da"><img src="http://feedads.g.doubleclick.net/~a/aytERy0gvH8aOgEIsf686_5Bs3Q/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/aytERy0gvH8aOgEIsf686_5Bs3Q/1/da"><img src="http://feedads.g.doubleclick.net/~a/aytERy0gvH8aOgEIsf686_5Bs3Q/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/jnoopsyy1fc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/04/05/improve-your-pages-with-pseudo-class-selectors/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/04/05/improve-your-pages-with-pseudo-class-selectors/</feedburner:origLink></item>
		<item>
		<title>Easily Parse HTML Documents in C#</title>
		<link>http://feedproxy.google.com/~r/olussier/~3/K_er8mghV7k/</link>
		<comments>http://olussier.net/2010/03/30/easily-parse-html-documents-in-csharp/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 03:22:51 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HtmlAgilityPack]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[XPath]]></category>

		<guid isPermaLink="false">http://olussier.net/?p=32</guid>
		<description><![CDATA[So, you are building a C# application and need to parse a web page&#8217;s HTML. You could use regular expressions, but it seems more efficient to use a DOM-based approach. What if you could even take advantage of the power of XPath? .Net contains an HtmlDocument class, along with HtmlElement, in System.Windows.Forms, which could seem [...]]]></description>
			<content:encoded><![CDATA[<p>So, you are building a C# application and need to parse  a web page&#8217;s HTML. You could use regular expressions, but it seems more  efficient to use a DOM-based approach. What if you could even take advantage of  the power of XPath?</p>
<p><span id="more-32"></span>.Net contains an <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.aspx">HtmlDocument</a> class, along with <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.htmlelement.aspx">HtmlElement</a>, in System.Windows.Forms,  which could seem pretty interesting. It does provide basic DOM methods like  GetElementById and GetElementsByTagName. However, if you try to create an  HtmlDocument object, you will soon notice that it has no public constructor. It  is actually a wrapper around an unmanaged class and the only way you can get an  instance is through the WebBrowser control. Quite slow and annoying&#8230; So, what  are the other solutions?</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx">XmlDocument</a> and <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.aspx">XmlNode</a> are an interesting solution if you have  correctly formatted XML or XHTML. If you are to retrieve content from the web,  then you should will need another library that will check the markup and correct  it if needed. You may want to try something like <a href="http://sourceforge.net/projects/tidynet/">Tidy</a> or  <a href="http://developer.mindtouch.com/Community/SgmlReader">SGMLReader</a>. Then you can create an XmlDocument and  access quite interesting methods to parse and manipulate the nodes.</p>
<h3>HtmlAgilityPack</h3>
<p>Another solution that I actually now use  every time I need to parse HTML is the free and open source <a href="http://htmlagilitypack.codeplex.com/">HtmlAgilityPack</a> library. It provides HtmlDocument and HtmlNode classes, which are quite similar to .NET&#8217;s XmlDocument and XmlNode classes. You can load the HTML either from a file, an URL or a string. There is no need to check the markup validity first as HtmlAgilityPack will take care of making everything valid by closing unclosed tags and fixing other markup errors. Once the document is loaded, you can start having fun parsing through the nodes!</p>
<h3>Basic Parsing</h3>
<p>The HtmlDocument object provides a getElementById method that let you target a specific node using its Id. You can use properties such as ChildNodes, FirstChild, NextSibling and ParentNode to navigate through the nodes. You can also use the Ancestors and Descendants methods to respectively get a list of all the ancestors or descendants of a node. Optionally, a node name can be given to retrieve only one type of nodes. Use the Attributes property to access a node&#8217;s attributes.</p>
<p>Here is a simple example that retrieves a web page and lists all the external links within a given node specified by its Id:</p>
<pre class="brush: csharp; title: ;">
// The HtmlWeb class is a utility class to get the HTML over HTTP
HtmlWeb htmlWeb = new HtmlWeb();

// Creates an HtmlDocument object from an URL
HtmlAgilityPack.HtmlDocument document = htmlWeb.Load(&quot;http://www.somewebsite.com&quot;);

// Targets a specific node
HtmlNode someNode = document.GetElementbyId(&quot;mynode&quot;);

// If there is no node with that Id, someNode will be null
if (someNode != null)
{
  // Extracts all links within that node
  IEnumerable&lt;HtmlNode&gt; allLinks = someNode.Descendants(&quot;a&quot;);

  // Outputs the href for external links
  foreach (HtmlNode link in allLinks)
  {
    // Checks whether the link contains an HREF attribute
    if (link.Attributes.Contains(&quot;href&quot;))
    {
      // Simple check: if the href begins with &quot;http://&quot;, prints it out
      if (link.Attributes[&quot;href&quot;].Value.StartsWith(&quot;http://&quot;))
        Console.WriteLine(link.Attributes[&quot;href&quot;].Value);
    }
  }
}
</pre>
<h3>Using XPath</h3>
<p>As I mentioned above, HtmlAgilityPack supports <a href="http://www.w3schools.com/XPath/default.asp">XPath</a>. If you don&#8217;t know XPath, I really suggest you take some time to learn it. It is quite simple, yet powerful. The HtmlNode class provides two methods to retrieve nodes matching an XPath expression: SelectSingleNode and SelectNodes. The first returns only one node (the first one matching) and the latter returns all matching nodes.</p>
<p>Here is almost the same example as above, but using XPath instead. Load the HtmlDocument object the same way and then:</p>
<pre class="brush: csharp; first-line: 7; title: ;">
// Targets a specific node
HtmlNode someNode = document.DocumentNode.SelectSingleNode(&quot;//*[@id='mynode']&quot;);

// If there is no node with that Id, someNode will be null
if (someNode != null)
{
    // Extracts all links within that node
    // Note the leading dot (.) to make it look relative to the current node instead of the whole document
    HtmlNodeCollection allLinks = someNode.SelectNodes(&quot;.//a&quot;);
</pre>
<p>The remaining is the same.</p>
<p>But that code is not any shorter or simpler than the previous one! It might even actually seem more complicated with that XPath syntax. That&#8217;s right, but here comes the power of XPath. Both expressions could be combined into only one that would do everything at once. And here is the new code after the HtmlDocument object loading as above:</p>
<pre class="brush: csharp; first-line: 7; title: ;">
// Extracts all links under a specific node that have an href that begins with &quot;http://&quot;
HtmlNodeCollection allLinks = document.DocumentNode.SelectNodes(&quot;//*[@id='mynode']//a[starts-with(@href,'http://')]&quot;);

// Outputs the href for external links
foreach (HtmlNode link in allLinks)
    Console.WriteLine(link.Attributes[&quot;href&quot;].Value);
</pre>
<p>Simple enough? Only the XPath part might be a bit hard to understand if you are new to it, but you will get used and eventually read it easily. This example is quite simple, but there is a lot more you can do using XPath to parse through nodes.</p>
<p>I hope this short introduction to HtmlAgilityPack will help you getting started using this really nice library and help you with your projects!</p>

<p><a href="http://feedads.g.doubleclick.net/~a/u-6AYLK8h0Xw9Lrxg9sVXxo-R2Q/0/da"><img src="http://feedads.g.doubleclick.net/~a/u-6AYLK8h0Xw9Lrxg9sVXxo-R2Q/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/u-6AYLK8h0Xw9Lrxg9sVXxo-R2Q/1/da"><img src="http://feedads.g.doubleclick.net/~a/u-6AYLK8h0Xw9Lrxg9sVXxo-R2Q/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/olussier/~4/K_er8mghV7k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://olussier.net/2010/03/30/easily-parse-html-documents-in-csharp/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://olussier.net/2010/03/30/easily-parse-html-documents-in-csharp/</feedburner:origLink></item>
	</channel>
</rss>

