I generally try to make my course web pages act as web portals for the course, with all the information students need (except, of course, for the pearls of wisdom contained in their textbooks and my lectures) there. I've also been increasing my use of blogs (and now, podcasts). Therein lies my desire to syndicate RSS feeds onto my web pages. Previously, I had been using RSS-to-JavaScript.com (there are other similar services), which provides the ability to includes JavaScript on your web page that will generate customizable HTML summarizes from RSS feeds. The problem I had with this was increased page load time: I was dependent on responses from their server. Now, I've found a new tool that works much better: RSS2HTML, which is a free PHP script that generates HTML according to a template that you write. There are three ways that I've been using it:
- As a "complete web page generator". I use the PHP script, customized to hard-code the RSS feed and template file URLs, as my web page (for example, renamed as "index.php"). This is useful when the only feature available to you on your web site is PHP script execution.
- As a server-side include. For example, the SSI code
on one of my course pages will cause the PHP script to generate suitable HTML to be included for the course blog's RSS feed. The template file here is just an HTML snippet. This requires both PHP script and SSI support on the web server.
- The third approach is what I'm using as of this date for the
list of upcoming conference deadlines I place in this blog's
sidebar. In this case, I can't make use of either local PHP scripts
or SSI, as Blogger doesn't support them. So, I rolled my own RSS to
JavaScript service by placing a modified rss2html.php script on
another server, and use it to generate JavaScript output, rather
than HTML (the script doesn't care what's in the template, other
than the variables that it replaces with feed information). So, the
template contains lines like:
document.writeln(' ~~~ItemDescription~~~');
There was one problem: the RSS fields can contain single quotes, which will of course screw up the generated JavaScript. To fix this, the PHP script must be modified. Specifically, lines like these:$this->ItemTitle[] = trim($this->title); $this->ItemDescription[] = trim($this->description)
must be replaced with lines like these:$this->ItemTitle[] = str_replace("'", "’", trim($this->title)); $this->ItemDescription[] = str_replace("'", "’", trim($this->description));
This will replace single quotes with HTML entities that display as quotes but won't act to close the strings in thedocument.write()
calls.
Topics: RSS, web software.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.