ruhk has asked for the wisdom of the Perl Monks concerning the following question:

Hello fellow monks, I have a question for you all, and hopefully you can give me some insight into which direction I should take this project. Please bear with me, the explanation is quite long.

I work for a university and we just moved off of our custom in-house CMS system to post news as it was old and quite frankly, didnt work very well. We are actually using Blogger now, departments can just log in and post news themselves.

I have to write code that will take the Atom feed from blogger, parse it, and display a 'Top 5' of news headlines. I cannot directly use perl since some department pages dont have perl enabled, so it has to be some sort of javasrcipt solution.

The two ways I have come up with are as follows:
1) Write a perl script to parse the Atom feed and return javascript, for example:

<script language="JavaScript" src="foo/bar.pl" type="text/javascript"></script> 2) Write a perl script that runs every so often that would generate a javascript file with the updated news headlines in the file itself.

For example, displayNews()
We are worried about speed and how much a performance impact solution #1 would have on the mainpage, as it gets a lot of hits.
Thoughts?

janitored by ybiC: Retitle from less-than-descriptive "I need direction" for better site search

Replies are listed 'Best First'.
Re: Parse Atom feed for Blogger
by waswas-fng (Curate) on Jul 14, 2004 at 17:05 UTC
    Or you can have a cron job set up that updates the js or whatever every 5 minutes. that would keep the cost low and still give you fresh results. It is not uncommon to have the initial page (landing zone) be completely static and get updated from an outside source every X minutes on very high hit rate sites.


    -Waswas
Re: Parse Atom feed for Blogger
by CountZero (Bishop) on Jul 14, 2004 at 18:34 UTC
    Don't re-invent the wheel and use the Atom feed with XML::Atom and friends (esp. XML::Atom::Syndication). You don't need any Java as you can deal with the feed on your own (Perl-enabled) machine.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Parse Atom feed for Blogger
by LTjake (Prior) on Jul 15, 2004 at 17:09 UTC

    If you search CPAN, you'll find XML::Atom::Feed::JavaScript. That module will parse an Atom feed and output a javascript file suitable for inclusion on any html page. Check the docs for more info.

    Version 0.2 is out-of-date. I'm working with the author to get a new version uploaded that should work with the most recent version of XML::Atom.

    --
    "Go up to the next female stranger you see and tell her that her "body is a wonderland."
    My hypothesis is that she’ll be too busy laughing at you to even bother slapping you.
    " (src)