git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
To: Git ML <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>,
	Jakub Narebski <jnareb@gmail.com>,
	Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Subject: [PATCH 2/2] gitweb: expose tags feed in appropriate places
Date: Wed, 19 Apr 2017 08:49:16 +0200	[thread overview]
Message-ID: <20170419064916.18663-3-giuseppe.bilotta@gmail.com> (raw)
In-Reply-To: <20170419064916.18663-1-giuseppe.bilotta@gmail.com>

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl | 47 +++++++++++++++++++++++++++++++++--------------
 1 file changed, 33 insertions(+), 14 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4adea84006..8be7444988 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -851,6 +851,8 @@ our %actions = (
 	"summary" => \&git_summary,
 	"tag" => \&git_tag,
 	"tags" => \&git_tags,
+	"tags_rss" => \&git_tags_rss,
+	"tags_atom" => \&git_tags_atom,
 	"tree" => \&git_tree,
 	"snapshot" => \&git_snapshot,
 	"object" => \&git_object,
@@ -2599,7 +2601,7 @@ sub get_feed_info {
 	return unless (defined $project);
 	# some views should link to OPML, or to generic project feed,
 	# or don't have specific feed yet (so they should use generic)
-	return if (!$action || $action =~ /^(?:tags|heads|forks|tag|search)$/x);
+	return if (!$action || $action =~ /^(?:heads|forks|search)$/x);
 
 	my $branch = undef;
 	# branches refs uses 'refs/' + $get_branch_refs()[x] + '/' prefix
@@ -2614,8 +2616,10 @@ sub get_feed_info {
 		}
 	}
 	# find log type for feed description (title)
-	my $type = 'log';
-	if (defined $file_name) {
+	my $type = "log";
+	if ($action eq 'tag' || $action eq 'tags') {
+		$type = "tags";
+	} elsif (defined $file_name) {
 		$type  = "history of $file_name";
 		$type .= "/" if ($action eq 'tree');
 		$type .= " on '$branch'" if (defined $branch);
@@ -4007,6 +4011,7 @@ sub print_feed_meta {
 			$href_params{'-title'} = 'log';
 		}
 
+		my $tag_view = $href_params{-title} eq 'tags';
 		foreach my $format (qw(RSS Atom)) {
 			my $type = lc($format);
 			my %link_attr = (
@@ -4016,7 +4021,7 @@ sub print_feed_meta {
 			);
 
 			$href_params{'extra_options'} = undef;
-			$href_params{'action'} = $type;
+			$href_params{'action'} = ($tag_view ? 'tags_' : '') . $type;
 			$link_attr{'-href'} = href(%href_params);
 			print "<link ".
 			      "rel=\"$link_attr{'-rel'}\" ".
@@ -4025,15 +4030,17 @@ sub print_feed_meta {
 			      "type=\"$link_attr{'-type'}\" ".
 			      "/>\n";
 
-			$href_params{'extra_options'} = '--no-merges';
-			$link_attr{'-href'} = href(%href_params);
-			$link_attr{'-title'} .= ' (no merges)';
-			print "<link ".
-			      "rel=\"$link_attr{'-rel'}\" ".
-			      "title=\"$link_attr{'-title'}\" ".
-			      "href=\"$link_attr{'-href'}\" ".
-			      "type=\"$link_attr{'-type'}\" ".
-			      "/>\n";
+			unless ($tag_view) {
+				$href_params{'extra_options'} = '--no-merges';
+				$link_attr{'-href'} = href(%href_params);
+				$link_attr{'-title'} .= ' (no merges)';
+				print "<link ".
+				      "rel=\"$link_attr{'-rel'}\" ".
+				      "title=\"$link_attr{'-title'}\" ".
+				      "href=\"$link_attr{'-href'}\" ".
+				      "type=\"$link_attr{'-type'}\" ".
+				      "/>\n";
+			}
 		}
 
 	} else {
@@ -4217,8 +4224,9 @@ sub git_footer_html {
 		}
 		$href_params{'-title'} ||= 'log';
 
+		my $tag_view = $href_params{-title} eq 'tags';
 		foreach my $format (qw(RSS Atom)) {
-			$href_params{'action'} = lc($format);
+			$href_params{'action'} = ($tag_view ? 'tags_' : '') . lc($format);
 			print $cgi->a({-href => href(%href_params),
 			              -title => "$href_params{'-title'} $format feed",
 			              -class => $feed_class}, $format)."\n";
@@ -8409,10 +8417,18 @@ sub git_rss {
 	git_feed('rss');
 }
 
+sub git_tags_rss {
+	git_feed('rss', 'tags')
+}
+
 sub git_atom {
 	git_feed('atom');
 }
 
+sub git_tags_atom {
+	git_feed('atom', 'tags')
+}
+
 sub git_opml {
 	my @list = git_get_projects_list($project_filter, $strict_export);
 	if (!@list) {
@@ -8457,6 +8473,9 @@ XML
 		my $rss  = href('project' => $proj{'path'}, 'action' => 'rss', -full => 1);
 		my $html = href('project' => $proj{'path'}, 'action' => 'summary', -full => 1);
 		print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";
+		# and now the tags rss feed
+		$rss  = href('project' => $proj{'path'}, 'action' => 'tags_rss', -full => 1);
+		print "<outline type=\"rss\" text=\"$path tags\" title=\"$path tags\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";
 	}
 	print <<XML;
 </outline>
-- 
2.12.2.822.g5451c77231


  parent reply	other threads:[~2017-04-19  6:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-19  6:49 [PATCH 0/2] gitweb: tags feeds Giuseppe Bilotta
2017-04-19  6:49 ` [PATCH 1/2] gitweb: infrastructure for tags feed Giuseppe Bilotta
2017-04-19  6:49 ` Giuseppe Bilotta [this message]
2017-05-07 20:55 ` [PATCH 0/2] gitweb: tags feeds Giuseppe Bilotta
  -- strict thread matches above, loose matches on Subject: below --
2012-09-25 20:10 [RFC PATCH 0/2] gitweb: tags feed Giuseppe Bilotta
2012-09-25 20:10 ` [PATCH 2/2] gitweb: expose tags feed in appropriate places Giuseppe Bilotta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170419064916.18663-3-giuseppe.bilotta@gmail.com \
    --to=giuseppe.bilotta@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jnareb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).