# Usage: plackup [OPTIONS] /path/to/this/file
use strict;
use warnings;
-use PublicInbox::RepoBrowse;
+use PublicInbox::Repobrowse;
use Plack::Request;
use Plack::Builder;
my $have_deflater = eval { require Plack::Middleware::Deflater; 1 };
-my $repo_browse = PublicInbox::RepoBrowse->new;
+my $repo_browse = PublicInbox::Repobrowse->new;
builder {
enable 'Plack::Middleware::Chunked';
#
# This allows an M:N relationship between "normal" repos for project
# and public-inbox (ssoma) git repositories where N may be zero.
-# In other words, RepoBrowse must work for repositories without
+# In other words, repobrowse must work for repositories without
# any public-inbox at all; or with multiple public-inboxes.
# And the rest of public-inbox will always work without a "normal"
# code repo for the project.
-package PublicInbox::RepoBrowse;
+package PublicInbox::Repobrowse;
use strict;
use warnings;
use URI::Escape qw(uri_escape_utf8 uri_unescape);
-use PublicInbox::RepoConfig;
+use PublicInbox::RepobrowseConfig;
my %CMD = map { lc($_) => $_ } qw(Log Commit Tree Patch Blob Plain Tag);
my %VCS = (git => 'Git');
sub new {
my ($class, $file) = @_;
- bless { rconfig => PublicInbox::RepoConfig->new($file) }, $class;
+ bless { rconfig => PublicInbox::RepobrowseConfig->new($file) }, $class;
}
# simple response for errors
unshift @extra, $cmd;
$mod = 'Fallback';
}
- $mod = load_once("PublicInbox::RepoBrowse$vcs$mod");
+ $mod = load_once("PublicInbox::Repobrowse$vcs$mod");
$vcs = load_once("PublicInbox::$vcs");
$repo_info->{$vcs_lc} ||= $vcs->new($repo_info->{path});
$req->{relcmd} = '../' x scalar(@extra);
# Copyright (C) 2015 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-package PublicInbox::RepoBrowseBase;
+package PublicInbox::RepobrowseBase;
use strict;
use warnings;
-require PublicInbox::RepoBrowseQuery;
+require PublicInbox::RepobrowseQuery;
use PublicInbox::Hval;
sub new { bless {}, shift }
# Copyright (C) 2015 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-package PublicInbox::RepoConfig;
+package PublicInbox::RepobrowseConfig;
use strict;
use warnings;
use PublicInbox::Config qw/try_cat/;
sub default_file {
my $f = $ENV{PI_REPO_CONFIG};
return $f if defined $f;
- PublicInbox::Config::config_dir() . '/repo_config';
+ PublicInbox::Config::config_dir() . '/repobrowse_config';
}
# Returns something like:
# Copyright (C) 2015 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ (https://www.gnu.org/licenses/agpl-3.0.txt)
-# common functions used by other RepoBrowseGit* modules
-package PublicInbox::RepoBrowseGit;
+# common functions used by other RepobrowseGit* modules
+package PublicInbox::RepobrowseGit;
use strict;
use warnings;
use base qw(Exporter);
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# Show a blob as-is
-package PublicInbox::RepoBrowseGitBlob;
+package PublicInbox::RepobrowseGitBlob;
use strict;
use warnings;
-use base qw(PublicInbox::RepoBrowseBase);
+use base qw(PublicInbox::RepobrowseBase);
use base qw(Exporter);
our @EXPORT = qw(git_blob_mime_type git_blob_stream_response);
sub call_git_blob {
my ($self, $req) = @_;
my $git = $req->{repo_info}->{git};
- my $q = PublicInbox::RepoBrowseQuery->new($req->{cgi});
+ my $q = PublicInbox::RepobrowseQuery->new($req->{cgi});
my $id = $q->{id};
$id eq '' and $id = 'HEAD';
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# shows the /commit/ endpoint for git repositories
-package PublicInbox::RepoBrowseGitCommit;
+package PublicInbox::RepobrowseGitCommit;
use strict;
use warnings;
-use base qw(PublicInbox::RepoBrowseBase);
+use base qw(PublicInbox::RepobrowseBase);
use PublicInbox::Hval qw(utf8_html);
-use PublicInbox::RepoBrowseGit qw(git_unquote git_commit_title);
+use PublicInbox::RepobrowseGit qw(git_unquote git_commit_title);
use constant GIT_FMT => '--pretty=format:'.join('%n',
'%H', '%h', '%s', '%an <%ae>', '%ai', '%cn <%ce>', '%ci',
sub call_git_commit {
my ($self, $req) = @_;
- my $q = PublicInbox::RepoBrowseQuery->new($req->{cgi});
+ my $q = PublicInbox::RepobrowseQuery->new($req->{cgi});
my $id = $q->{id};
$id eq '' and $id = 'HEAD';
my $git = $req->{repo_info}->{git};
# when no endpoints match, fallback to this and serve a static file
# This can serve Smart HTTP in the future.
-package PublicInbox::RepoBrowseGitFallback;
+package PublicInbox::RepobrowseGitFallback;
use strict;
use warnings;
-use base qw(PublicInbox::RepoBrowseBase);
+use base qw(PublicInbox::RepobrowseBase);
use Fcntl qw(:seek);
-# overrides PublicInbox::RepoBrowseBase::call
+# overrides PublicInbox::RepobrowseBase::call
sub call {
my ($self, undef, $req) = @_;
my $expath = $req->{expath};
# Copyright (C) 2015 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-package PublicInbox::RepoBrowseGitLog;
+package PublicInbox::RepobrowseGitLog;
use strict;
use warnings;
use PublicInbox::Hval qw(utf8_html);
-use base qw(PublicInbox::RepoBrowseBase);
-use PublicInbox::RepoBrowseGit qw(git_dec_links git_commit_title);
+use base qw(PublicInbox::RepobrowseBase);
+use PublicInbox::RepobrowseGit qw(git_dec_links git_commit_title);
# cannot rely on --date=format-local:... yet, it is too new (September 2015)
my $LOG_FMT = '--pretty=tformat:'.
join('%x00', qw(%h %p %s D%D));
$max = int($max);
$max = 50 if $max == 0;
- my $q = PublicInbox::RepoBrowseQuery->new($req->{cgi});
+ my $q = PublicInbox::RepobrowseQuery->new($req->{cgi});
my $h = $q->{h};
$h eq '' and $h = 'HEAD';
# shows the /patch/ endpoint for git repositories
# usage: /repo.git/patch?id=COMMIT_ID
-package PublicInbox::RepoBrowseGitPatch;
+package PublicInbox::RepobrowseGitPatch;
use strict;
use warnings;
-use base qw(PublicInbox::RepoBrowseBase);
+use base qw(PublicInbox::RepobrowseBase);
# try to be educational and show the command-line used in the signature
my @CMD = qw(format-patch -M --stdout);
sub call_git_patch {
my ($self, $req) = @_;
my $git = $req->{repo_info}->{git};
- my $q = PublicInbox::RepoBrowseQuery->new($req->{cgi});
+ my $q = PublicInbox::RepobrowseQuery->new($req->{cgi});
my $id = $q->{id};
$id =~ /\A[\w-]+([~\^][~\^\d])*\z/ or $id = 'HEAD';
# Copyright (C) 2015-2016 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-package PublicInbox::RepoBrowseGitPlain;
+package PublicInbox::RepobrowseGitPlain;
use strict;
use warnings;
-use base qw(PublicInbox::RepoBrowseBase);
-use PublicInbox::RepoBrowseGitBlob;
+use base qw(PublicInbox::RepobrowseBase);
+use PublicInbox::RepobrowseGitBlob;
use PublicInbox::Hval qw(utf8_html);
sub call_git_plain {
my ($self, $req) = @_;
my $git = $req->{repo_info}->{git};
- my $q = PublicInbox::RepoBrowseQuery->new($req->{cgi});
+ my $q = PublicInbox::RepobrowseQuery->new($req->{cgi});
my $id = $q->{id};
$id eq '' and $id = 'HEAD';
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# shows the /tag/ endpoint for git repositories
-package PublicInbox::RepoBrowseGitTag;
+package PublicInbox::RepobrowseGitTag;
use strict;
use warnings;
-use base qw(PublicInbox::RepoBrowseBase);
+use base qw(PublicInbox::RepobrowseBase);
use POSIX qw(strftime);
use PublicInbox::Hval qw(utf8_html);
sub call_git_tag {
my ($self, $req) = @_;
- my $q = PublicInbox::RepoBrowseQuery->new($req->{cgi});
+ my $q = PublicInbox::RepobrowseQuery->new($req->{cgi});
my $h = $q->{h};
$h eq '' and return sub {
my ($res) = @_;
# Copyright (C) 2015 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-package PublicInbox::RepoBrowseGitTree;
+package PublicInbox::RepobrowseGitTree;
use strict;
use warnings;
-use base qw(PublicInbox::RepoBrowseBase);
+use base qw(PublicInbox::RepobrowseBase);
use PublicInbox::Hval qw(utf8_html);
my %GIT_MODE = (
my ($self, $req, $res) = @_; # res: Plack callback
my @extra = @{$req->{extra}};
my $git = $req->{repo_info}->{git};
- my $q = PublicInbox::RepoBrowseQuery->new($req->{cgi});
+ my $q = PublicInbox::RepobrowseQuery->new($req->{cgi});
my $id = $q->{id};
if ($id eq '') {
chomp($id = $git->qx(qw(rev-parse --short=10 HEAD)));
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# query parameter management for repobrowse
-package PublicInbox::RepoBrowseQuery;
+package PublicInbox::RepobrowseQuery;
use strict;
use warnings;
use PublicInbox::Hval;
psgi => $psgi,
git_dir => $git_dir,
app => $app,
-}, 'RepoBrowse::TestGit';
+}, 'Repobrowse::TestGit';
use strict;
use warnings;
use Test::More;
-use PublicInbox::RepoBrowseGit qw(git_unquote);
+use PublicInbox::RepobrowseGit qw(git_unquote);
is("foo\nbar", git_unquote('"foo\\nbar"'), 'unquoted newline');
is("Eléanor", git_unquote('"El\\303\\251anor"'), 'unquoted octal');