{"thread":{"id":"45740","subject":"[PATCH 0/2] gitweb: tags feeds","startedAt":"2017-04-19T06:49:31Z","lastAt":"2017-05-07T21:59:00Z","messageCount":4,"participants":["Giuseppe Bilotta"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"317193","messageId":"20170419064916.18663-1-giuseppe.bilotta@gmail.com","threadId":"45740","inReplyTo":null,"subject":"[PATCH 0/2] gitweb: tags feeds","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2017-04-19T06:49:14Z","receivedAt":"2017-04-19T06:49:31Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"A smallish patchset to implement RSS and Atom feeds to complement the\ntags view, accessible as verbs `tags_rss` and `tags_atom`.\n\n(I actually made this some 5 years ago, and it has been running on\nhttp://git.oblomov.eu/ since, but for some reason I forgot to submit\nit for upstreaming.)\n\nThe patchset is also available in the git repository at:\n\n  git://git.oblomov.eu/git gitweb-tags-feed\n\n------------------------------------------------------------------------\n\nGiuseppe Bilotta (2):\n  gitweb: infrastructure for tags feed\n  gitweb: expose tags feed in appropriate places\n\n gitweb/gitweb.perl | 126 ++++++++++++++++++++++++++++++++++++++---------------\n 1 file changed, 91 insertions(+), 35 deletions(-)\n\n-- \n2.12.2.822.g5451c77231\n\n"},{"id":"317194","messageId":"20170419064916.18663-2-giuseppe.bilotta@gmail.com","threadId":"45740","inReplyTo":"20170419064916.18663-1-giuseppe.bilotta@gmail.com","subject":"[PATCH 1/2] gitweb: infrastructure for tags feed","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2017-04-19T06:49:15Z","receivedAt":"2017-04-19T06:49:52Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n gitweb/gitweb.perl | 79 +++++++++++++++++++++++++++++++++++++++---------------\n 1 file changed, 58 insertions(+), 21 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 7cf68f07b7..4adea84006 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3807,6 +3807,7 @@ sub git_get_tags_list {\n \n \t\tif ($type eq \"tag\" || $type eq \"commit\") {\n \t\t\t$ref_item{'epoch'} = $epoch;\n+\t\t\t$ref_item{'tz'} = $tz;\n \t\t\tif ($epoch) {\n \t\t\t\t$ref_item{'age'} = age_string(time - $ref_item{'epoch'});\n \t\t\t} else {\n@@ -8132,6 +8133,10 @@ sub git_shortlog {\n \n sub git_feed {\n \tmy $format = shift || 'atom';\n+\n+\t# feed context: log, tags\n+\tmy $ctx = shift || 'log';\n+\n \tmy $have_blame = gitweb_check_feature('blame');\n \n \t# Atom: http://www.atomenabled.org/developers/syndication/\n@@ -8140,9 +8145,19 @@ sub git_feed {\n \t\tdie_error(400, \"Unknown web feed format\");\n \t}\n \n+\tif ($ctx ne 'log' && $ctx ne 'tags') {\n+\t\tdie_error(400, \"Unknown web feed context\");\n+\t}\n+\tmy $tags = $ctx eq 'tags' ? 1 : 0;\n+\n \t# log/feed of current (HEAD) branch, log of given branch, history of file/directory\n \tmy $head = $hash || 'HEAD';\n-\tmy @commitlist = parse_commits($head, 150, 0, $file_name);\n+\tmy @commitlist;\n+\tif ($tags) {\n+\t\t@commitlist = git_get_tags_list(15);\n+\t} else {\n+\t\t@commitlist = parse_commits($head, 150, 0, $file_name);\n+\t}\n \n \tmy %latest_commit;\n \tmy %latest_date;\n@@ -8154,9 +8169,12 @@ sub git_feed {\n \t}\n \tif (defined($commitlist[0])) {\n \t\t%latest_commit = %{$commitlist[0]};\n-\t\tmy $latest_epoch = $latest_commit{'committer_epoch'};\n+\t\tmy $latest_epoch = $tags ? $latest_commit{'epoch'} :\n+\t\t\t\t\t   $latest_commit{'committer_epoch'};\n \t\texit_if_unmodified_since($latest_epoch);\n-\t\t%latest_date = parse_date($latest_epoch, $latest_commit{'committer_tz'});\n+\t\t%latest_date = parse_date($latest_epoch,\n+\t\t\t$tags ? $latest_commit{'tz'} :\n+\t\t\t\t$latest_commit{'committer_tz'});\n \t}\n \tprint $cgi->header(\n \t\t-type => $content_type,\n@@ -8171,7 +8189,9 @@ sub git_feed {\n \t# header variables\n \tmy $title = \"$site_name - $project/$action\";\n \tmy $feed_type = 'log';\n-\tif (defined $hash) {\n+\tif ($tags) {\n+\t\t$feed_type = 'tags';\n+\t} elsif (defined $hash) {\n \t\t$title .= \" - '$hash'\";\n \t\t$feed_type = 'branch log';\n \t\tif (defined $file_name) {\n@@ -8189,6 +8209,7 @@ sub git_feed {\n \t\t$descr = esc_html($descr);\n \t} else {\n \t\t$descr = \"$project \" .\n+\t\t\t ($tags ? 'tags ' : '') .\n \t\t         ($format eq 'rss' ? 'RSS' : 'Atom') .\n \t\t         \" feed\";\n \t}\n@@ -8197,7 +8218,9 @@ sub git_feed {\n \n \t#header\n \tmy $alt_url;\n-\tif (defined $file_name) {\n+\tif ($tags) {\n+\t\t$alt_url = href(-full=>1, action=>\"tags\");\n+\t} elsif (defined $file_name) {\n \t\t$alt_url = href(-full=>1, action=>\"history\", hash=>$hash, file_name=>$file_name);\n \t} elsif (defined $hash) {\n \t\t$alt_url = href(-full=>1, action=>\"log\", hash=>$hash);\n@@ -8261,9 +8284,15 @@ XML\n \t}\n \n \t# contents\n+\tmy $co_action = $tags ? 'tag' : 'commitdiff';\n \tfor (my $i = 0; $i <= $#commitlist; $i++) {\n+\t\tmy %clco; # commit info from commitlist, only used for tags\n \t\tmy %co = %{$commitlist[$i]};\n \t\tmy $commit = $co{'id'};\n+\t\tif ($tags) {\n+\t\t\t%clco = %co;\n+\t\t\t%co = parse_tag($commit);\n+\t\t}\n \t\t# we read 150, we always show 30 and the ones more recent than 48 hours\n \t\tif (($i >= 20) && ((time - $co{'author_epoch'}) > 48*60*60)) {\n \t\t\tlast;\n@@ -8271,44 +8300,52 @@ XML\n \t\tmy %cd = parse_date($co{'author_epoch'}, $co{'author_tz'});\n \n \t\t# get list of changed files\n-\t\topen my $fd, \"-|\", git_cmd(), \"diff-tree\", '-r', @diff_opts,\n-\t\t\t$co{'parent'} || \"--root\",\n-\t\t\t$co{'id'}, \"--\", (defined $file_name ? $file_name : ())\n-\t\t\tor next;\n-\t\tmy @difftree = map { chomp; $_ } <$fd>;\n-\t\tclose $fd\n-\t\t\tor next;\n+\t\tmy @difftree;\n+\t\tunless ($tags) {\n+\t\t\topen my $fd, \"-|\", git_cmd(), \"diff-tree\", '-r', @diff_opts,\n+\t\t\t\t$co{'parent'} || \"--root\",\n+\t\t\t\t$co{'id'}, \"--\", (defined $file_name ? $file_name : ())\n+\t\t\t\tor next;\n+\t\t\t@difftree = map { chomp; $_ } <$fd>;\n+\t\t\tclose $fd\n+\t\t\t\tor next;\n+\t\t}\n+\n+\t\tmy $co_hash = $tags ? $clco{'name'} : $commit;\n+\t\tmy $co_url = href(-full=>1, action=>$co_action, hash=>$co_hash);\n+\t\tmy $co_title = esc_html($tags ? $clco{'subject'} : $co{'title'});\n \n \t\t# print element (entry, item)\n-\t\tmy $co_url = href(-full=>1, action=>\"commitdiff\", hash=>$commit);\n \t\tif ($format eq 'rss') {\n \t\t\tprint \"<item>\\n\" .\n-\t\t\t      \"<title>\" . esc_html($co{'title'}) . \"</title>\\n\" .\n+\t\t\t      \"<title>\" . $co_title . \"</title>\\n\" .\n \t\t\t      \"<author>\" . esc_html($co{'author'}) . \"</author>\\n\" .\n \t\t\t      \"<pubDate>$cd{'rfc2822'}</pubDate>\\n\" .\n \t\t\t      \"<guid isPermaLink=\\\"true\\\">$co_url</guid>\\n\" .\n \t\t\t      \"<link>$co_url</link>\\n\" .\n-\t\t\t      \"<description>\" . esc_html($co{'title'}) . \"</description>\\n\" .\n+\t\t\t      \"<description>\" . $co_title . \"</description>\\n\" .\n \t\t\t      \"<content:encoded>\" .\n \t\t\t      \"<![CDATA[\\n\";\n \t\t} elsif ($format eq 'atom') {\n \t\t\tprint \"<entry>\\n\" .\n-\t\t\t      \"<title type=\\\"html\\\">\" . esc_html($co{'title'}) . \"</title>\\n\" .\n+\t\t\t      \"<title type=\\\"html\\\">\" . $co_title . \"</title>\\n\" .\n \t\t\t      \"<updated>$cd{'iso-8601'}</updated>\\n\" .\n \t\t\t      \"<author>\\n\" .\n \t\t\t      \"  <name>\" . esc_html($co{'author_name'}) . \"</name>\\n\";\n \t\t\tif ($co{'author_email'}) {\n \t\t\t\tprint \"  <email>\" . esc_html($co{'author_email'}) . \"</email>\\n\";\n \t\t\t}\n-\t\t\tprint \"</author>\\n\" .\n+\t\t\tprint \"</author>\\n\";\n+\t\t\tunless ($tags) {\n \t\t\t      # use committer for contributor\n-\t\t\t      \"<contributor>\\n\" .\n+\t\t\t      print \"<contributor>\\n\" .\n \t\t\t      \"  <name>\" . esc_html($co{'committer_name'}) . \"</name>\\n\";\n-\t\t\tif ($co{'committer_email'}) {\n+\t\t\t}\n+\t\t\tif (!$tags && $co{'committer_email'}) {\n \t\t\t\tprint \"  <email>\" . esc_html($co{'committer_email'}) . \"</email>\\n\";\n \t\t\t}\n-\t\t\tprint \"</contributor>\\n\" .\n-\t\t\t      \"<published>$cd{'iso-8601'}</published>\\n\" .\n+\t\t\tprint \"</contributor>\\n\" unless $tags;\n+\t\t\tprint \"<published>$cd{'iso-8601'}</published>\\n\" .\n \t\t\t      \"<link rel=\\\"alternate\\\" type=\\\"text/html\\\" href=\\\"$co_url\\\" />\\n\" .\n \t\t\t      \"<id>$co_url</id>\\n\" .\n \t\t\t      \"<content type=\\\"xhtml\\\" xml:base=\\\"\" . esc_url($my_url) . \"\\\">\\n\" .\n-- \n2.12.2.822.g5451c77231\n\n"},{"id":"317195","messageId":"20170419064916.18663-3-giuseppe.bilotta@gmail.com","threadId":"45740","inReplyTo":"20170419064916.18663-1-giuseppe.bilotta@gmail.com","subject":"[PATCH 2/2] gitweb: expose tags feed in appropriate places","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2017-04-19T06:49:16Z","receivedAt":"2017-04-19T06:49:57Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n gitweb/gitweb.perl | 47 +++++++++++++++++++++++++++++++++--------------\n 1 file changed, 33 insertions(+), 14 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 4adea84006..8be7444988 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -851,6 +851,8 @@ our %actions = (\n \t\"summary\" => \\&git_summary,\n \t\"tag\" => \\&git_tag,\n \t\"tags\" => \\&git_tags,\n+\t\"tags_rss\" => \\&git_tags_rss,\n+\t\"tags_atom\" => \\&git_tags_atom,\n \t\"tree\" => \\&git_tree,\n \t\"snapshot\" => \\&git_snapshot,\n \t\"object\" => \\&git_object,\n@@ -2599,7 +2601,7 @@ sub get_feed_info {\n \treturn unless (defined $project);\n \t# some views should link to OPML, or to generic project feed,\n \t# or don't have specific feed yet (so they should use generic)\n-\treturn if (!$action || $action =~ /^(?:tags|heads|forks|tag|search)$/x);\n+\treturn if (!$action || $action =~ /^(?:heads|forks|search)$/x);\n \n \tmy $branch = undef;\n \t# branches refs uses 'refs/' + $get_branch_refs()[x] + '/' prefix\n@@ -2614,8 +2616,10 @@ sub get_feed_info {\n \t\t}\n \t}\n \t# find log type for feed description (title)\n-\tmy $type = 'log';\n-\tif (defined $file_name) {\n+\tmy $type = \"log\";\n+\tif ($action eq 'tag' || $action eq 'tags') {\n+\t\t$type = \"tags\";\n+\t} elsif (defined $file_name) {\n \t\t$type  = \"history of $file_name\";\n \t\t$type .= \"/\" if ($action eq 'tree');\n \t\t$type .= \" on '$branch'\" if (defined $branch);\n@@ -4007,6 +4011,7 @@ sub print_feed_meta {\n \t\t\t$href_params{'-title'} = 'log';\n \t\t}\n \n+\t\tmy $tag_view = $href_params{-title} eq 'tags';\n \t\tforeach my $format (qw(RSS Atom)) {\n \t\t\tmy $type = lc($format);\n \t\t\tmy %link_attr = (\n@@ -4016,7 +4021,7 @@ sub print_feed_meta {\n \t\t\t);\n \n \t\t\t$href_params{'extra_options'} = undef;\n-\t\t\t$href_params{'action'} = $type;\n+\t\t\t$href_params{'action'} = ($tag_view ? 'tags_' : '') . $type;\n \t\t\t$link_attr{'-href'} = href(%href_params);\n \t\t\tprint \"<link \".\n \t\t\t      \"rel=\\\"$link_attr{'-rel'}\\\" \".\n@@ -4025,15 +4030,17 @@ sub print_feed_meta {\n \t\t\t      \"type=\\\"$link_attr{'-type'}\\\" \".\n \t\t\t      \"/>\\n\";\n \n-\t\t\t$href_params{'extra_options'} = '--no-merges';\n-\t\t\t$link_attr{'-href'} = href(%href_params);\n-\t\t\t$link_attr{'-title'} .= ' (no merges)';\n-\t\t\tprint \"<link \".\n-\t\t\t      \"rel=\\\"$link_attr{'-rel'}\\\" \".\n-\t\t\t      \"title=\\\"$link_attr{'-title'}\\\" \".\n-\t\t\t      \"href=\\\"$link_attr{'-href'}\\\" \".\n-\t\t\t      \"type=\\\"$link_attr{'-type'}\\\" \".\n-\t\t\t      \"/>\\n\";\n+\t\t\tunless ($tag_view) {\n+\t\t\t\t$href_params{'extra_options'} = '--no-merges';\n+\t\t\t\t$link_attr{'-href'} = href(%href_params);\n+\t\t\t\t$link_attr{'-title'} .= ' (no merges)';\n+\t\t\t\tprint \"<link \".\n+\t\t\t\t      \"rel=\\\"$link_attr{'-rel'}\\\" \".\n+\t\t\t\t      \"title=\\\"$link_attr{'-title'}\\\" \".\n+\t\t\t\t      \"href=\\\"$link_attr{'-href'}\\\" \".\n+\t\t\t\t      \"type=\\\"$link_attr{'-type'}\\\" \".\n+\t\t\t\t      \"/>\\n\";\n+\t\t\t}\n \t\t}\n \n \t} else {\n@@ -4217,8 +4224,9 @@ sub git_footer_html {\n \t\t}\n \t\t$href_params{'-title'} ||= 'log';\n \n+\t\tmy $tag_view = $href_params{-title} eq 'tags';\n \t\tforeach my $format (qw(RSS Atom)) {\n-\t\t\t$href_params{'action'} = lc($format);\n+\t\t\t$href_params{'action'} = ($tag_view ? 'tags_' : '') . lc($format);\n \t\t\tprint $cgi->a({-href => href(%href_params),\n \t\t\t              -title => \"$href_params{'-title'} $format feed\",\n \t\t\t              -class => $feed_class}, $format).\"\\n\";\n@@ -8409,10 +8417,18 @@ sub git_rss {\n \tgit_feed('rss');\n }\n \n+sub git_tags_rss {\n+\tgit_feed('rss', 'tags')\n+}\n+\n sub git_atom {\n \tgit_feed('atom');\n }\n \n+sub git_tags_atom {\n+\tgit_feed('atom', 'tags')\n+}\n+\n sub git_opml {\n \tmy @list = git_get_projects_list($project_filter, $strict_export);\n \tif (!@list) {\n@@ -8457,6 +8473,9 @@ XML\n \t\tmy $rss  = href('project' => $proj{'path'}, 'action' => 'rss', -full => 1);\n \t\tmy $html = href('project' => $proj{'path'}, 'action' => 'summary', -full => 1);\n \t\tprint \"<outline type=\\\"rss\\\" text=\\\"$path\\\" title=\\\"$path\\\" xmlUrl=\\\"$rss\\\" htmlUrl=\\\"$html\\\"/>\\n\";\n+\t\t# and now the tags rss feed\n+\t\t$rss  = href('project' => $proj{'path'}, 'action' => 'tags_rss', -full => 1);\n+\t\tprint \"<outline type=\\\"rss\\\" text=\\\"$path tags\\\" title=\\\"$path tags\\\" xmlUrl=\\\"$rss\\\" htmlUrl=\\\"$html\\\"/>\\n\";\n \t}\n \tprint <<XML;\n </outline>\n-- \n2.12.2.822.g5451c77231\n\n"},{"id":"319013","messageId":"CAOxFTczgB05mS0A50ESdgk_4AMCpx1Odrdz4PKr3bkuwRFNHPw@mail.gmail.com","threadId":"45740","inReplyTo":"20170419064916.18663-1-giuseppe.bilotta@gmail.com","subject":"Re: [PATCH 0/2] gitweb: tags feeds","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2017-05-07T20:55:41Z","receivedAt":"2017-05-07T21:59:00Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Ping?\n\nOn Wed, Apr 19, 2017 at 8:49 AM, Giuseppe Bilotta\n<giuseppe.bilotta@gmail.com> wrote:\n> A smallish patchset to implement RSS and Atom feeds to complement the\n> tags view, accessible as verbs `tags_rss` and `tags_atom`.\n>\n> (I actually made this some 5 years ago, and it has been running on\n> http://git.oblomov.eu/ since, but for some reason I forgot to submit\n> it for upstreaming.)\n>\n> The patchset is also available in the git repository at:\n>\n>   git://git.oblomov.eu/git gitweb-tags-feed\n>\n> ------------------------------------------------------------------------\n>\n> Giuseppe Bilotta (2):\n>   gitweb: infrastructure for tags feed\n>   gitweb: expose tags feed in appropriate places\n>\n>  gitweb/gitweb.perl | 126 ++++++++++++++++++++++++++++++++++++++---------------\n>  1 file changed, 91 insertions(+), 35 deletions(-)\n>\n> --\n> 2.12.2.822.g5451c77231\n>\n\n\n\n-- \nGiuseppe \"Oblomov\" Bilotta\n"}]}