]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Feed.pm
consistently whitespace wrap on <pre> sections
[public-inbox.git] / lib / PublicInbox / Feed.pm
index 12ac8a95be278bb046962e1233b4442707a59df9..0104a6baf70ef97499e37bc3386d1cd292adf29d 100644 (file)
@@ -9,8 +9,9 @@ use Date::Parse qw(strptime str2time);
 use PublicInbox::Hval;
 use PublicInbox::GitCatFile;
 use constant {
-       DATEFMT => '%Y-%m-%dT%H:%M:%SZ',
-       MAX_PER_PAGE => 25,
+       DATEFMT => '%Y-%m-%dT%H:%M:%SZ', # atom standard
+       MAX_PER_PAGE => 25, # this needs to be tunable
+       PRE_WRAP => '<pre style="white-space:pre-wrap">',
 };
 
 # main function
@@ -75,7 +76,7 @@ sub generate_html_index {
        my $html = "<html><head><title>$title</title>" .
                '<link rel="alternate" title="Atom feed" href="' .
                $feed_opts->{atomurl} . '" type="application/atom+xml"/>' .
-               '</head><body><pre>';
+               '</head><body>' . PRE_WRAP;
 
        # sort by date, most recent at top
        $th->order(sub {
@@ -88,15 +89,17 @@ sub generate_html_index {
 
        Email::Address->purge_cache;
 
-       my $footer = nav_footer($args->{cgi}, $last);
-       $footer = "<hr /><pre>$footer</pre>" if $footer;
+       my $footer = nav_footer($args->{cgi}, $last, $feed_opts);
+       my $list_footer = $args->{footer};
+       $footer .= "\n" . $list_footer if ($footer && $list_footer);
+       $footer = "<hr />" . PRE_WRAP . "$footer</pre>" if $footer;
        $html . "</pre>$footer</html>";
 }
 
 # private subs
 
 sub nav_footer {
-       my ($cgi, $last) = @_;
+       my ($cgi, $last, $feed_opts) = @_;
        $cgi or return '';
        my $old_r = $cgi->param('r');
        my $head = '    ';
@@ -109,7 +112,8 @@ sub nav_footer {
                $head = $cgi->path_info;
                $head = qq!<a href="$head">head</a>!;
        }
-       "$next $head";
+       my $atom = "<a href=\"$feed_opts->{atomurl}\">atom</a>";
+       "$next $head $atom";
 }
 
 sub each_recent_blob {