Index: book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.439
diff -u -r1.439 book.module
--- book.module	25 Aug 2007 09:25:48 -0000	1.439
+++ book.module	27 Aug 2007 12:53:00 -0000
@@ -59,6 +59,13 @@
           'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
         );
       }
+      if (user_access('access content')) {
+        $links['book_feed'] = array(
+          'title' => t('Feed'),
+          'href' => 'book/feed/'. $node->nid,
+          'attributes' => array('title' => t('Access a feed of all changes below that page in the book hierarchy.'))
+        );
+      }
     }
   }
   return $links;
@@ -106,6 +113,12 @@
     'access arguments' => array('access printer-friendly version'),
     'type' => MENU_CALLBACK,
   );
+  $items['book/feed/%'] = array(
+    'page callback' => 'book_feed',
+    'page arguments' => array(2),
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
   $items['node/%node/outline'] = array(
     'title' => 'Outline',
     'page callback' => 'book_outline',
@@ -1523,3 +1536,53 @@
   return $tree[$cid];
 }
 
+/**
+ * Ancillary PRE function for book_feed
+ *
+ * @param $node
+ *   The node object being traversed
+ */
+function _book_feed_pre($node) {
+  $pubDate = date(DATE_RSS, $node->changed);
+  return format_rss_item(
+    $node->title,
+    url("node/$node->nid", array('absolute' => TRUE)),
+    strip_tags($node->teaser),
+    array('pubDate' => $pubDate)
+    );
+  }
+
+/**
+ * Ancillary POST function for book_feed
+ *
+ * @param $node
+ *   The node object being traversed
+ */
+function _book_feed_post($node)
+  {
+  return NULL ; //"post $node->nid ";
+  }
+
+/**
+/**
+ * Return a feed to nodes below the passed-in node in the book hierarchy,
+ * 
+ * @param $nid
+ *   Node below which the feed is built
+ */
+function book_feed($nid) {
+
+  global $base_url;
+
+  $namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"');
+  $node = node_load($nid);
+  $tree = book_menu_subtree_data($node->book);
+  $items = book_export_traverse($tree, '_book_feed_pre', '_book_feed_post');
+ 
+  $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
