1

Topic: Atom feed generator

Just another quickie. Have setup a RSS feed no probs, but tried the only Atom mod I could find, punatom, and the reader, Sage for FF, doesn't seem happy with it's output. So, is there a working Atom feed creator script knocking about for PunBB, or is it the FF Sage plugin just being tetchy?


Cheers,

Matt

2

Re: Atom feed generator

Well, couldn't find naff all else in the way of Atom generators, so adapted that RSS generator off the A.K site. It's passed the output validation tests too. big_smile With it being based on that code, it has the same category/forum/topic specific abilites. Sorted the non guest forum problem that caused a parser error to come up in the reader whilst I was at it. It just outputs a standard no alterations feed page now instead of dumping out rather ungracefully, as in the original RSS script. So......, what's the opinion? (It's the green icon for Atom, btw). big_smile

http://forums.bauchan.org/testforum/forums.php

3

Re: Atom feed generator

In IE it just prompts me to download the file atom.php.

4

Re: Atom feed generator

Paul wrote:

In IE it just prompts me to download the file atom.php.

Every atom feed I've tried so far does that, (including this one). big_smile. You have to drag the icon, (or add the feed address manually), into the reader. Firefox does exactly the same. I'm still trying to figure out whether that is how it should behave, or whether there's another header type needs adding, or suchlike. That php file it prompts one to download is actually the output of the generator, and not the script itself. smile

5

Re: Atom feed generator

Figured that file dump bit. big_smile I'd used the wrong content type header in the script. It's now dumping as text/xml when you click on the icon, the same as RSS does.

6

Re: Atom feed generator

I would expect the atom feed to open a page in IE which shows the xml output and not prompt me for a file download which is what the rss feed on your site does. Have you had a look at the PunBB 1.3's atom feed, that works exactly the same as the rss feed.

7

Re: Atom feed generator

Just bet you to the post on that one. big_smile Sorted it. The post is just above yours. smile I'd used the header type I'd seen in another atom script, rather than just specifiying text/xml as in the rss script. That's what was causing the problem. Proper text output on it now. smile

Re: Atom feed generator

It works in Firefox for me. big_smile I have Feedreader as my aggregator and associated with the feeds URL types, so it works just fine.

9

Re: Atom feed generator

Cheers for testing it. smile I've tested it with the Sage FF plugin, but the more testing it gets with different readers/clients, the better. smile

10

Re: Atom feed generator

Tested in Opera 9, Safari 3 (Win) and FeedDemon. Works fine.

11

Re: Atom feed generator

Paul wrote:

Tested in Opera 9, Safari 3 (Win) and FeedDemon. Works fine.

Cheers. smile Greatly appreciated. smile

12

Re: Atom feed generator

MattF wrote:

Just bet you to the post on that one. big_smile Sorted it. The post is just above yours. smile I'd used the header type I'd seen in another atom script, rather than just specifiying text/xml as in the rss script. That's what was causing the problem. Proper text output on it now. smile

While it might not prompt you to download the file anymore, you are now using an incorrect mime type to serve atom feeds. They should always be sent as…

application/atom+xml

…just like you used originally.

13

Re: Atom feed generator

Sod's law that I get it right for once and then change it. big_smile big_smile Is it worthwhile doing that at the moment though, or is it better just leaving it on the incorrect but more accessible, (and not dependant on registered filetypes being setup in M$ correctly), option?

14

Re: Atom feed generator

MattF wrote:

Sod's law that I get it right for once and then change it. big_smile big_smile Is it worthwhile doing that at the moment though, or is it better just leaving it on the incorrect but more accessible, (and not dependant on registered filetypes being setup in M$ correctly), option?

What I would have done is to do content negotiation to determine if the user agent accepts said mime type. That's what I do on one of my sites (though I haven't done anything with the extern.php script yet) and it works very well as you can see if you try opening the site in IE and a proper browser like Opera or FF smile

Really, all you should have to check for is whether or not

application/xml

exists in the $_SERVER['HTTP_ACCEPT'] string.

Re: Atom feed generator

FYI: http://blogs.msdn.com/rssteam/articles/ … Guide.aspx

16

Re: Atom feed generator

Cheers for the advice chaps.  smile Have just added a HTTP_ACCEPT statement to the atom script:

if (stristr($_SERVER["HTTP_ACCEPT"], "application/xml"))
{
        header ("Content-Type: application/atom+xml; charset=utf-8");
}
else
{
        header ("Content-type: text/xml; charset=utf-8");
}

and popped that on the testforum server. Is that code correct in it's design? Is it working as it should now? (I'm still getting used to this bit with regards to testing, so I'm not overly sure). big_smile

Thanks again for all the help on this one. I highly appreciate it. smile


Matt

17

Re: Atom feed generator

MattF wrote:

Cheers for the advice chaps.  smile Have just added a HTTP_ACCEPT statement to the atom script:

if (stristr($_SERVER["HTTP_ACCEPT"], "application/xml"))
{
        header ("Content-Type: application/atom+xml; charset=utf-8");
}
else
{
        header ("Content-type: text/xml; charset=utf-8");
}

and popped that on the testforum server. Is that code correct in it's design? Is it working as it should now? (I'm still getting used to this bit with regards to testing, so I'm not overly sure). big_smile

Thanks again for all the help on this one. I highly appreciate it. smile


Matt

It appears to work just fine smile The only change I would have made is to use $lang_common['lang_encoding'] instead of hard coding it for UTF-8.

18

Re: Atom feed generator

Cheers. smile I'll get that hardcoded charset altered to use lang_encoding too. Thanks for the pointer. smile Btw, like that theme on your site.

19

Re: Atom feed generator

MattF wrote:

Cheers. smile I'll get that hardcoded charset altered to use lang_encoding too. Thanks for the pointer. smile Btw, like that theme on your site.

Hey, thanks for that smile I have a few more on that site as well, so if you wish to check them out just login with the following account:

Username: PunBB
Password: PunDemo

I make a few styles every now and them when I don't have anything more productive to do, but very few of them are actually uploaded...I just like playing around wink

I've also made a few changes to my own extern.php now, but I haven't bothered with Atom just yet (don't know if I'll ever, because I don't really need it).

20 (edited by MattF 2007-09-22 14:44)

Re: Atom feed generator

CodeXP wrote:

I make a few styles every now and them when I don't have anything more productive to do, but very few of them are actually uploaded...I just like playing around wink

Like the Submerged one. The left pinky grows on you after a short while too. smile Those two have that something.

CodeXP wrote:

I've also made a few changes to my own extern.php now, but I haven't bothered with Atom just yet (don't know if I'll ever, because I don't really need it).

Must admit, I've no real need for Atom either, but thought it only fair to offer the more O.S of the two formats too. big_smile Must admit, having messed about with it, I do actually prefer the layout of the Atom tags and such to the RSS ones. Easier to adapt to and work with. If you want that Atom script to play with, I can post it up. I think I've ironed out any little niggles/wrinkles now. big_smile

Could I pick your brains a tad more btw? Firstly, the Atom and RSS scripts. Should they preferably have the extension .xml rather than .php, and then get the webserver to execute them as with .php scripts?

Secondly, how do you manage the .php/.xml part with regards to the forum/site itself? Since having a diddle and look at your site, decided to have a go at getting the forum served up in xml or html, dependant on the browser. Have it almost working fine, apart from the fact that a XML capable browser will try to download the .php file rather than just open it, whereas, obviously, a .xml file it will open and display as it should.


Cheers,

Matt

21

Re: Atom feed generator

This last php/xml bit is driving me to distraction. big_smile

IE gets the correct header type, (text/html), and opens the forums.php, (running the portal mod), fine. Firefox gets the application/xhtml+xml header and tries downloading the forums.php file. Works fine with the same file renamed as forums.xml. I know I must be missing something obvious here, but can't find out what. big_smile

22 (edited by CodeXP 2007-09-22 20:55)

Re: Atom feed generator

MattF wrote:

This last php/xml bit is driving me to distraction. big_smile

IE gets the correct header type, (text/html), and opens the forums.php, (running the portal mod), fine. Firefox gets the application/xhtml+xml header and tries downloading the forums.php file. Works fine with the same file renamed as forums.xml. I know I must be missing something obvious here, but can't find out what. big_smile

Are you including the XML declaration? If not, it needs to be the very first thing on the page. Just add…

echo '<?xml version="1.0" encoding="'.$lang_common['lang_encoding'].'" ?>';

…as the first thing you echo out from header.php.

Also, the extension doesn't matter one bit as long as you are sending the document with the correct mime type, and correctly identifies the document as xml.

23

Re: Atom feed generator

Well, guess who's feeling a right muppet again? big_smile big_smile I was just posting the header output script code in this post for you to check it over, and happened to notice what was causing the problem. Spot the discrepancy below. big_smile big_smile (I'm off to find a dark corner to lurk in now).

if($mimetype == "application/xhtml+xml")
{

$prologue_type = '<?xml version="1.0" encoding="'.$lang_common['lang_encoding'].'"?>
<?xml-stylesheet type="text/css" href="'.$pun_config['o_base_url'].'/style/'.$pun_user['style'].'.css"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="'.$lang_common['lang_direction'].'">
<head>
<title>'.$page_title.'</title>'."\n";

}
header('Content-Type: '.$mime.'; charset='.$lang_common['lang_encoding']);

24

Re: Atom feed generator

Hehe, stuff like that happens to all of us from time to time wink

By the way, I don't know if you are aware of it but when you are serving the pages as application/xhtml+xml the tags in the your style sheets are now case sensitive so if you haven't done so already, it's a good idea to look over them. Also, you need to serve javascripts slightly different depending on if you're using text/html or xml. In XML, they should be enclosed in a CDATA section, instead of the usual html comment tags.

25

Re: Atom feed generator

big_smile I've spent nigh on half a day on and off chasing around that typo.

The css has all been lowercased. Did that because I hate seeing uppercase in scripts, then found out it's a requirement, so it served a real purpose. big_smile

With the javascript bit, I'm still a bit uncertain on that one. Am I correct in assuming that this first example is fine as it is:

<script type="text/javascript" src="./mod-addons/global.js"></script>

but that this second example would need the cdata tags enclosing all text/script placed between the '<script></script>' tags?

<script type="text/javascript">
<!--
function process_form(the_form)
{

   [ Rest of function trimmed out ]

}
// -->
</script>

Thanks for all your help and advice with this, btw. I really do appreciate it. smile