From f6244586ba4f5a5e7575e1254be8c9bbe303fce9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 15 Feb 2017 22:35:18 +0000 Subject: repobrowse: switch to new URL format to avoid query strings Query strings make endpoint caching more difficult since they're order-independent. They are also more likely lost or truncated inadvertantly when copy+pasting, so try to avoid them for default endpoints. There's still some things which are broken and followup commits will be needed to fix them. --- lib/PublicInbox/RepoGitCommit.pm | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'lib/PublicInbox/RepoGitCommit.pm') diff --git a/lib/PublicInbox/RepoGitCommit.pm b/lib/PublicInbox/RepoGitCommit.pm index e98c3c18..c1cf06db 100644 --- a/lib/PublicInbox/RepoGitCommit.pm +++ b/lib/PublicInbox/RepoGitCommit.pm @@ -37,11 +37,9 @@ sub commit_header { my @p = split(' ', $p); my $rel = $req->{relcmd}; - my $q = $req->{'q'}; - my $qs = $req->{qs} = $q->qs(id => $h); my $x = $self->html_start($req, $s) . "\n" . - qq( commit $H (patch)\n) . - qq( tree $t); + qq( commit $H (patch)\n) . + qq( tree $t); my $git = $req->{repo_info}->{git}; # extra show path information, if any @@ -56,7 +54,7 @@ sub commit_header { my $e = PublicInbox::Hval->utf8($_, join('/', @t)); $ep = $e->as_path; my $eh = $e->as_html; - $ep = "${rel}tree/$ep?id=$h"; + $ep = "${rel}tree/$ep/$h"; qq($eh); } @$extra); $path = "/$ep"; @@ -66,10 +64,10 @@ sub commit_header { my $np = scalar @p; if ($np == 1) { my $p = $p[0]; - $x .= git_parent_line(' parent', $p, $q, $git, $rel, $path); + $x .= git_parent_line(' parent', $p, $git, $rel); } elsif ($np > 1) { $req->{mhelp} = CC_MERGE; - my @common = ($q, $git, $rel, $path); + my @common = ($git, $rel); my @t = @p; my $p = shift @t; $x .= git_parent_line(' parents', $p, @common); @@ -119,24 +117,20 @@ sub git_commit_sed ($$) { sub call_git_commit { # RepoBase calls this my ($self, $req) = @_; my $env = $req->{env}; - my $q = PublicInbox::RepoGitQuery->new($env); - my $id = $q->{id}; - $id eq '' and $id = 'HEAD'; + my $tip = $req->{-tip}; my $expath = $req->{expath}; if ($expath ne '') { my $relup = join('', map { '../' } @{$req->{extra}}); - my $qs = $q->qs; - return $self->r(301, $req, "$relup$qs#".to_attr($expath)); + return $self->r(301, $req, "$relup#".to_attr($expath)); } my $git = $req->{repo_info}->{git}; my $cmd = $git->cmd(qw(show -z --numstat -p --encoding=UTF-8 --no-notes --no-color -c), - $git->abbrev, GIT_FMT, $id, '--'); + $git->abbrev, GIT_FMT, $tip, '--'); my $rdr = { 2 => $git->err_begin }; my $qsp = PublicInbox::Qspawn->new($cmd, undef, $rdr); - $req->{'q'} = $q; $env->{'qspawn.quiet'} = 1; $qsp->psgi_return($env, undef, sub { # parse header my ($r, $bref) = @_; @@ -159,8 +153,7 @@ sub git_commit_404 { my $try = 'try'; $x = "$x
$x\n\n";
-	my $qs = $req->{'q'}->qs(id => '');
-	$x .= "$try the latest commit in HEAD\n";
+	$x .= "$try the latest commit in HEAD\n";
 	$x .= '
'; [404, ['Content-Type'=>'text/html'], [ $x ]]; @@ -168,11 +161,10 @@ sub git_commit_404 { # FIXME: horrifically expensive... sub git_parent_line { - my ($pfx, $p, $q, $git, $rel, $path) = @_; - my $qs = $q->qs(id => $p); + my ($pfx, $p, $git, $rel) = @_; my $t = git_commit_title($git, $p); $t = defined $t ? utf8_html($t) : ''; - $pfx . qq( $p $t\n); + $pfx . qq( $p $t\n); } # do not break anchor links if the combined diff doesn't show changes: @@ -186,14 +178,13 @@ sub show_unchanged { qq( See the parents, ) . "or view final state(s) below:\n\n"; my $rel = $req->{relcmd}; - my $qs = $req->{qs}; foreach my $anchor (@unchanged) { my $fn = $anchors->{$anchor}; my $p = PublicInbox::Hval->utf8(git_unquote($fn)); $p = $p->as_path; $fn = utf8_html($fn); $$dst .= qq(\t); + $$dst .= qq(\nid="$anchor"\nhref="${rel}tree/$p">); $$dst .= "$fn\n"; } } -- cgit v1.2.3-24-ge0c7