Skip to content

Commit

Permalink
support wiki raw
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-kimoto committed May 23, 2017
1 parent 5e5adb9 commit d25899c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 6 additions & 0 deletions lib/Gitprep.pm
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ sub startup {

# Blob
$r->get('/blob/*rev_file' => sub { shift->render_maybe('/blob') });

# Raw
$r->get('/raw/*rev_file' => sub { shift->render_maybe('/raw') });

# Blame
$r->get('/blame/*rev_file' => sub { shift->render_maybe('/blame') });
}

# Commit
Expand Down
18 changes: 13 additions & 5 deletions templates/raw.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@
my $git = app->git;

# Parameters
my $user = param('user');
my $project = param('project');
my $user_id = param('user');
my $project_id = param('project');
my $rev_file = param('rev_file');
my ($rev, $file) = $git->parse_rev_path(app->rep_info($user, $project), $rev_file);

my $is_wiki = (stash('tab') // '') eq 'wiki';
my $user_id_project_path = "/$user_id/$project_id";
if ($is_wiki) {
$user_id_project_path .= '/wiki';
}
my $rep_info = $is_wiki ? app->wiki_rep_info($user_id, $project_id) : app->rep_info($user_id, $project_id);

my ($rev, $file) = $git->parse_rev_path($rep_info, $rev_file);

# Blob raw
my $blob_raw = $git->blob_raw(app->rep_info($user, $project), $rev, $file);
my $blob_raw = $git->blob_raw($rep_info, $rev, $file);

# Content type
my $type = $git->blob_content_type(app->rep_info($user, $project), $rev, $file);
my $type = $git->blob_content_type($rep_info, $rev, $file);

# File name
my $file_name = $rev;
Expand Down

0 comments on commit d25899c

Please sign in to comment.