Noticed from access log that I had forgotten to supply an atom module when I upgraded to Drupal 4.6.0. There isn't one on the drupal download site and a grep through the source for 'atom' gave nothing so I copied my 4.5.x version and it Just Worked (e.g). I'm not sure who it is that is downloading the atom feed it but I'd hate to disappoint them.
Items filed under atom
After upgrading my site to Drupal 4.5.0 I looked on the drupal site for an updated version of the atom module and found none.
So I updated it myself. The module file is here. This is just a gzipped module file, not a tar, gzip -d it and copy to the modules directory to install. After that /atom/feed link should give you an atom feed.
All I have done is added the atom_menu function required by Drupal 4.5.0 and changed the help link in atom_help.
Here is the code:
1 // $Id: atom.module,v 1.7.2.1 2004/04/29 05:13:03 dries Exp $ 2 3 function atom_help($section) { 4 $output = ""; 5 6 switch ($section) { 7 case "admin/modules#description": 8 $output = t("Provides an Atom 0.3 feed"); 9 break; 10 } 11 return $output; 12 } 13 14 function atom_menu($may_cache) { 15 global $user; 16 $items = array(); 17 if ($may_cache) { 18 $items[] = array('path' => 'atom/feed', 'title' => t('Atom feed'), 19 'callback' => 'atom_feed', 20 'access' => user_access('access content'), 21 'type' => MENU_CALLBACK); 22 } 23 return $items; 24 } 25 26 function atom_feed() { 27 global $base_url; 28 $output = ""; 29 $last_mod = 0; 30 $nodes = db_query_range("SELECT n.nid, u.uid, u.name FROM {node} n, {users} u WHERE n.uid = u.uid AND 31 n.promote = '1' AND n.status = '1' ORDER BY n.created DESC", 0, 15); 32 33 while ($node = db_fetch_object($nodes)) { 34 $item = node_load(array("nid" => $node->nid)); 35 $link = url("node/view/$node->nid", NULL, NULL, true); 36 $output .= " <entry>\n"; 37 $output .= " <title>". $item->title ."</title>\n"; 38 $output .= " <link rel=\"alternate\" type=\"text/html\" href=\"". $link ."\" />\n"; 39 $output .= " <id>$link</id>\n"; 40 $output .= " <issued>". _atom_timestamp2w3dtf($item->created) ."</issued>\n"; 41 $output .= " <modified>". _atom_timestamp2w3dtf($item->changed) ."</modified>\n"; 42 $last_mod = $item->changed; 43 $output .= " <author>\n"; 44 $output .= " <name>". $node->name ."</name>\n"; 45 $output .= " </author>\n"; 46 $output .= " </entry>\n"; 47 } 48 49 header("Content-Type: application/xml"); 50 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; 51 print "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\">\n"; 52 print " <title>". variable_get("site_name", "drupal") ." - ". variable_get("site_slogan", "") ."</title>\n"; 53 print " <link rel=\"alternate\" type=\"text/html\" href=\"". $base_url. "\"/>\n"; 54 print " <modified>". _atom_timestamp2w3dtf($last_mod) ."</modified>\n"; 55 print $output; 56 print "</feed>\n"; 57 } 58 59 function _atom_timestamp2w3dtf($timestamp) { 60 $tz = date("O", $timestamp); 61 return date("Y-m-d", $timestamp) ."T". date("H:i:s", $timestamp) . substr($tz, 0, 3) . ":" . substr($tz, 3, 2); 62 }
Add a comment
Added an atom feed to keep whatever keeps trying to find one happy. I did this as follows:
- Installed atom module. Zero documentation.
- Enabled module in drupal
-
Added this to .htaccess file:
RewriteRule atom.xml atom/feed/1
The link is also here.
Regarding any Atom v RSS wars, I'm probably on the RSS side as the tools I have used (Python Desktop Server, Drupal) have supported it by default and they work for me. Atom is for those Blogger.com instant boilerplate blog folk.
1 Comment

