I recently discovered the magic of RSS aggregators (tried out
kaggregator on KDE), and realized that Campsite's RSS feed didnt work
with it. Ok, no problem, i thought, cant be that hard to get it
working...ahem.
After several attempts, the following is the simplest I've been able
to make it. Maybe someone knows a less hackier way to do this. If
you know, please tell me, because I want to post some intructions in
the manual.
Summary:
This hack is the result of trying to overcome three problems:
1) There doesnt seem like there is a way in campsite to display a
specific template, except by creating an empty section and assigning
the template to it.
2) There isnt a way in the template language to set the HTTP headers
of a page. In this case we need to tell the browser that the
"Content-type" is "text/xml".
3) PHP wrapper annoyances
Step 1) Create your RSS feed. Create a template named "rss.tpl" that
looks something like what written below. Notice that there is no
at the top. This is on purpose, if you put it
in there the PHP wrapper will think this is PHP code and try to
execute it (point #3 above). When it tries to do this, it will crash.
I've tested the RSS below using a web-based feed validator and it
says it still checks out even without the XML tag. The PHP code at
the beginning and end of the sample below is to overcome point #2
above and also to strip out HTML from the new stories.
-----------------------------------------------------------------------------------------------
ob_start();
?>
xmlns="http://purl.org/rss/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
// Optional: remove mixed content to insure 100% compatible RSS.
// Comment out the next 2 lines if you dont want this.
$allowedTags="";
$content = strip_tags($content, $allowedTags);
Step 2) Because of problem #1 above, we need to assign this template
to a section. So create a new section (doesnt matter where), and call
it "rss". Configure the section so that its templates are "rss.tpl",
and give the section the URL name of "rss". The URL to this section
will be the URL to your RSS feed.
(this one is for mugur)
By the way, I didnt see a way to get the time for the publish date -
is there a way to do that? ( look in the code below for what I did for
the publish date)
On 4/5/06, Paul Baranowski wrote:
> I recently discovered the magic of RSS aggregators (tried out
> kaggregator on KDE), and realized that Campsite's RSS feed didnt work
> with it. Ok, no problem, i thought, cant be that hard to get it
> working...ahem.
>
> After several attempts, the following is the simplest I've been able
> to make it. Maybe someone knows a less hackier way to do this. If
> you know, please tell me, because I want to post some intructions in
> the manual.
>
> Summary:
> This hack is the result of trying to overcome three problems:
>
> 1) There doesnt seem like there is a way in campsite to display a
> specific template, except by creating an empty section and assigning
> the template to it.
> 2) There isnt a way in the template language to set the HTTP headers
> of a page. In this case we need to tell the browser that the
> "Content-type" is "text/xml".
> 3) PHP wrapper annoyances
>
> Step 1) Create your RSS feed. Create a template named "rss.tpl" that
> looks something like what written below. Notice that there is no
> at the top. This is on purpose, if you put it
> in there the PHP wrapper will think this is PHP code and try to
> execute it (point #3 above). When it tries to do this, it will crash.
> I've tested the RSS below using a web-based feed validator and it
> says it still checks out even without the XML tag. The PHP code at
> the beginning and end of the sample below is to overcome point #2
> above and also to strip out HTML from the new stories.
> -----------------------------------------------------------------------------------------------
>
> ob_start();
> ?>
>
> xmlns="http://purl.org/rss/1.0/"
> xmlns:dc="http://purl.org/dc/elements/1.1/">
>
>
> Campware News
> http://www.campware.org
> Free Software for a Free Press
> en-us
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> http://www.campware.org
>
> body>
>
> "%Y-%m-%d">T00:00:00+00:00
>
>
>
>
>
> header("Content-type: text/xml");
>
> $content = ob_get_clean();
>
> // Optional: remove mixed content to insure 100% compatible RSS.
> // Comment out the next 2 lines if you dont want this.
> $allowedTags="";
> $content = strip_tags($content, $allowedTags);
>
> echo $content;
> ?>
> ---------------------------------------------------------------------------------------------
>
> Step 2) Because of problem #1 above, we need to assign this template
> to a section. So create a new section (doesnt matter where), and call
> it "rss". Configure the section so that its templates are "rss.tpl",
> and give the section the URL name of "rss". The URL to this section
> will be the URL to your RSS feed.
>
>
> - Paul
>
Hi Paul,
had same problems with rss on our instances especialy because "pseudo
rss"(created only from tpl files) how i like to call it cannot be read in
Firefox feed reader(integrated). Looks like Firefox expect rss to be served
as XML file only. So, I came upto this... basicly, as for template there are
no big differences, only part where file header is set.
"); ?>
href=\
"); ?>
basicly the same, except you dont need to escape from wrapper, but You will
need to escape quotes as usualy in php, though I like the way You stripped
html tags, i had ugly solution with external php script called from cron via
lynx... You can wrap it in CDATA for description in RSS, but then XSL in
firefox will not return it correctly if I recall it right...
last, third line, is for XSL template (check out www.mediaonweb.org and
click on RSS link). So, as You can see, drawback is that we cannot get
RFC-822 date needed for RSS 2.0(yes you can hack it with adding not acurate
time and timezone).
----- Original Message -----
From: "Paul Baranowski"
To:
Sent: Wednesday, April 05, 2006 2:47 PM
Subject: [campsite-dev] Re: My hack to get RSS working
(this one is for mugur)
By the way, I didnt see a way to get the time for the publish date -
is there a way to do that? ( look in the code below for what I did for
the publish date)
On 4/5/06, Paul Baranowski wrote:
> I recently discovered the magic of RSS aggregators (tried out
> kaggregator on KDE), and realized that Campsite's RSS feed didnt work
> with it. Ok, no problem, i thought, cant be that hard to get it
> working...ahem.
>
> After several attempts, the following is the simplest I've been able
> to make it. Maybe someone knows a less hackier way to do this. If
> you know, please tell me, because I want to post some intructions in
> the manual.
>
> Summary:
> This hack is the result of trying to overcome three problems:
>
> 1) There doesnt seem like there is a way in campsite to display a
> specific template, except by creating an empty section and assigning
> the template to it.
> 2) There isnt a way in the template language to set the HTTP headers
> of a page. In this case we need to tell the browser that the
> "Content-type" is "text/xml".
> 3) PHP wrapper annoyances
>
> Step 1) Create your RSS feed. Create a template named "rss.tpl" that
> looks something like what written below. Notice that there is no
> at the top. This is on purpose, if you put it
> in there the PHP wrapper will think this is PHP code and try to
> execute it (point #3 above). When it tries to do this, it will crash.
> I've tested the RSS below using a web-based feed validator and it
> says it still checks out even without the XML tag. The PHP code at
> the beginning and end of the sample below is to overcome point #2
> above and also to strip out HTML from the new stories.
> -----------------------------------------------------------------------------------------------
>
> ob_start();
> ?>
>
> xmlns="http://purl.org/rss/1.0/"
> xmlns:dc="http://purl.org/dc/elements/1.1/">
>
>
> Campware News
> http://www.campware.org
> Free Software for a Free Press
> en-us
>
>
>
>
>
>
>
>
> desc>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> http://www.campware.org
>
> body>
>
> "%Y-%m-%d">T00:00:00+00:00
>
>
>
>
>
> header("Content-type: text/xml");
>
> $content = ob_get_clean();
>
> // Optional: remove mixed content to insure 100% compatible RSS.
> // Comment out the next 2 lines if you dont want this.
> $allowedTags="";
> $content = strip_tags($content, $allowedTags);
>
> echo $content;
> ?>
> ---------------------------------------------------------------------------------------------
>
> Step 2) Because of problem #1 above, we need to assign this template
> to a section. So create a new section (doesnt matter where), and call
> it "rss". Configure the section so that its templates are "rss.tpl",
> and give the section the URL name of "rss". The URL to this section
> will be the URL to your RSS feed.
>
>
> - Paul
>
I tested my RSS templates with bloglines.com and other tools and they
seemed to work. Certainly the HTTP Content-Type header is important. I
used a custom-coded wrapper to process mine. If you don't have access to
the code I can sent it to you -- it's part of the campsite template work
that I did. I don't kno w if/how it works with the new version(s).
Cheers
JP
Paul Baranowski wrote:
>I recently discovered the magic of RSS aggregators (tried out
>kaggregator on KDE), and realized that Campsite's RSS feed didnt work
>with it. Ok, no problem, i thought, cant be that hard to get it
>working...ahem.
>
>After several attempts, the following is the simplest I've been able
>to make it. Maybe someone knows a less hackier way to do this. If
>you know, please tell me, because I want to post some intructions in
>the manual.
>
>Summary:
>This hack is the result of trying to overcome three problems:
>
>1) There doesnt seem like there is a way in campsite to display a
>specific template, except by creating an empty section and assigning
>the template to it.
>2) There isnt a way in the template language to set the HTTP headers
>of a page. In this case we need to tell the browser that the
>"Content-type" is "text/xml".
>3) PHP wrapper annoyances
>
>Step 1) Create your RSS feed. Create a template named "rss.tpl" that
>looks something like what written below. Notice that there is no
> at the top. This is on purpose, if you put it
>in there the PHP wrapper will think this is PHP code and try to
>execute it (point #3 above). When it tries to do this, it will crash.
> I've tested the RSS below using a web-based feed validator and it
>says it still checks out even without the XML tag. The PHP code at
>the beginning and end of the sample below is to overcome point #2
>above and also to strip out HTML from the new stories.
>-----------------------------------------------------------------------------------------------
>
>ob_start();
>?>
>
>xmlns="http://purl.org/rss/1.0/"
>xmlns:dc="http://purl.org/dc/elements/1.1/">
>
>
> Campware News
> http://www.campware.org
> Free Software for a Free Press
> en-us
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> http://www.campware.org
>
>body>
>
>"%Y-%m-%d">T00:00:00+00:00
>
>
>
>
>
>header("Content-type: text/xml");
>
>$content = ob_get_clean();
>
>// Optional: remove mixed content to insure 100% compatible RSS.
>// Comment out the next 2 lines if you dont want this.
>$allowedTags="";
>$content = strip_tags($content, $allowedTags);
>
>echo $content;
>?>
>---------------------------------------------------------------------------------------------
>
>Step 2) Because of problem #1 above, we need to assign this template
>to a section. So create a new section (doesnt matter where), and call
>it "rss". Configure the section so that its templates are "rss.tpl",
>and give the section the URL name of "rss". The URL to this section
>will be the URL to your RSS feed.
>
>
>- Paul
>
>
>
"1) There doesnt seem like there is a way in campsite to display a
specific template, except by creating an empty section and assigning the template to it."
Paul Baranowski wrote: I recently discovered the magic of RSS aggregators (tried out
kaggregator on KDE), and realized that Campsite's RSS feed didnt work
with it. Ok, no problem, i thought, cant be that hard to get it
working...ahem.
After several attempts, the following is the simplest I've been able
to make it. Maybe someone knows a less hackier way to do this. If
you know, please tell me, because I want to post some intructions in
the manual.
Summary:
This hack is the result of trying to overcome three problems:
1) There doesnt seem like there is a way in campsite to display a
specific template, except by creating an empty section and assigning
the template to it.
2) There isnt a way in the template language to set the HTTP headers
of a page. In this case we need to tell the browser that the
"Content-type" is "text/xml".
3) PHP wrapper annoyances
Step 1) Create your RSS feed. Create a template named "rss.tpl" that
looks something like what written below. Notice that there is no
at the top. This is on purpose, if you put it
in there the PHP wrapper will think this is PHP code and try to
execute it (point #3 above). When it tries to do this, it will crash.
I've tested the RSS below using a web-based feed validator and it
says it still checks out even without the XML tag. The PHP code at
the beginning and end of the sample below is to overcome point #2
above and also to strip out HTML from the new stories.
-----------------------------------------------------------------------------------------------
ob_start();
?>
// Optional: remove mixed content to insure 100% compatible RSS.
// Comment out the next 2 lines if you dont want this.
$allowedTags="
";
$content = strip_tags($content, $allowedTags);
Step 2) Because of problem #1 above, we need to assign this template
to a section. So create a new section (doesnt matter where), and call
it "rss". Configure the section so that its templates are "rss.tpl",
and give the section the URL name of "rss". The URL to this section
will be the URL to your RSS feed.
- Paul
---------------------------------
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min.
Yep, you are right, please file a ticket for me to implement this in 2.6
Mugur
Paul Baranowski wrote: (this one is for mugur)
By the way, I didnt see a way to get the time for the publish date - is there a way to do that? ( look in the code below for what I did for the publish date)
On 4/5/06, Paul Baranowski
wrote:
> I recently discovered the magic of RSS aggregators (tried out
> kaggregator on KDE), and realized that Campsite's RSS feed didnt work
> with it. Ok, no problem, i thought, cant be that hard to get it
> working...ahem.
>
> After several attempts, the following is the simplest I've been able
> to make it. Maybe someone knows a less hackier way to do this. If
> you know, please tell me, because I want to post some intructions in
> the manual.
>
> Summary:
> This hack is the result of trying to overcome three problems:
>
> 1) There doesnt seem like there is a way in campsite to display a
> specific template, except by creating an empty section and assigning
> the template to it.
> 2) There isnt a way in the template language to set the HTTP headers
> of a page. In this case we need to tell the browser that the
> "Content-type" is "text/xml".
> 3) PHP wrapper annoyances
>
> Step 1) Create your RSS feed. Create a template named "rss.tpl" that
> looks something like what written below. Notice that there is no
> at the top. This is on purpose, if you put it
> in there the PHP wrapper will think this is PHP code and try to
> execute it (point #3 above). When it tries to do this, it will crash.
> I've tested the RSS below using a web-based feed validator and it
> says it still checks out even without the XML tag. The PHP code at
> the beginning and end of the sample below is to overcome point #2
> above and also to strip out HTML from the new stories.
> -----------------------------------------------------------------------------------------------
> > ob_start();
> ?>
>
> xmlns="http://purl.org/rss/1.0/"
> xmlns:dc="http://purl.org/dc/elements/1.1/">
>
>
Campware News>
> http://www.campware.org
> Free Software for a Free Press
> en-us
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> http://www.campware.org
> > body>
> > "%Y-%m-%d">T00:00:00+00:00
>
>
>
>
> > header("Content-type: text/xml");
>
> $content = ob_get_clean();
>
> // Optional: remove mixed content to insure 100% compatible RSS.
> // Comment out the next 2 lines if you dont want this.
> $allowedTags="
";
> $content = strip_tags($content, $allowedTags);
>
> echo $content;
> ?>
> ---------------------------------------------------------------------------------------------
>
> Step 2) Because of problem #1 above, we need to assign this template
> to a section. So create a new section (doesnt matter where), and call
> it "rss". Configure the section so that its templates are "rss.tpl",
> and give the section the URL name of "rss". The URL to this section
> will be the URL to your RSS feed.
>
>
> - Paul
>
---------------------------------
How low will we go? Check out Yahoo! Messenger