George S. Baugh 4 éve
szülő
commit
aea965318f
2 módosított fájl, 24 hozzáadás és 11 törlés
  1. 19 10
      lib/Trog/Routes/HTML.pm
  2. 5 1
      www/templates/sitemap.tx

+ 19 - 10
lib/Trog/Routes/HTML.pm

@@ -1143,22 +1143,31 @@ sub _rss ($query,$posts) {
     );
 
     foreach my $post (@$posts) {
-        my $url = "http://$query->{domain}/posts/$post->{id}";
-        $rss->add_item(
-            title       => $post->{title},
-            permaLink   => $url,
-            link        => $url,
-            enclosure   => { url => $url, type=>"text/html" },
-            description => "<![CDATA[$post->{data}]]>",
-            pubDate     => DateTime->from_epoch(epoch => $post->{created} ), #TODO format like Thu, 23 Aug 1999 07:00:00 GMT
-            author      => $post->{user}, #TODO translate to "email (user)" format
-        );
+        my $url = "http://$query->{domain}$query->{local_href}";
+        _post2rss($rss,$url,$post);
+        next unless ref $post->{aliases} eq 'ARRAY';
+        foreach my $alias (@{$post->{aliases}}) {
+            $url = "http://$query->{domain}$alias";
+            _post2rss($rss,$url,$post);
+        }
     }
 
     require Encode;
     return [200, ["Content-type" => "application/rss+xml"], [Encode::encode_utf8($rss->as_string)]];
 }
 
+sub _post2rss ($rss,$url,$post) {
+    $rss->add_item(
+        title       => $post->{title},
+        permaLink   => $url,
+        link        => $url,
+        enclosure   => { url => $url, type=>"text/html" },
+        description => "<![CDATA[$post->{data}]]>",
+        pubDate     => DateTime->from_epoch(epoch => $post->{created} ), #TODO format like Thu, 23 Aug 1999 07:00:00 GMT
+        author      => $post->{user}, #TODO translate to "email (user)" format
+    );
+}
+
 =head2 manual
 
 Implements the /manual and /lib/* routes.

+ 5 - 1
www/templates/sitemap.tx

@@ -24,10 +24,14 @@
         : if ( $route_type == 'Static Routes' ) {
             <a href="<: $map :>">
             <: $map :>
+            </a><br />
         : } else {
+            : for $map.aliases -> $alias {
+                &#8227; <a href="<: $alias :>"><: $alias :></a><br />
+            : }
             <a href="<: $map.local_href :>">
             <: $map.title :>
+            </a><br />
         : }
-        </a><br />
     : }
 : }