<p>Finally today I revamped <a href="http://www.ideias3.com">ideias3</a> homepage. It now has a simple page featuring a simple aggregator of this, <a href="http://sergiosantos.info">sergio</a> and ideias3 blogs. It was written in <a href="http://python.org">Python</a> with a experimental version of <strong>pungi</strong> and using <a href="http://feedparser.org">universal feedparser</a> to get the info from the <span class="caps">RSS</span> feeds, and <a href="http://chardet.feedparser.org/">chardet</a> to solve encoding problems. This one also uses a sorter I found out <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/67106">here</a> instead of traditional bubblesort with auxiliar lists I used to use.</p>

<p>In a near future I&#8217;m thinking of creating a full aggregator to use in a project of mine, I will talk about soon.</p>

<p>Source code follows.</p>

<div class="code"><pre>
#!/usr/bin/python

from pungi import *
import feedparser
import sorter


page=Page('ideias3.html')
	
# IDEIAS3

posts = []
authors=[&quot;Ideias3&quot;,&quot;Alcides&quot;,&quot;Sérgio&quot;]
feeds=[&quot;http://blog.ideias3.com/main/rss&quot;,&quot;http://feeds.feedburner.com/alcides&quot;,&quot;http://feeds.feedburner.com/sergiosantos&quot;]

for feed in feeds:
	d = feedparser.parse(feed)
	for entry in d['entries'][:min(8,len(d['entries']))]:
		title=str(entry['title'].encode('ascii', 'xmlcharrefreplace'))
		link=str(entry['links'][0]['href'])
		if 'updated_parsed' in entry.keys():
			date=entry['updated_parsed']
		else:
			date=(0,0,0,0,0,0,0,0)
		author=authors[feeds.index(feed)]
		posts.append({'title':title,'link':link,'date':date,&quot;author&quot;:author})

sorter.sort(posts, 'date')
posts.reverse()

body=&quot;&lt;ul&gt;&quot;
for entry in posts[:min(15,len(posts))]:
	body+=&quot;&lt;li&gt;&lt;div class='author'&gt;&quot;+entry['author']+&quot;:&lt;/div&gt; &lt;a href='&quot;+entry['link']+&quot;' target='_blank'&gt;&quot;+entry['title']+&quot;&lt;/a&gt;&lt;/li&gt;\n&quot;
body+=&quot;&lt;/ul&gt;&quot;



page.add_tag('body',body )

print start_output()

import chardet
final=&quot;&quot;
for line in body.split(&quot;\n&quot;):
	try:
		it = chardet.detect(line)
		final+= line.replace(&quot;&lt;br /&gt;&quot;,&quot;&lt;br /&gt;&quot;).decode(it['encoding']).encode('utf-8')
	except:
		final+= line.replace(&quot;&lt;br /&gt;&quot;,&quot;&lt;br /&gt;&quot;)

page.add_tag('body',final)
print page.output()
</pre>
</div>