make FeedGenerator pretty-print the XML
[scpubgit/SCS.git] / lib / SCSite / FeedGenerator.pm
index 463ce56..981865c 100644 (file)
@@ -62,15 +62,15 @@ sub _feed_data_to_tags {
     feed title subtitle link id
   );
   my ($web_url, $feed_url) = @{$data}{qw(web_url feed_url)};
-  (\'<?xml version="1.0" encoding="UTF-8"?>',
-  <feed xmlns="http://www.w3.org/2005/Atom">,
-    <title type="text">, $data->{title}, </title>,
+  (\'<?xml version="1.0" encoding="UTF-8"?>', "\n",
+  <feed xmlns="http://www.w3.org/2005/Atom">, "\n",
+    '  ', <title type="text">, $data->{title}, </title>, "\n",
     ($data->{subtitle}
-      ? (<subtitle type="text">, $data->{subtitle}, </subtitle>)
+      ? ('  ', <subtitle type="text">, $data->{subtitle}, </subtitle>, "\n",)
       : ()),
-    <link rel="alternate" type="text/html" href="${web_url}" />,
-    <link rel="self" type="application/atom+xml" href="${feed_url}" />,
-    <id>, $data->{id}, </id>,
+    '  ', <link rel="alternate" type="text/html" href="${web_url}" />, "\n",
+    '  ', <link rel="self" type="application/atom+xml" href="${feed_url}" />, "\n",
+    '  ', <id>, $data->{id}, </id>, "\n",
     (map $self->_entry_data_to_tags($_), @{$data->{entries}}),
   </feed>);
 }
@@ -79,18 +79,18 @@ sub _entry_data_to_tags {
   my ($self, $data) = @_;
   use XML::Tags qw(entry title link id published updated summary content);
   my $web_url = $data->{web_url};
-  <entry>,
-    <title>, $data->{title}, </title>,
-    <link href="${web_url}" />,
-    <id>, $self->_id_for($data->{web_url}), </id>,
-    <published>, $data->{created}, </published>,
-    <updated>, ($data->{created}||$data->{updated}), </updated>,
+  '  ', <entry>, "\n",
+    '    ', <title>, $data->{title}, </title>, "\n",
+    '    ', <link href="${web_url}" />, "\n",
+    '    ', <id>, $self->_id_for($data->{web_url}), </id>, "\n",
+    '    ', <published>, $data->{created}, </published>, "\n",
+    '    ', <updated>, ($data->{created}||$data->{updated}), </updated>, "\n",
     ($data->{summary_html}
-      ? (<summary type="html">, \($data->{summary_html}), </summary>)
+      ? ('    ', <summary type="html">, \($data->{summary_html}), </summary>, "\n")
       : ()
     ),
-    <content type="html">, \($data->{body_html}), </content>,
-  </entry>;
+    '    ', <content type="html">, \($data->{body_html}), </content>, "\n",
+  '  ', </entry>, "\n";
 }
 
 1;