diff options
author | Eric Wong <e@80x24.org> | 2017-03-02 23:39:49 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-03-02 23:39:49 +0000 |
commit | 16b1fbe36cc39a351ef9810b9018d36df833a941 (patch) | |
tree | 6a354e1ab5177993fb11bd5ae0e43400d66ffbce | |
parent | a4df292ed39f6e02a7d57326f291583339cb562d (diff) | |
download | public-inbox-16b1fbe36cc39a351ef9810b9018d36df833a941.tar.gz |
This is shorter, and makes more sense as the endpoint displays both tree listings and actual blob sources. This will also make rewriting existing URLs from cgit installations easier.
-rw-r--r-- | MANIFEST | 4 | ||||
-rw-r--r-- | lib/PublicInbox/RepoGitCommit.pm | 6 | ||||
-rw-r--r-- | lib/PublicInbox/RepoGitDiffCommon.pm | 8 | ||||
-rw-r--r-- | lib/PublicInbox/RepoGitSrc.pm (renamed from lib/PublicInbox/RepoGitTree.pm) | 10 | ||||
-rw-r--r-- | lib/PublicInbox/RepoGitSummary.pm | 4 | ||||
-rw-r--r-- | lib/PublicInbox/Repobrowse.pm | 4 | ||||
-rw-r--r-- | t/repobrowse_git_src.t (renamed from t/repobrowse_git_tree.t) | 4 |
7 files changed, 20 insertions, 20 deletions
@@ -97,9 +97,9 @@ lib/PublicInbox/RepoGitRaw.pm lib/PublicInbox/RepoGitSearch.pm lib/PublicInbox/RepoGitSearchIdx.pm lib/PublicInbox/RepoGitSnapshot.pm +lib/PublicInbox/RepoGitSrc.pm lib/PublicInbox/RepoGitSummary.pm lib/PublicInbox/RepoGitTag.pm -lib/PublicInbox/RepoGitTree.pm lib/PublicInbox/RepoRoot.pm lib/PublicInbox/Repobrowse.pm lib/PublicInbox/SaPlugin/ListMirror.pm @@ -197,7 +197,7 @@ t/repobrowse_git_httpd.t t/repobrowse_git_log.t t/repobrowse_git_raw.t t/repobrowse_git_snapshot.t -t/repobrowse_git_tree.t +t/repobrowse_git_src.t t/search.t t/spamcheck_spamc.t t/spawn.t diff --git a/lib/PublicInbox/RepoGitCommit.pm b/lib/PublicInbox/RepoGitCommit.pm index 34f7acc3..8add3006 100644 --- a/lib/PublicInbox/RepoGitCommit.pm +++ b/lib/PublicInbox/RepoGitCommit.pm @@ -40,7 +40,7 @@ sub commit_header { my $rel = $req->{relcmd}; my $x = $self->html_start($req, $s) . "\n" . qq( commit $H (<a\nhref="${rel}patch/$H">patch</a>)\n) . - qq( tree <a\nrel=nofollow\nhref="${rel}tree/$H">$t</a>); + qq( tree <a\nrel=nofollow\nhref="${rel}src/$H">$t</a>); my $git = $req->{-repo}->{git}; # extra show path information, if any @@ -55,7 +55,7 @@ sub commit_header { my $e = PublicInbox::Hval->utf8($_, join('/', @t)); $ep = $e->as_path; my $eh = $e->as_html; - $ep = "${rel}tree/$ep/$H"; + $ep = "${rel}src/$ep/$H"; qq(<a\nrel=nofollow\nhref="$ep">$eh</a>); } @$extra); $path = "/$ep"; @@ -185,7 +185,7 @@ sub show_unchanged { $p = $p->as_path; $fn = utf8_html($fn); $$dst .= qq(\t<a\nrel=nofollow); - $$dst .= qq(\nid="$anchor"\nhref="${rel}tree/$p">); + $$dst .= qq(\nid="$anchor"\nhref="${rel}src/$p">); $$dst .= "$fn</a>\n"; } } diff --git a/lib/PublicInbox/RepoGitDiffCommon.pm b/lib/PublicInbox/RepoGitDiffCommon.pm index 46e243ed..b60a5fbc 100644 --- a/lib/PublicInbox/RepoGitDiffCommon.pm +++ b/lib/PublicInbox/RepoGitDiffCommon.pm @@ -68,7 +68,7 @@ sub git_diff_ab_hunk ($$$$) { $na = defined $na ? "#n$na" : ''; my $p = $req->{p}->[0]; $rv .= qq(<a\nrel=nofollow); - $rv .= qq(\nhref="${rel}tree/$p/$req->{path_a}$na">); + $rv .= qq(\nhref="${rel}src/$p/$req->{path_a}$na">); $rv .= "$ca</a>"; } $rv .= ' '; @@ -77,7 +77,7 @@ sub git_diff_ab_hunk ($$$$) { } else { $nb = defined $nb ? "#n$nb" : ''; $rv .= qq(<a\nrel=nofollow); - $rv .= qq(\nhref="${rel}tree/$req->{-tip}/$req->{path_b}$nb">); + $rv .= qq(\nhref="${rel}src/$req->{-tip}/$req->{path_b}$nb">); $rv .= "$cb</a>"; } $rv . ' @@' . utf8_html($ctx); @@ -121,14 +121,14 @@ sub git_diff_cc_hunk { } } - # we can use the normal 'tree' endpoint for the result + # we can use the normal 'src' endpoint for the result my ($n) = ($last =~ /\A\+(\d+)/); # line number if ($n == 0) { # deleted file (does this happen with --cc?) $rv .= " $last"; } else { my $H = $req->{H}; $rv .= qq( <a\nrel=nofollow); - $rv .= qq(\nhref="${rel}tree/$H/$path#n$n">$last</a>); + $rv .= qq(\nhref="${rel}src/$H/$path#n$n">$last</a>); } $rv .= " $at" . utf8_html($ctx); } diff --git a/lib/PublicInbox/RepoGitTree.pm b/lib/PublicInbox/RepoGitSrc.pm index e8c34a69..1546830f 100644 --- a/lib/PublicInbox/RepoGitTree.pm +++ b/lib/PublicInbox/RepoGitSrc.pm @@ -1,6 +1,6 @@ # Copyright (C) 2015 all contributors <meta@public-inbox.org> # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> -package PublicInbox::RepoGitTree; +package PublicInbox::RepoGitSrc; use strict; use warnings; use base qw(PublicInbox::RepoBase); @@ -19,7 +19,7 @@ my $BINARY_MSG = "Binary file, save using the 'raw' link above"; my $MAX_ASYNC = 65536; # same as pipe size on Linux my $BIN_DETECT = 8000; # same as git (buffer_is_binary in git.git) -sub call_git_tree { +sub call_git_src { my ($self, $req) = @_; my $repo = $req->{-repo}; my $git = $repo->{git}; @@ -63,7 +63,7 @@ sub cur_path { my $rel = $req->{relcmd}; # avoid relative paths, here, we don't want to propagate # trailing-slash URLs although we tolerate them - $s = "<a\nhref=\"${rel}tree/$tip\">root</a>/"; + $s = "<a\nhref=\"${rel}src/$tip\">root</a>/"; my $cur = pop @ex; my @t; $s .= join('/', (map { @@ -71,7 +71,7 @@ sub cur_path { my $e = PublicInbox::Hval->utf8($_, join('/', @t)); my $ep = $e->as_path; my $eh = $e->as_html; - "<a\nhref=\"${rel}tree/$tip/$ep\">$eh</a>"; + "<a\nhref=\"${rel}src/$tip/$ep\">$eh</a>"; } @ex), '<b>'.utf8_html($cur).'</b>'); } @@ -230,7 +230,7 @@ sub git_tree_show { } elsif (defined(my $tip = $req->{tip})) { $pfx = $tip; } else { - $pfx = 'tree/' . $req->{-repo}->tip; + $pfx = 'src/' . $req->{-repo}->tip; } $req->{tpfx} = $pfx; my $env = $req->{env}; diff --git a/lib/PublicInbox/RepoGitSummary.pm b/lib/PublicInbox/RepoGitSummary.pm index 5eb8087d..96ae9be9 100644 --- a/lib/PublicInbox/RepoGitSummary.pm +++ b/lib/PublicInbox/RepoGitSummary.pm @@ -84,14 +84,14 @@ sub readme_path_links { my ($req, $rel, $readme) = @_; my @path = split(m!/+!, $readme); my $tip = $req->{-repo}->tip; - my $s = "tree <a\nhref=\"${rel}tree/$tip\">root</a>/"; + my $s = "tree <a\nhref=\"${rel}src/$tip\">root</a>/"; my @t; $s .= join('/', (map { push @t, $_; my $e = PublicInbox::Hval->utf8($_, join('/', @t)); my $ep = $e->as_path; my $eh = $e->as_html; - $e = "<a\nhref=\"${rel}tree/$tip/$ep\">$eh</a>"; + $e = "<a\nhref=\"${rel}src/$tip/$ep\">$eh</a>"; # bold the last one scalar(@t) == scalar(@path) ? "<b>$e</b>" : $e; } @path)); diff --git a/lib/PublicInbox/Repobrowse.pm b/lib/PublicInbox/Repobrowse.pm index aad0e8ba..5ef9e59a 100644 --- a/lib/PublicInbox/Repobrowse.pm +++ b/lib/PublicInbox/Repobrowse.pm @@ -22,7 +22,7 @@ use strict; use warnings; use PublicInbox::RepoConfig; -my %CMD = map { lc($_) => $_ } qw(Log Commit Tree Patch Blob Raw Tag Atom +my %CMD = map { lc($_) => $_ } qw(Log Commit Src Patch Blob Raw Tag Atom Diff Snapshot); my %VCS = (git => 'Git'); my %LOADED; @@ -93,7 +93,7 @@ sub call { } # URL syntax: / repo [ / cmd [ / head [ / path ] ] ] - # cmd: log | commit | diff | tree | view | blob | snapshot + # cmd: log | commit | diff | src | view | blob | snapshot # repo and path (@extra) may both contain '/' my $path_info = $env->{PATH_INFO}; my (undef, $repo_path, @extra) = split(m{/+}, $path_info, -1); diff --git a/t/repobrowse_git_tree.t b/t/repobrowse_git_src.t index d91cfdc9..4d16eac4 100644 --- a/t/repobrowse_git_tree.t +++ b/t/repobrowse_git_src.t @@ -7,7 +7,7 @@ my $test = require './t/repobrowse_common_git.perl'; test_psgi($test->{app}, sub { my ($cb) = @_; - my $req = 'http://example.com/test.git/tree/HEAD/dir'; + my $req = 'http://example.com/test.git/src/HEAD/dir'; my $res = $cb->(GET($req)); is(200, $res->code, 'got 200 response from dir'); my $noslash_body = dechunk($res); @@ -19,7 +19,7 @@ test_psgi($test->{app}, sub { is(301, $r2->code, 'got 301 response from dir with slash'); is($req, $r2->header('Location'), 'redirected w/o slash'); - $req = 'http://example.com/test.git/tree/master/foo.txt'; + $req = 'http://example.com/test.git/src/master/foo.txt'; my $blob = $cb->(GET($req)); is($blob->header('Content-Type'), 'text/html; charset=UTF-8', 'got text/html blob'); |