Introducing Planet JavaScript

Planet JavaScriptPlanets are nothing new. No no, not planets like in the solar system; planets like news aggregating sites. I’ve been reading some for quite a while now as a low-fat alternative to full-on feed readers like Google Reader or Bloglines. My current favorites include Planet PHP, Planet Python, and as of about a week ago, Planet Web Security. It seems like there is a planet site for almost every subject matter. Especially ones related to coding.

This weekend I was surprised to discover that there was no planet for JavaScript related blogs. So I made it. Inspired by one of Chris Shiflett’s recent posts about how he made one, I decided to give it a go and build one myself. All in all, it was a great experience and wasn’t all that difficult. I began Saturday afternoon and finished Sunday afternoon. Probably the hardest thing about the process was finding good JavaScript blogs.

Here’s a question for the community: Where are all the JavaScript bloggers?

At any rate, it was an incredibly fun project and anyone who finds themselves reading a lot of feeds in a specific category, should try to whip one up. Here’s some of the basics things to keep in mind:

  • There are two main types of feeds floating around the internets today: RSS and Atom; both of which do the same thing but very differently. It would be worth the time if you took a moment to sit down and read up on them a bit. WikiPedia has examples of both RSS and Atom feeds that you can dissect and learn from.
  • Content from other people’s blogs will interfere with your content. There is a good chance that you use the same ID attribute on something that someone else has and as a result your layout breaks. It’s also possible that they just have a poorly marked up site which will cause yours to fail validation. Either way, you need to clean up the bad content that will come your way. I suggest getting friendly with HTMLPurifier. It’s a gem.
  • Consider how you are going to store the data. If you are just going to cache the data in a flat file, you don’t need to do much; but if you plan on any amount of scalability, you’ll probably use a database. There are a lot of characters in XHTML that will cause databases to flip out. Make sure you have a good escaping routine to take care of those potentially dangerous characters. If you are a MySQL and PHP user, use mysql_real_escape_string.
  • People post regularly on blogs so you need to update your planet regularly. You could have a nice admin area with a big shiny “Update” button but manual updates suck. Simple websites like this should run themselves. I created a cron job to call a command-line PHP script that fetches the latest headlines and saves them to my database every six hours.
  • Last but not least: Think about how you are going to prevent duplicate entries from being saved. I’m simply checking the posted date but I’m sure that some error will pop up. Another alternative would be to generate a md5 sum of the content and compare it to a sum of what’s stored in the database. That sounded like a lot of work and I quickly lost interest.

I’ll post the source code soon. I hacked it together procedurally and am currently integrating it into another little project I have going which you will soon hear about.

Check the site out. Give me some feedback. Blog about JavaScript.

This entry was posted on Wednesday, October 17th, 2007 at 12:03 am and is filed under Code, JavaScript. You can leave a response, or trackback from your own site.

What do you have to say?

Site Stuff

Pages

Projects

Archives

Categories