<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Sleepiness in Seattle &#187; favorite</title>
	<atom:link href="http://stanblog.jojoyao.com/tag/favorite/feed/" rel="self" type="application/rss+xml" />
	<link>http://stanblog.jojoyao.com</link>
	<description>Stanley&#039;s Chat on the Technology and Business</description>
	<lastBuildDate>Tue, 21 Apr 2009 04:29:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Extract Favorite Websites Collection from Bookmark RSS feeds</title>
		<link>http://stanblog.jojoyao.com/2007/02/extract-favorite-websites-collection-from-bookmark-rss-feeds/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=extract-favorite-websites-collection-from-bookmark-rss-feeds</link>
		<comments>http://stanblog.jojoyao.com/2007/02/extract-favorite-websites-collection-from-bookmark-rss-feeds/#comments</comments>
		<pubDate>Sun, 25 Feb 2007 18:11:41 +0000</pubDate>
		<dc:creator>Stanley Yao</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[bookmark]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[favorite]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://stanblog.jojoyao.com/newblog/?p=17</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>Bookmarking a website and bookmarking an article are different usage of the bookmarking tools.  You may want to have a clean collection of all your favorite websites and on the other hand you may want to bookmark multiple good articles from the same website.  This way your bookmark collection is a mixture of both.  This is my little frustration of using sites like <a href="http://del.icio.us/">http://del.icio.us/</a>.  It&#8217;s great in collect articles and links, but not so great to keep a clean list of my favorite <strong>websites</strong>.  Although I can use a different bookmarking tool (e.g., <a href="http://favorites.live.com/">http://favorites.live.com/</a>, which could sync with IE bookmarks) to collect just sites, it&#8217;d be nice if I could keep them in one place.  So I developed a custom web control that could be put on your website to display all the websites of a list of <a href="http://del.icio.us/">http://del.icio.us/</a> RSS feeds in the order of popularity.  Multiple articles of each websites are collapsed into one entry shown for that website, and the number of the articles bookmarked from that site is used as the indicator of the popularity of that site within the RSS feeds.  So the more articles of a website that are bookmarked, the more popular the website is.  In my example of using this web control, I put my bookmark feeds and the del.icios.us homepage hotlist feeds in so that I will get a list of all the websites either I bookmarked or on the hostlist. </p>
<div>
<table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 575px;"></col>
</colgroup>
<tbody valign="top">
<tr>
<td style="border: 0.5pt solid black; padding-left: 7px; padding-right: 7px;">
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">&lt;</span><span style="color: rgb(163, 21, 21);">cc1</span><span style="color: blue;">:</span><span style="color: red;">BookmarkedWebsites<br />
&nbsp;&nbsp;&nbsp; id</span><span style="color: red;">=&quot;WebCustomControl1_1&quot;<br />
&nbsp;&nbsp;&nbsp; Url</span><span style="color: red;">=&quot;<a href="http://del.icio.us/rss/dbtu/; http://del.icio.us/rss/">http://del.icio.us/rss/dbtu/; http://del.icio.us/rss/</a>&quot;<br />
&nbsp;&nbsp;&nbsp; runat</span><span style="color: blue;">=&quot;server&quot;&gt;&lt;/</span><span style="color: rgb(163, 21, 21);">cc1</span><span style="color: blue;">:</span><span style="color: rgb(163, 21, 21);">BookmarkedWebsites</span><span style="color: blue;">&gt;</span></span></p>
</td>
</tr>
</tbody>
</table>
</div>
<p>The &quot;Url&quot; property of the control specifies a list of RSS feeds to extract from.  The delimiter is &quot;;&quot;. </p>
<p><a href="http://www.rssdotnet.com/">RSS.NET</a> library is used to parse the RSS feed.  The website part (domain) of the URL is extracted and used as the collapsing key. </p>
<div>
<table border="0" style="border-collapse: collapse;">
<colgroup>
<col style="width: 575px;"></col>
</colgroup>
<tbody valign="top">
<tr>
<td style="border: 0.5pt solid black; padding-left: 7px; padding-right: 7px;">
</p>
<p><span style="font-family: Courier New; font-size: 10pt;"> 								<span style="color: blue;">protected</span> 								<span style="color: blue;">override</span> 								<span style="color: blue;">void</span> RenderContents(<span style="color: rgb(43, 145, 175);">HtmlTextWriter</span> output)<br />
{<br />
<span style="color: blue;">&nbsp;&nbsp;&nbsp; // Get each individual RSS feed<br />
&nbsp;&nbsp;&nbsp; char</span>[] delimiters = { <span style="color: rgb(163, 21, 21);">&#8216;;&#8217;</span> };<br />
<span style="color: blue;">&nbsp;&nbsp;&nbsp; string</span>[] feeds = Url.Split(delimiters);<br />
<span style="color: rgb(43, 145, 175);">&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; // Get all websites<br />
&nbsp;&nbsp;&nbsp; SortedDictionary</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">int</span>&gt; sites =<span style="color: blue;"><br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; new </span><span style="color: rgb(43, 145, 175);">SortedDictionary</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">int</span>&gt;();<br />
<span style="color: blue;">&nbsp;&nbsp;&nbsp; foreach</span> (<span style="color: blue;">string</span> feedUrl <span style="color: blue;">in</span> feeds)<br />
&nbsp;&nbsp;&nbsp; {<br />
<span style="color: rgb(43, 145, 175);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; RssFeed</span> feed = <span style="color: rgb(43, 145, 175);">RssFeed</span>.Read(feedUrl);<br />
<span style="color: blue;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; foreach</span> (<span style="color: rgb(43, 145, 175);">RssChannel</span> channel <span style="color: blue;">in</span> feed.Channels)<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />
<span style="color: blue;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; foreach</span> (<span style="color: rgb(43, 145, 175);">RssItem</span> item <span style="color: blue;">in</span> channel.Items)<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />
<span style="color: blue;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; string</span> link = item.Link.Scheme + <span style="color: rgb(163, 21, 21);">&quot;://&quot;</span> +<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; item.Link.Host;<br />
<span style="color: blue;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if</span> (sites.ContainsKey(link))<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sites[link]++;<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />
<span style="color: blue;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br />
</span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sites[link] = 1;<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; }<span style="color: green;"><br />
</span></span></p>
</p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: rgb(43, 145, 175);">&nbsp;&nbsp;&nbsp; // Reorder it on the number of occurrence (thus popularity)<br />
&nbsp;&nbsp;&nbsp; KeyValuePair</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">int</span>&gt;[] popSites = <span style="color: blue;"><br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; new</span> <span style="color: rgb(43, 145, 175);">KeyValuePair</span>&lt;<span style="color: blue;">string</span>,<span style="color: blue;">int</span>&gt;[sites.Count];<br />
&nbsp;&nbsp;&nbsp; sites.CopyTo(popSites, 0);<br />
<span style="color: rgb(43, 145, 175);">&nbsp;&nbsp;&nbsp; Array</span>.Sort(popSites, <span style="color: blue;">new</span> 								<span style="color: rgb(43, 145, 175);">SitePopularityComparer</span>());<br />
<span style="color: blue;">&nbsp;&nbsp;&nbsp; foreach</span> (<span style="color: rgb(43, 145, 175);">KeyValuePair</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">int</span>&gt; s <span style="color: blue;">in</span> popSites)<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; output.Write(<span style="color: rgb(163, 21, 21);">&quot;( &quot;</span> + s.Value + <span style="color: rgb(163, 21, 21);">&quot; ) &lt;a href=\&quot;&quot;</span> +<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; s.Key + <span style="color: rgb(163, 21, 21);">&quot;\&quot;&gt;&quot;</span>+ s.Key + <span style="color: rgb(163, 21, 21);">&quot;&lt;/a&gt;&lt;br /&gt;&quot;</span>);<br />
&nbsp;&nbsp;&nbsp; }<br />
} </span></p>
</p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">public</span> 								<span style="color: blue;">class</span> 								<span style="color: rgb(43, 145, 175);">SitePopularityComparer</span> : <span style="color: rgb(43, 145, 175);">IComparer</span><br />
{<br />
<span style="color: blue;">&nbsp;&nbsp;&nbsp; int</span> 								<span style="color: rgb(43, 145, 175);">IComparer</span>.Compare(<span style="color: blue;">object</span> x, <span style="color: blue;">object</span> y)<br />
&nbsp;&nbsp;&nbsp; {<br />
<span style="color: blue;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return</span> ((<span style="color: rgb(43, 145, 175);">KeyValuePair</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">int</span>&gt;)y).Value -<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ((<span style="color: rgb(43, 145, 175);">KeyValuePair</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">int</span>&gt;)x).Value;<br />
&nbsp;&nbsp;&nbsp; }<br />
}</span></p>
</td>
</tr>
</tbody>
</table>
</div>
<p> The web control looks like the following:<br />
<a onclick="window.open('http://stanblog.jojoyao.com/myimg/sitelist.html','popup','width=281,height=354,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false" href="http://stanblog.jojoyao.com/myimg/sitelist.html"><img width="281" height="354" alt="" src="http://stanblog.jojoyao.com/myimg/sitelist-thumb.JPG" /></a><br />
&nbsp;
</p>
<p>Furthermore, it would be cooler to be able to sync this website list into the browser bookmark so that you can use them as your reading list even more conveniently.</p>
<p>The prototype source code can be downloaded here: <a href="http://stanblog.jojoyao.com/myupload/MyFavoriteWebSites.zip">MyFavoriteWebSites.zip</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://stanblog.jojoyao.com/2007/02/extract-favorite-websites-collection-from-bookmark-rss-feeds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

