forked from yuki-kimoto/gitprep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmodule.html.ep
71 lines (59 loc) · 1.59 KB
/
submodule.html.ep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<%
use File::Basename ();
# API
my $api = gitprep_api;
# Git
my $git = $self->app->git;
# Parameters
my $user = param('user');
my $project = param('project');
my $rev_file = param('rev_file');
my ($rev, $file) = $git->parse_rev_path(app->rep_info($user, $project), $rev_file);
my $file_base = File::Basename::basename $file;
# Blob lines
my $lines = $git->blob(app->rep_info($user, $project), $rev, '.gitmodules');
my $submodule_rep_url;
my $match;
my $file_q = quotemeta $file;
for my $line (@$lines) {
$line =~ s/\r//;
$line =~ s/\n//;
if ($match) {
if ($line =~ /url += +(.+)/) {
$submodule_rep_url = $1;
last;
}
}
elsif ($line =~ /path += +$file_q( +|$)/) {
$match = 1;
};
}
# Variables for included template
stash id => $rev;
stash project => $project;
stash rev => $rev;
layout 'common' , title => "$project/$file at $rev \x{30fb} $user/$project";
%>
%= include '/include/header';
<div class="container">
%= include '/include/page_path', type => 'blob', Path => $file;
<div class="submodule">
<div>
<div>
<div>
<%= $file_base %> <small>[submodule]</small>
</div>
</div>
</div>
<div class="last-child">
% if ($submodule_rep_url) {
% if ($submodule_rep_url =~ /^http/) {
<a href="<%= $submodule_rep_url %>"><%= $submodule_rep_url %></a>
% } else {
<%= $submodule_rep_url %>
% }
% }
</div>
</div>
</div>
%= include '/include/footer';