Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.406
diff -u -r1.406 book.module
--- modules/book/book.module	9 Jan 2007 08:31:22 -0000	1.406
+++ modules/book/book.module	25 Feb 2007 01:00:00 -0000
@@ -119,6 +119,11 @@
       'type' => MENU_CALLBACK);
   }
   else {
+    $items[] = array(
+      'path' => 'book/feed',
+      'callback' => 'book_feed',
+      'access' => user_access('access content'),
+      'type' => MENU_CALLBACK);
     // Add the CSS for this module
     // We put this in !$may_cache so it's only added once per request
     drupal_add_css(drupal_get_path('module', 'book') .'/book.css');
@@ -999,4 +1004,42 @@
   }
 }
 
+function book_feed_pre($node)
+  {
+  $pubDate = date(DATE_RSS, $node->changed);
+  return format_rss_item(
+    $node->title,
+    url("node/$node->nid", NULL, NULL, TRUE),
+    strip_tags($node->teaser),
+    array('pubDate' => $pubDate)
+    );
+  }
+
+function book_feed_post($node)
+  {
+  return NULL ; //"post $node->nid ";
+  }
+
+/**
+ * Generates a RSS feed for the pages of the book below the page at the
+ * passed-in nid, with a depth of $depth
+ *
+ * @param int $nid 0 is invalid
+ * @param int $depth 0 means unlimited
+ * @return string RSS 2.0 feed
+ */
+function book_feed($nid, $depth = 0)
+  {
+  global $base_url;
+
+  $namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"');
+  $items = book_recurse($nid, $depth, 'book_feed_pre', 'book_feed_post');
+  $node = node_load($nid);
 
+  $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+    . "<rss version=\"2.0\" xml:base=\"$base_url\" ". implode(' ', $namespaces) .">\n"
+    . format_rss_channel($node->title, url("node/$nid"), $node->teaser, $items)
+    . "</rss>\n";
+  drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
+  print $output;
+  }
\ No newline at end of file
