General Question

Perchik's avatar

Can I use an RSS feed like this?

Asked by Perchik (4992points) December 8th, 2008

I’ve built a website for a web-programming class. It reads in data from a text file and builds news stories from the text file. I’ve added a page that will allow a logged in admin add news from the web. That page just writes to the text file. That is all done in perl, with some javascript validation.

I’m interested in building an RSS feed, mostly for the educational value, to allow people to subscribe to our news posts.

~~

I want to create an xml file with the RSS 2.0 specs*. I can build some kind of perl/javascript thing to parse this new xml and output the news as content on our html page. That part isn’t particularly complicated, but the only reason I want to use the xml is for an RSS feed. So once I’ve got this xml file… would I just link to it to allow people subscribe to it? And how would I trigger an update? (i.e. how do I get the RSS feed reader to say news(1)?)

* If you’re curious, I’m going to build a short program to read in the current text file and output an xml file

I know this is probably a very inefficient way of doing things, I just wanted to do it so I could finally do some stuff with rss feeds.

Observing members: 0 Composing members: 0

9 Answers

lercio's avatar

RSS is a pull technology, so you are relying on the client to refresh to get the update.

anthelios77's avatar

Add this to the website’s frontpage, or all pages, and the feed will be detectable by most common browsers:

<link href=”[filename].xml” rel=“alternate”
type=“application/rss+xml” title=”[Title for the feed]” />

Just keep the file updated after each new post and it should work fine.
Don’t forget to set the proper rights for the file.

Perchik's avatar

@Anthelios Just keep the file updated after each new post and it should work fine.

Each new post would be in the xml file. There would only be the .xml file instead of the .txt file that is currently in place. So there wouldn’t be a file to update. Does this change your answer?

I know the obvious answer is “try it and see” but that could require some time to build and debug, I want to know if it’s at least feasible before I try it.

anthelios77's avatar

@Perchik – I’m not communicating well today. ^^ What I meant was that you simply overwrite the file with the new version that contains the new post along with the old ones. That’s how I would implement it at least. Was that any clearer?

You might want to think about how many posts in total you want the file to contain – e.g. the 10 most recent posts.

Perchik's avatar

Ah yes, that was the plan- overwrite the file each time (and produce a backup.) The first implementation would be solely proof of concept, so I’d probably use all the current news posts (20~). If that works successfully, I’ll work on a better archiving method.

anthelios77's avatar

Cool. Playing with feeds is fun. :)

Vincentt's avatar

Also note that you don’t need to ping the clients – they will poll the feed occasionally to check for updates (that’s why badly designed clients can drain your bandwidth, but providing a static file should prevent quite some problems already :).

anthelios77's avatar

What could happen when a client asks for the file when it is currently being overwritten?

Vincentt's avatar

I believe I read somewhere that Apache (if so, other servers probably as well) takes care of that, i.e. it will make sure the old version is still available when it’s being written to. I’m not sure though. To minimize the risk, you could first write the changes to another file and then just delete the old one and move the new one to the real location, I suppose.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther