Nuke RSS (Atom only!), and use Atom in the OPML
authorChris Morgan <me@chrismorgan.info>
committerChris Morgan <me@chrismorgan.info>
gitweb.cgi

index f8d82f71d879edf6fabc48b7fbb7e848f80d275a..16e2e3c70c6df29963e55d4df61598b3f8a832c4 100755 (executable)
@@ -887,7 +887,6 @@ our %actions = (
        "patch" => \&git_patch,
        "patches" => \&git_patches,
        "remotes" => \&git_remotes,
-       "rss" => \&git_rss,
        "atom" => \&git_atom,
        "search" => \&git_search,
        "search_help" => \&git_search_help,
@@ -907,7 +906,7 @@ our %actions = (
 # finally, we have the hash of allowed extra_options for the commands that
 # allow them
 our %allowed_options = (
-       "--no-merges" => [ qw(rss atom log shortlog history) ],
+       "--no-merges" => [ qw(atom log shortlog history) ],
 );
 
 # fill %input_params with the CGI parameters. All values except for 'opt'
@@ -4070,7 +4069,7 @@ sub print_feed_meta {
                        $href_params{'-title'} = 'log';
                }
 
-               foreach my $format (qw(RSS Atom)) {
+               foreach my $format (qw(Atom)) {
                        my $type = lc($format);
                        my %link_attr = (
                                '-rel' => 'alternate',
@@ -4282,7 +4281,7 @@ sub git_footer_html {
                }
                $href_params{'-title'} ||= 'log';
 
-               foreach my $format (qw(RSS Atom)) {
+               foreach my $format (qw(Atom)) {
                        $href_params{'action'} = lc($format);
                        print $cgi->a({-href => href(%href_params),
                                      -title => "$href_params{'-title'} $format feed",
@@ -8202,15 +8201,14 @@ sub git_shortlog {
 }
 
 ## ......................................................................
-## feeds (RSS, Atom; OPML)
+## feeds (Atom; OPML)
 
 sub git_feed {
        my $format = shift || 'atom';
        my $have_blame = gitweb_check_feature('blame');
 
        # Atom: http://www.atomenabled.org/developers/syndication/
-       # RSS:  http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
-       if ($format ne 'rss' && $format ne 'atom') {
+       if ($format ne 'atom') {
                die_error(400, "Unknown web feed format");
        }
 
@@ -8262,9 +8260,7 @@ sub git_feed {
        if (defined $descr) {
                $descr = esc_html($descr);
        } else {
-               $descr = "$project " .
-                        ($format eq 'rss' ? 'RSS' : 'Atom') .
-                        " feed";
+               $descr = "$project Atom feed";
        }
        my $owner = git_get_project_owner($project);
        $owner = esc_html($owner);
@@ -8280,60 +8276,32 @@ sub git_feed {
        }
        $alt_url = esc_attr($alt_url);
        print qq!<?xml version="1.0" encoding="utf-8"?>\n!;
-       if ($format eq 'rss') {
-               print <<XML;
-<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
-<channel>
-XML
-               print "<title>$title</title>\n" .
-                     "<link>$alt_url</link>\n" .
-                     "<description>$descr</description>\n" .
-                     "<language>en</language>\n" .
-                     # project owner is responsible for 'editorial' content
-                     "<managingEditor>$owner</managingEditor>\n";
-               if (defined $logo || defined $favicon) {
-                       # prefer the logo to the favicon, since RSS
-                       # doesn't allow both
-                       my $img = esc_url($logo || $favicon);
-                       print "<image>\n" .
-                             "<url>$img</url>\n" .
-                             "<title>$title</title>\n" .
-                             "<link>$alt_url</link>\n" .
-                             "</image>\n";
-               }
-               if (%latest_date) {
-                       print "<pubDate>$latest_date{'rfc2822'}</pubDate>\n";
-                       print "<lastBuildDate>$latest_date{'rfc2822'}</lastBuildDate>\n";
-               }
-               print "<generator>gitweb v.$version/$git_version</generator>\n";
-       } elsif ($format eq 'atom') {
-               print <<XML;
+       print <<XML;
 <feed xmlns="http://www.w3.org/2005/Atom">
 XML
-               print "<title>$title</title>\n" .
-                     "<subtitle>$descr</subtitle>\n" .
-                     '<link rel="alternate" type="text/html" href="' .
-                     $alt_url . '" />' . "\n" .
-                     '<link rel="self" type="' . $content_type . '" href="' .
-                     $cgi->self_url() . '" />' . "\n" .
-                     "<id>" . esc_url(href(-full=>1)) . "</id>\n" .
-                     # use project owner for feed author
-                     "<author><name>$owner</name></author>\n";
-               if (defined $favicon) {
-                       print "<icon>" . esc_url($favicon) . "</icon>\n";
-               }
-               if (defined $logo) {
-                       # not twice as wide as tall: 72 x 27 pixels
-                       print "<logo>" . esc_url($logo) . "</logo>\n";
-               }
-               if (! %latest_date) {
-                       # dummy date to keep the feed valid until commits trickle in:
-                       print "<updated>1970-01-01T00:00:00Z</updated>\n";
-               } else {
-                       print "<updated>$latest_date{'iso-8601'}</updated>\n";
-               }
-               print "<generator version='$version/$git_version'>gitweb</generator>\n";
+       print "<title>$title</title>\n" .
+             "<subtitle>$descr</subtitle>\n" .
+             '<link rel="alternate" type="text/html" href="' .
+             $alt_url . '" />' . "\n" .
+             '<link rel="self" type="' . $content_type . '" href="' .
+             $cgi->self_url() . '" />' . "\n" .
+             "<id>" . esc_url(href(-full=>1)) . "</id>\n" .
+             # use project owner for feed author
+             "<author><name>$owner</name></author>\n";
+       if (defined $favicon) {
+               print "<icon>" . esc_url($favicon) . "</icon>\n";
+       }
+       if (defined $logo) {
+               # not twice as wide as tall: 72 x 27 pixels
+               print "<logo>" . esc_url($logo) . "</logo>\n";
+       }
+       if (! %latest_date) {
+               # dummy date to keep the feed valid until commits trickle in:
+               print "<updated>1970-01-01T00:00:00Z</updated>\n";
+       } else {
+               print "<updated>$latest_date{'iso-8601'}</updated>\n";
        }
+       print "<generator version='$version/$git_version'>gitweb</generator>\n";
 
        # contents
        for (my $i = 0; $i <= $#commitlist; $i++) {
@@ -8356,39 +8324,27 @@ XML
 
                # print element (entry, item)
                my $co_url = href(-full=>1, action=>"commitdiff", hash=>$commit);
-               if ($format eq 'rss') {
-                       print "<item>\n" .
-                             "<title>" . esc_html($co{'title'}) . "</title>\n" .
-                             "<author>" . esc_html($co{'author'}) . "</author>\n" .
-                             "<pubDate>$cd{'rfc2822'}</pubDate>\n" .
-                             "<guid isPermaLink=\"true\">$co_url</guid>\n" .
-                             "<link>" . esc_html($co_url) . "</link>\n" .
-                             "<description>" . esc_html($co{'title'}) . "</description>\n" .
-                             "<content:encoded>" .
-                             "<![CDATA[\n";
-               } elsif ($format eq 'atom') {
-                       print "<entry>\n" .
-                             "<title type=\"html\">" . esc_html($co{'title'}) . "</title>\n" .
-                             "<updated>$cd{'iso-8601'}</updated>\n" .
-                             "<author>\n" .
-                             "  <name>" . esc_html($co{'author_name'}) . "</name>\n";
-                       if ($co{'author_email'}) {
-                               print "  <email>" . esc_html($co{'author_email'}) . "</email>\n";
-                       }
-                       print "</author>\n" .
-                             # use committer for contributor
-                             "<contributor>\n" .
-                             "  <name>" . esc_html($co{'committer_name'}) . "</name>\n";
-                       if ($co{'committer_email'}) {
-                               print "  <email>" . esc_html($co{'committer_email'}) . "</email>\n";
-                       }
-                       print "</contributor>\n" .
-                             "<published>$cd{'iso-8601'}</published>\n" .
-                             "<link rel=\"alternate\" type=\"text/html\" href=\"" . esc_attr($co_url) . "\" />\n" .
-                             "<id>" . esc_html($co_url) . "</id>\n" .
-                             "<content type=\"xhtml\" xml:base=\"" . esc_url($my_url) . "\">\n" .
-                             "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n";
-               }
+               print "<entry>\n" .
+                     "<title type=\"html\">" . esc_html($co{'title'}) . "</title>\n" .
+                     "<updated>$cd{'iso-8601'}</updated>\n" .
+                     "<author>\n" .
+                     "  <name>" . esc_html($co{'author_name'}) . "</name>\n";
+               if ($co{'author_email'}) {
+                       print "  <email>" . esc_html($co{'author_email'}) . "</email>\n";
+               }
+               print "</author>\n" .
+                     # use committer for contributor
+                     "<contributor>\n" .
+                     "  <name>" . esc_html($co{'committer_name'}) . "</name>\n";
+               if ($co{'committer_email'}) {
+                       print "  <email>" . esc_html($co{'committer_email'}) . "</email>\n";
+               }
+               print "</contributor>\n" .
+                     "<published>$cd{'iso-8601'}</published>\n" .
+                     "<link rel=\"alternate\" type=\"text/html\" href=\"" . esc_attr($co_url) . "\" />\n" .
+                     "<id>" . esc_html($co_url) . "</id>\n" .
+                     "<content type=\"xhtml\" xml:base=\"" . esc_url($my_url) . "\">\n" .
+                     "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n";
                my $comment = $co{'comment'};
                print "<pre>\n";
                foreach my $line (@$comment) {
@@ -8424,27 +8380,13 @@ XML
                        print "] ".
                              "$file</li>\n";
                }
-               if ($format eq 'rss') {
-                       print "</ul>]]>\n" .
-                             "</content:encoded>\n" .
-                             "</item>\n";
-               } elsif ($format eq 'atom') {
-                       print "</ul>\n</div>\n" .
-                             "</content>\n" .
-                             "</entry>\n";
-               }
+               print "</ul>\n</div>\n" .
+                     "</content>\n" .
+                     "</entry>\n";
        }
 
        # end of feed
-       if ($format eq 'rss') {
-               print "</channel>\n</rss>\n";
-       } elsif ($format eq 'atom') {
-               print "</feed>\n";
-       }
-}
-
-sub git_rss {
-       git_feed('rss');
+       print "</feed>\n";
 }
 
 sub git_atom {
@@ -8476,7 +8418,7 @@ sub git_opml {
   <title>$title OPML Export$filter</title>
 </head>
 <body>
-<outline text="git RSS feeds">
+<outline text="git Atom feeds">
 XML
 
        foreach my $pr (@list) {
@@ -8492,9 +8434,9 @@ XML
                }
 
                my $path = esc_html(chop_str($proj{'path'}, 25, 5));
-               my $rss  = esc_attr(href('project' => $proj{'path'}, 'action' => 'rss', -full => 1));
+               my $atom  = esc_attr(href('project' => $proj{'path'}, 'action' => 'atom', -full => 1));
                my $html = esc_attr(href('project' => $proj{'path'}, 'action' => 'summary', -full => 1));
-               print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";
+               print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$atom\" htmlUrl=\"$html\"/>\n";
        }
        print <<XML;
 </outline>