 |
 |
Testing... |
 |
|
 |
Main Menu |
 |
|
 |
Topics |
 |
|
 |
Voice Over IP |
 |
|
 |
Last 10 Articles... |
 |
|
 |
Search this site |
 |
|
|  |
 |
This blog is no longer updated.
Since I own the domain name for a couple more years, and the hosting was paid-in-advance, it's still here. But I've moved on to Hawaii, and no longer have the need to publish all the sorts of neat stuff that made up the contents of this website.
If you've linked to me, you are invited to unlink, as your readers will no longer be presented with new content. Thanks, Steve
What I'm Reading
Saturday, September 18, 2004 : Stephen D. Carroll, rokus.net
|
|
Created the right-block today. Exported my OPML file (conveniently named "my.opml") and tweeked the script from http://ken.coar.org/burrow/blogroll.php to convert the OPML to HTML. Got rid of the word wrap by truncating to the first 20 characters or so.
Probably ought to separate the OPML files into topics of interest to break up the list into more friendly chunks. And technically, it's not everything I'm reading, it's just the stuff I read via RSS.
So, what does all this mean? OPML is the Outline Processor Markup Language, which is an aggregation of all the newsfeeds, blogs, and MS-stuff I read through NewsGator. If I want to send my list of feeds to another RSS aggregator, I export OPML from the source program (NewsGator) and import it to the destination. If you want to subscribe to all the feeds I subscribe to, you can just copy the file. Think of it as a big paper clip around all the RSS feeds that I use.
So, what's the big deal? I no longer have to sync my feeds manually - I can publish a single OPML file, import it at home, import it at work, post it on the web, and all my feeds are synchronized.
So, go ahead and download a copy of NewsGator, intraVnews (both are Outlook plugins), Pluck (IE plug in), or sign up for NewsGator Online for free. Import the OPML file and start reading!!
Code to create the blogroll follows:
<?php
/*
* Construct the blogroll. This is the place to make customisations
* to turn the OPML data into HTML.
*/
function blogroll($file) {
global $_BLOGROLL;
$_BLOGROLL = array();
if (! parse_opml($file)) {
return false;
}
if ($_BLOGROLL) {
/*
* $_BLOGROLL is an array with one element for each
* outline in the original XML file. The array key
* is the value of the 'title' attribute of each
* <outline> element; the value of each entry is an
* array of the attribute name/value pairs from the
* outline. For instance:
*
* $_BLOGROLL['foo'] =
* ['TITLE'] => 'foo'
* ['DESCRIPTION'] => 'from the outline'
* ['HTMLURL'] => 'http://example.com/blog/'
*
* et cetera.
*/
//print "<ul class=\"linklist\" id=\"blogroll\">\n";
ksort($_BLOGROLL);
foreach ($_BLOGROLL as $blog) {
/*
* Figure out what the anchor title attribute should be.
* Use the description if there is one, otherwise use
* the outlint title.
*/
if (isset($blog['DESCRIPTION']) && $blog['DESCRIPTION']) {
$alt = HTMLentities($blog['DESCRIPTION']);
}
else {
$alt = (isset($attr) && isset($attr['TITLE'])
? HTMLentities($attr['TITLE'])
: '');
}
/*
* Form an anchor for this outline.
*/
$url = explode('?', $blog['HTMLURL']);
for ($i = 0; $i < count($url); $i++) {
$url[$i] = HTMLentities($url[$i]);
}
$url = implode('?', $url);
$anchor = ('<a target="_blank" href="'
. $url
. '" title="' . $alt . '">'
. substr(HTMLentities($blog['TITLE']), 0, 21)
. '...</a>');
/*
* Here's the *real* place to make personal changes.
*/
print "-$anchor<br />\n";
}
print "\n";
}
$status = count($_BLOGROLL);
/*
* Nuke the global cell (ptui, ptui!)
*/
$_BLOGROLL = null;
return $status;
}
/*
* You shouldn't need to change anything from this point on.
*/
/*
* Parse the OPML file and extract the outlines from it.
*/
function parse_opml($file) {
$fp = @fopen($file, 'rB');
if (! $fp) {
return false;
}
$opml = fread($fp, 1000000);
$xp = xml_parser_create();
xml_set_element_handler($xp, '_xml_startElement', '_xml_endElement');
xml_parse($xp, $opml, true);
xml_parser_free($xp);
return true;
}
/*
* Helper functions for parsing the OPML file (which is XML).
* It's too bad we have to pollute the global namespace (variable
* $_BLOGROLL), but that's a limitation. I tried doing this OO
* inside an object, but indirect call-by-name apparently requires
* global function names. Sigh.
*
* Basically, add each outline to the $_BLOGROLL array, using
* the outline 'title' attribute as the key.
*/
function _xml_startElement($xp, $element, $attr) {
global $_BLOGROLL;
/*
* If it isn't an <outline> element, ignore it.
*/
if (strcasecmp('outline', $element)) {
return;
}
$_BLOGROLL[$attr['TITLE']] = $attr;
}
function _xml_endElement($xp, $element) {
return;
}
/*
* Local Variables:
* mode: C
* c-file-style: "bsd"
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/
blogroll("my.opml")
// this is where I ought to
?>
|
|
Permalink | Mail this...
|
|
|  |
 |
|
|