Drop XML::OPML::SimpleGen dep
Tomas Doran [Tue, 26 Jan 2010 01:27:47 +0000 (01:27 +0000)]
ISSUES
Makefile.PL
lib/Gitalist/Controller/OPML.pm
root/opml.tt2 [new file with mode: 0644]
t/opml.t

diff --git a/ISSUES b/ISSUES
index 826c233..448f798 100644 (file)
--- a/ISSUES
+++ b/ISSUES
@@ -1,5 +1,6 @@
 * Root /search page doesn't do anything
 * Atom feed sucks shit (see t/atom.t)
+* OPML Feed dates incorrect format
 * Sort out commitdiff so conflicted merges have an equivalent display to gitweb (d7f39bebabeb31ce9a7b4f1b6f3db9f391b78c3e as a reference)
 * Need to sanitise the input ...
 * The snapshot action does not properly support tgz - requests for this format will receive a tar.  tbz2 is not supported at all (yet).
index 13b84df..6c86077 100644 (file)
@@ -93,7 +93,6 @@ requires 'Syntax::Highlight::Engine::Kate';
 requires 'Sys::Hostname';
 requires 'XML::Atom';
 requires 'XML::RSS';
-requires 'XML::OPML::SimpleGen';
 
 test_requires 'Test::More' => '0.88';
 test_requires 'Test::utf8' => '0.02';
index bd7670f..ece56f3 100644 (file)
@@ -2,7 +2,7 @@ package Gitalist::Controller::OPML;
 
 use Moose;
 use Moose::Autobox;
-
+use DateTime;
 use Sys::Hostname qw/hostname/;
 use XML::OPML::SimpleGen;
 
@@ -15,16 +15,14 @@ sub opml : Chained('/base') Args(0) {
 
     my $opml = XML::OPML::SimpleGen->new();
 
-    $opml->head(title => lc(hostname()) . ' - ' . blessed($c)->config->{name});
-
-    for my $repos ( $c->model()->repositories->flatten ) {
-        $opml->insert_outline(
-            text   => $repos->name. ' - '. $repos->description,
-            xmlUrl => $c->uri_for_action('/repository/rss', [$repos->name])->as_string,
-        );
-    }
+    $c->stash(
+        title => lc(hostname()) . ' - ' . blessed($c)->config->{name},
+        Repositories => $c->model()->repositories,
+        now => DateTime->now,
+        template => 'opml.tt2',
+        no_wrapper => 1,
+    );
 
-    $c->response->body($opml->as_string);
     $c->response->content_type('application/rss');
 }
 
diff --git a/root/opml.tt2 b/root/opml.tt2
new file mode 100644 (file)
index 0000000..a05297e
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<opml version="1.1">
+  <body>[% count = 1 %]
+    [% FOR Repository = Repositories %]
+    <outline id="[% count %]"
+             description=""
+             text="[% Repository.name %] - [% Repository.description %]"
+             title=""
+             type="rss"
+             version="RSS"
+             xmlUrl="[% c.uri_for_action('/repository/rss', [ Repository.name ])%]" />
+    [% SET count = count + 1; END %]
+    </body>
+    <head>
+        <dateCreated>[% now %]</dateCreated>
+        <dateModified>[% now %]</dateModified>
+        <title>[% title %]</title>
+    </head>
+</opml>
index a3ea5c6..d468b44 100644 (file)
--- a/t/opml.t
+++ b/t/opml.t
@@ -6,6 +6,7 @@ use TestGitalist;
 my $res = request('/opml');
 ok $res->is_success;
 
+is $res->content_type, 'application/rss';
 like $res->content, qr{Gitalist</title>};
 like $res->content, qr{xmlUrl="http://localhost/bare.git/rss"};
 like $res->content, qr{text="repo1 - some test repository"};