View previous topic :: View next topic |
Author |
Message |
chrisale
Joined: 09 Nov 2005 Posts: 187
|
Posted: Sat Nov 26, 2005 12:11 pm Post subject: RSS Feed |
|
|
I've impletemented an RSS feed on my site.
I just made a new template file (called weatherrss.htx) ... stuck in the data I wanted for the feed... and then I have a cron job to rename the generated "weatherrss.htm" to "weatherrss.xml"
The weatherrss.xml file is added to the FTP rules to be uploaded every 1 minute. So the cron job also runs every minute.
You're welcome to copy my code into your own file for an RSS feed. Make sure you keep the first 6 lines as is.. they're needed for the rest of the file to function.
Code: |
<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>Port Alberni Weather Conditions</title>
<link>http://weather.chrisale.info</link>
<description>Current Conditions, Almanac, and Trends for Port Alberni</description>
<language>en-us</language>
<pubDate>20051126,10:04:10</pubDate>
<ttl>1</ttl>
<generator>WView wview 1.8.4</generator>
<item>
<title>Conditions @ 10:04:10, 20051126</title>
<link>http://weather.chrisale.info/Current_Conditions.htm</link>
<description>Current Conditions in the City of Port Alberni</description>
<pubDate>10:04:10, 20051126</pubDate>
<guid isPermaLink="true">http://weather.chrisale.info/Current_Conditions.htm</guid>
<dc:date>20051126 - 10:04:10</dc:date>
<content:encoded><![CDATA[
<p>Mostly clear with little temperature change.<br><img src="fc-icon-sunny.gif"></p>
<p>Temp: 1.28 C<br>
Wind: NW at 0.0 kph<br>
Wind Chill: 1.3 C<br>
Barometer: 1023.40 + mb<br>
Humidity: 95 %<br>
Dewpoint: 0.56 C<br>
Rain Rate: 0.000 cm<br>
</p>
]]></content:encoded>
</item>
</channel>
</rss>
|
For the cron job, make sure you make it as the root user. Since its' every minute, it is a very simply entry...
* * * * * cp /var/wview/img/weatherrss.htm /var/wview/img/weatherrss.xml
Cheers.
Chris |
|
Back to top |
|
|
mteel
Joined: 30 Jun 2005 Posts: 435 Location: Collinsville, TX
|
Posted: Sat Nov 26, 2005 3:42 pm Post subject: |
|
|
I was going to suggest you do this - good deal. Now could you possibly use the wview tags for your station name etc? Anything you can abstract by using wview tags you should. In fact, email me a copy of the template file with tags instead of replaced values...
I can create a new "mode" for generation which will generate the proper file extension, thus removing the need for a cron job. Might not make it into 1.8.5 - but if not, soon.
Thanks for the contribution. |
|
Back to top |
|
|
mteel
Joined: 30 Jun 2005 Posts: 435 Location: Collinsville, TX
|
Posted: Sat Nov 26, 2005 3:55 pm Post subject: |
|
|
Let me be the newb for a minute: how does RSS with this xml file work? |
|
Back to top |
|
|
chrisale
Joined: 09 Nov 2005 Posts: 187
|
Posted: Sat Nov 26, 2005 7:43 pm Post subject: |
|
|
Ya I'll post one without my names in there... I just took the name tags out so that it didn't have the underscores and stuff in it.
As far as how the RSS works. Not sure your basic familiarity but basically XML works the same as HTML it uses tags (elements) to describe the content. The difference with XML being that you can create your own tags and rules for those tags.
So RSS is simply an implementation of a bunch of rules and tags in an XML file.
The browser (Firefox) or RSS reader notices the XML and RSS tags at the top of the document... new browsers have the "RSS 2.0" specification bult-in.. just like a web browser stores the HTML definitions.
The basic RSS spec is very basic though... so that it's very cross-platform capable... but you can add onto it. That's where the "xmlns" attributes come in. They point to other RSS definition/rule sets that extend the regular RSS.
As for the RSS content itself... It's fairly self explanatory... the "channel", "title" and other simple tags are all the basic RSS 2.0 stuff. The tags that start with "dc:" or "content:" come from the external definitions.
The main content that people see in their RSS reader is in the "content:encoded" tag. It's "encoded" in HTML format... It has to include the "<![CDATA[" to start... CDATA refers to HTML content. You can stick any HTML code inside the "content:encoded" element.
I gotta run. But that's the basics I think. If you have any other questions don't hesitate, I'll try to post that cleaned out RSS example tonight. |
|
Back to top |
|
|
chrisale
Joined: 09 Nov 2005 Posts: 187
|
Posted: Sat Nov 26, 2005 8:43 pm Post subject: |
|
|
Here's the weatherrss.htx file:
I've made it more generic... put in the original station tags and stuff... and put in other generic stuff.
Code: |
<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title><!--stationCity--> <!--stationState--></title>
<link>http://insert your website here</link>
<description>Your Station Description</description>
<language>en-us</language>
<pubDate><!--stationDate-->,<!--stationTime--></pubDate>
<ttl>1</ttl>
<generator>WView <!--wviewVersion--></generator>
<item>
<title>Conditions @ <!--stationTime-->, <!--stationDate--></title>
<link>http://weather.chrisale.info/Current_Conditions.htm</link>
<description>Your Station Description</description>
<pubDate><!--stationTime-->, <!--stationDate--></pubDate>
<guid isPermaLink="true">http://weather.chrisale.info/Current_Conditions.htm</guid>
<dc:date><!--stationDate--> - <!--stationTime--></dc:date>
<content:encoded><![CDATA[
<p><!--forecastRule--><br><!--forecastIcon--></p>
<p>Temp: <!--outsideTemp--><!--tempUnit--><br>
Wind: <!--windDirection--> at <!--windSpeed--><!--windUnit--><br>
Wind Chill: <!--windChill--><!--tempUnit--><br>
Barometer: <!--barometer--><!--barUnit--><br>
Humidity: <!--outsideHumidity--><!--humUnit--><br>
Dewpoint: <!--outsideDewPt--><!--tempUnit--><br>
Rain Rate: <!--rainRate--><!--rainUnit--><br>
</p>
]]></content:encoded>
</item>
</channel>
</rss>
|
I just realised I didn't post a link to the RSS feed. If you use Firefox (it has RSS buitin) you can click on the "XML" button at the bottom of my frontpage: http://weather.chrisale.info |
|
Back to top |
|
|
mteel
Joined: 30 Jun 2005 Posts: 435 Location: Collinsville, TX
|
Posted: Sat Nov 26, 2005 10:20 pm Post subject: |
|
|
When I select the XML button (using Firefox) I get:
Quote: |
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<rss version="2.0">
-
<channel>
<title>Port Alberni Weather Conditions</title>
<link>http://weather.chrisale.info</link>
-
<description>
Current Conditions, Almanac, and Trends for Port Alberni
</description>
<language>en-us</language>
<pubDate>20051126,20:17:10</pubDate>
<ttl>1</ttl>
<generator>WView wview 1.8.4</generator>
-
<item>
<title>Conditions @ 20:17:10, 20051126</title>
-
<link>
http://weather.chrisale.info/Current_Conditions.htm
</link>
<description>Current Conditions in the City of Port Alberni</description>
<pubDate>20:17:10, 20051126</pubDate>
-
<guid isPermaLink="true">
http://weather.chrisale.info/Current_Conditions.htm
</guid>
<dc:date>20051126 - 20:17:10</dc:date>
-
<content:encoded>
<p>Increasing clouds with little temperature change. Precipitation possible within 24 to 48 hours.<br><img src="fc-icon-partlycloudy.gif"></p>
<p>Temp: 1.61 C<br>
Wind: NW at 0.0 kph<br>
Wind Chill: 1.6 C<br>
Barometer: 1022.66 - mb<br>
Humidity: 95 %<br>
Dewpoint: 0.89 C<br>
Rain Rate: 0.000 cm<br>
</p>
</content:encoded>
</item>
</channel>
</rss> |
Hmmm... |
|
Back to top |
|
|
chrisale
Joined: 09 Nov 2005 Posts: 187
|
Posted: Sat Nov 26, 2005 10:33 pm Post subject: |
|
|
Ah yes, when you're using Firefox for RSS you have to use the "Sage" Extension to view RSS. I believe all Firefox versions since 1.0 have included the Sage plugin. Firefox itself doesn't render the RSS.
In your "Tools" menu should be a "Sage" option... click it... it'll open a bar on the right.
Then go to my weather page, and click the search (loupe) button in Sage, and it should discover the RSS feed. |
|
Back to top |
|
|
mteel
Joined: 30 Jun 2005 Posts: 435 Location: Collinsville, TX
|
Posted: Sat Nov 26, 2005 11:12 pm Post subject: |
|
|
I have Firefox 1.07...
I had to install the Sage extension, it is not included by default apparently.
After that it worked, pretty cool. |
|
Back to top |
|
|
chrisale
Joined: 09 Nov 2005 Posts: 187
|
Posted: Sat Nov 26, 2005 11:20 pm Post subject: |
|
|
Sorry 'bout that, I don't use Firefox as my main browser.. |
|
Back to top |
|
|
mteel
Joined: 30 Jun 2005 Posts: 435 Location: Collinsville, TX
|
Posted: Sun Nov 27, 2005 10:13 am Post subject: |
|
|
OK, I've incorporated it into 1.8.5 after changing the format and contents a bit. No cron job required, wview now recognizes "xtx" templates and generates "xml" files from them. I've created a new template file "wxrss.xtx" in the distro and enabled it for all home page template examples as well as including it in the "html-templates.conf" file.
You can discover my RSS feed at: http://www.weather.teel.ws/
I have hidden the XML reference in the home page templates so it is not visible in any way, but the RSS feed is discovered using Sage while on my home page. I might add text to indicate a RSS feed is available in the templates...
Now to tidy everything up and get a release out today.
Thanks again. |
|
Back to top |
|
|
chrisale
Joined: 09 Nov 2005 Posts: 187
|
Posted: Sun Nov 27, 2005 11:32 am Post subject: |
|
|
Right on!
thanks! |
|
Back to top |
|
|
mteel
Joined: 30 Jun 2005 Posts: 435 Location: Collinsville, TX
|
Posted: Sun Nov 27, 2005 11:34 am Post subject: |
|
|
1.8.5 is released and available... |
|
Back to top |
|
|
wxnut
Joined: 12 Jul 2005 Posts: 5 Location: Cleves, OH (Cincinnati)
|
Posted: Mon Nov 28, 2005 7:55 pm Post subject: RSS Feed Icon |
|
|
Mark and Chris,
Thanks for implementing the RSS feature.
I figured out how to display the RSS orange icon at the bottom right corner of the browser (Firefox in this case). Just add the following line near the top of the index.htx file and edit the title.
<link rel="alternate" type="application/rss+xml" title="Subscribe to Cleves,OH Weather" href="wxrss.xml">
See my web site for a demo.
http://www.cas.uc.edu/~ciminero/ClevesWeather/
Ron _________________ "Some people are weatherwise, but most are otherwise."
Benjamin Franklin |
|
Back to top |
|
|
mteel
Joined: 30 Jun 2005 Posts: 435 Location: Collinsville, TX
|
Posted: Mon Nov 28, 2005 8:02 pm Post subject: |
|
|
Thanks Ron,
That's cool!
I tried it with Internet Exploder, didn't seem to recognize it, but no big surprise there...
I will add that html code to the templates and make it generic using the wview tags for location. In the next release...
Mark |
|
Back to top |
|
|
wxnut
Joined: 12 Jul 2005 Posts: 5 Location: Cleves, OH (Cincinnati)
|
Posted: Mon Nov 28, 2005 8:07 pm Post subject: RSS Feed Icon correction |
|
|
Hi,
Need not include the "Subscribe to ... " in the title of
<link > tag. RSS supplies it.
<link rel="alternate" type="application/rss+xml" title="Cleves,OH Weather" href="wxrss.xml">
Ron[/quote] _________________ "Some people are weatherwise, but most are otherwise."
Benjamin Franklin |
|
Back to top |
|
|
|