Browse Source

Add port if used to RSS abs uris

George Baugh 2 years ago
parent
commit
b745f4c0b4
2 changed files with 6 additions and 4 deletions
  1. 5 4
      lib/Trog/Routes/HTML.pm
  2. 1 0
      www/templates/html/components/header.tx

+ 5 - 4
lib/Trog/Routes/HTML.pm

@@ -1290,10 +1290,11 @@ sub _rss ( $query, $subtitle, $posts ) {
     require XML::RSS;
     require XML::RSS;
     my $rss = XML::RSS->new( version => '2.0', stylesheet => '/styles/rss-style.xsl' );
     my $rss = XML::RSS->new( version => '2.0', stylesheet => '/styles/rss-style.xsl' );
     my $now = DateTime->from_epoch( epoch => time() );
     my $now = DateTime->from_epoch( epoch => time() );
+    my $port = $query->{port} ? ":$query->{port}" : '';
     $rss->channel(
     $rss->channel(
         title         => "$query->{domain}",
         title         => "$query->{domain}",
         subtitle      => $subtitle,
         subtitle      => $subtitle,
-        link          => "http://$query->{domain}/$query->{route}?format=xml",
+        link          => "http://$query->{domain}$port/$query->{route}?format=xml",
         language      => 'en',                                                   #TODO localization
         language      => 'en',                                                   #TODO localization
         description   => "$query->{domain} : $query->{route}",
         description   => "$query->{domain} : $query->{route}",
         pubDate       => $now,
         pubDate       => $now,
@@ -1303,18 +1304,18 @@ sub _rss ( $query, $subtitle, $posts ) {
     $rss->image(
     $rss->image(
         title       => $query->{domain},
         title       => $query->{domain},
         url         => "/favicon.ico",
         url         => "/favicon.ico",
-        link        => "http://$query->{domain}",
+        link        => "http://$query->{domain}$port",
         width       => 32,
         width       => 32,
         height      => 32,
         height      => 32,
         description => "$query->{domain} favicon",
         description => "$query->{domain} favicon",
     );
     );
 
 
     foreach my $post (@$posts) {
     foreach my $post (@$posts) {
-        my $url = "http://$query->{domain}$post->{local_href}";
+        my $url = "http://$query->{domain}$port$post->{local_href}";
         _post2rss( $rss, $url, $post );
         _post2rss( $rss, $url, $post );
         next unless ref $post->{aliases} eq 'ARRAY';
         next unless ref $post->{aliases} eq 'ARRAY';
         foreach my $alias ( @{ $post->{aliases} } ) {
         foreach my $alias ( @{ $post->{aliases} } ) {
-            $url = "http://$query->{domain}$alias";
+            $url = "http://$query->{domain}$port$alias";
             _post2rss( $rss, $url, $post );
             _post2rss( $rss, $url, $post );
         }
         }
     }
     }

+ 1 - 0
www/templates/html/components/header.tx

@@ -6,6 +6,7 @@
         <title><: $title | mark_raw :></title>
         <title><: $title | mark_raw :></title>
         <meta charset="utf-8" />
         <meta charset="utf-8" />
 
 
+        <link rel="alternate" title="rss" type="application/rss+xml" href="<: $route :?format=rss" />
         <link rel="icon" type="image/svg+xml" href="<: $theme_dir :>/img/icon/favicon.svg" />
         <link rel="icon" type="image/svg+xml" href="<: $theme_dir :>/img/icon/favicon.svg" />
         <link rel="apple-touch-icon" type="image/png" sizes="167x167" href="<: $theme_dir :>/img/icon/favicon-167.png" />
         <link rel="apple-touch-icon" type="image/png" sizes="167x167" href="<: $theme_dir :>/img/icon/favicon-167.png" />
         <link rel="apple-touch-icon" type="image/png" sizes="180x180" href="<: $theme_dir :>/img/icon/favicon-180.png" />
         <link rel="apple-touch-icon" type="image/png" sizes="180x180" href="<: $theme_dir :>/img/icon/favicon-180.png" />