diff options
author | Eric Wong <e@80x24.org> | 2016-01-19 01:16:19 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-04-05 18:58:27 +0000 |
commit | e90aa39b6447ceef78d31d4c68291585eb02244a (patch) | |
tree | b1307ffb83ae07a12ee90cb14228c8f00b56a088 /lib/PublicInbox/RepobrowseGitCommit.pm | |
parent | 2b79ca6a1f3f12cac616b2bce800f7f9487c8170 (diff) | |
download | public-inbox-e90aa39b6447ceef78d31d4c68291585eb02244a.tar.gz |
It is expensive and of dubious usefulness to have tree content auto-followed and indexed by search engines. Reduce the links we recommend to crawlers so they don't waste resources of users running our code or waste the time of search engine users finding low-value content. We will allow indexing blobs, however, as they may contain useful information for others to refer to. Of course, I definitely want search engines to index commit messages; as I consider those to be the most important data served.
Diffstat (limited to 'lib/PublicInbox/RepobrowseGitCommit.pm')
-rw-r--r-- | lib/PublicInbox/RepobrowseGitCommit.pm | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/PublicInbox/RepobrowseGitCommit.pm b/lib/PublicInbox/RepobrowseGitCommit.pm index e4e0f3c6..d6843a6d 100644 --- a/lib/PublicInbox/RepobrowseGitCommit.pm +++ b/lib/PublicInbox/RepobrowseGitCommit.pm @@ -23,7 +23,7 @@ use constant GIT_FMT => '--pretty=format:'.join('%n', '%t', '%p', '%D', '%b%x00'); sub git_commit_stream { - my ($req, $q, $H, $log, $fh) = @_; + my ($self, $req, $q, $H, $log, $fh) = @_; chomp(my $h = <$log>); # abbreviated commit my $l; chomp(my $s = utf8_html($l = <$log>)); # subject @@ -40,10 +40,9 @@ sub git_commit_stream { my $rel = $req->{relcmd}; my $qs = $q->qs(id => $h); chomp $H; - my $x = "<html><head><title>$s</title>" . - PublicInbox::Hval::STYLE . '</head><body><pre>' . - " commit $H (<a\nhref=\"${rel}patch$qs\">patch</a>)\n" . - " tree <a\nhref=\"${rel}tree?id=$h\">$t</a>"; + my $x = $self->html_start($req, $s) . "\n" . + qq( commit $H (<a\nhref="${rel}patch$qs">patch</a>)\n) . + qq( tree <a\nrel=nofollow\nhref="${rel}tree?id=$h">$t</a>); # extra show path information, if any my $extra = $req->{extra}; @@ -57,7 +56,8 @@ sub git_commit_stream { my $e = PublicInbox::Hval->utf8($_, join('/', @t)); $ep = $e->as_path; my $eh = $e->as_html; - "<a\nhref=\"${rel}tree/$ep?id=$h\">$eh</a>"; + $ep = "${rel}tree/$ep?id=$h"; + qq(<a\nrel=nofollow\nhref="$ep">$eh</a>); } @$extra); $path = "/$ep"; } @@ -158,7 +158,7 @@ sub call_git_commit { sub { my ($res) = @_; # Plack callback my $fh = $res->([200, ['Content-Type'=>'text/html']]); - git_commit_stream($req, $q, $H, $log, $fh); + git_commit_stream($self, $req, $q, $H, $log, $fh); $fh->close; } } @@ -266,7 +266,8 @@ sub git_diff_ab_hunk { $rv .= $ca; } else { my $p = $diff->{p}->[0]; - $rv .= "<a\nhref=\"${rel}tree/$diff->{path_a}?id=$p#n$na\">"; + $rv .= qq(<a\nrel=nofollow); + $rv .= qq(\nhref="${rel}tree/$diff->{path_a}?id=$p#n$na">); $rv .= "$ca</a>"; } $rv .= ' '; @@ -274,7 +275,8 @@ sub git_diff_ab_hunk { $rv .= $cb; } else { my $h = $diff->{h}; - $rv .= "<a\nhref=\"${rel}tree/$diff->{path_b}?id=$h#n$nb\">"; + $rv .= qq(<a\nrel=nofollow); + $rv .= qq(\nhref="${rel}tree/$diff->{path_b}?id=$h#n$nb">); $rv .= "<b>$cb</b></a>"; } $rv . ' @@' . utf8_html($ctx); @@ -340,7 +342,8 @@ sub git_diff_cc_hunk { $rv .= " <b>$last</b>"; } else { my $h = $diff->{h}; - $rv .= " <a\nhref=\"${rel}tree/$path?id=$h#n$n\">"; + $rv .= qq( <a\nrel=nofollow); + $rv .= qq(\nhref="${rel}tree/$path?id=$h#n$n">); $rv .= "<b>$last</b></a>"; } $rv .= " $at" . utf8_html($ctx); @@ -418,7 +421,8 @@ sub show_unchanged { my $p = PublicInbox::Hval->utf8(git_unquote($fn)); $p = $p->as_path; $fn = utf8_html($fn); - $s .= qq(\t<a\nid="$anchor"\nhref="${rel}tree/$p$qs">); + $s .= qq(\t<a\nrel=nofollow); + $s .= qq(\nid="$anchor"\nhref="${rel}tree/$p$qs">); $s .= "$fn</a>\n"; } $fh->write($s); |