forked from yuki-kimoto/gitprep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree.html.ep
208 lines (172 loc) · 6.35 KB
/
tree.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<%
my $state;
# API
my $api = gitprep_api;
# Git
my $git = app->git;
# Parameters
my $user_id = param('user');
my $project_id = param('project');
my $project_row_id = $api->get_project_row_id($user_id, $project_id);
my $rev;
my $dir;
my $rev_dir = param('rev_dir');
if (defined $rev_dir) {
($rev, $dir) = $git->parse_rev_path(app->rep_info($user_id, $project_id), $rev_dir);
}
else {
$rev = app->manager->default_branch($user_id, $project_id);
}
unless (app->manager->exists_project($user_id, $project_id)) {
$self->reply->not_found;
return;
}
# Repository description
my $desc = $git->description(app->rep_info($user_id, $project_id));
my $website_url = app->dbi->model('project')->select('website_url', where => {row_id => $project_row_id})->value;
# Check exsitence
my $commits_number;
if ($git->exists_branch(app->rep_info($user_id, $project_id))) {
# Commit
my $commit = $git->get_commit(app->rep_info($user_id, $project_id), $rev);
# Tree
my $trees;
if (defined $dir && length $dir) {
$trees = $git->trees(app->rep_info($user_id, $project_id), $rev, $dir);
}
else {
$trees = $git->trees(app->rep_info($user_id, $project_id), $rev);
}
# Commits number
$commits_number = $git->commits_number(app->rep_info($user_id, $project_id), $rev);
# Variable for included template
stash(
commit => $commit,
trees => $trees,
rev => $rev,
title => "$user_id/$project_id",
);
$state = 'display';
}
else { $state = 'init' }
my $is_project_top_page = !(defined $dir && length $dir);
my $url = url_for->to_abs;
$url->base(undef);
my $ssh_port = config->{basic}{ssh_port};
my $rep_home = app->rep_home;
my $execute_user = getpwuid($>);
my $ssh_rep_url_base = defined app->config->{basic}{'ssh_rep_url_base'}
? app->config->{basic}{'ssh_rep_url_base'} : $rep_home;
my $ssh_rep_url = "ssh://$execute_user\@" . $url->host
. ($ssh_port ? ":$ssh_port" : '') . "$ssh_rep_url_base/$user_id/$project_id.git";
my $branches = stash('branches');
my $branches_count = app->git->branches_count($self->app->rep_info($user_id, $project_id));
my $default_branch_name = app->manager->default_branch($user_id, $project_id);
my $tags_count = app->git->tags_count(app->rep_info($user_id, $project_id));
my $logined = $api->logined;
layout 'common', title => "$user_id/$project_id";
%>
%= include '/include/header';
<div class="container">
%= include '/include/message', message => flash('message');
% if ($is_project_top_page) {
<h3 style="font-weight:normal;color:#666;margin:20px 0px 20px 0;font-size:16px;line-height:0">
<%= $desc %>
% if (defined $website_url && length $website_url) {
<a href="<%= $website_url %>"><%= $website_url %></a>
% }
</h3>
% }
% if ($state eq 'display') {
% if ($is_project_top_page) {
<ul class="commits-count">
<li>
% my $commits_url = "/$user_id/$project_id/commits/" . ((defined $rev && length $rev) ? $rev : $default_branch_name);
<a href="<%= url_for($commits_url) %>">
<span class="commits-count-number">
<i class="icon-repeat"></i>
<%= $commits_number %>
</span>
<span class="commits-count-type">
commits
</span>
</a>
</li>
<li>
<a href="<%= url_for("/$user_id/$project_id/branches") %>">
<span class="commits-count-number">
<i class="icon-indent-left"></i>
<%= $branches_count %>
</span>
<span class="commits-count-type">
branches
</span>
</a>
</li>
<li>
<a href="<%= url_for("/$user_id/$project_id/tags") %>">
<span class="commits-count-number">
<i class="icon-tags"></i>
<%= $tags_count %>
</span>
<span class="commits-count-type">
releases
</span>
</a>
</li>
</ul>
<div style="border-radius:0 0 3px 3px;border: 1px solid #ddd;min-height:8px;border-top:none;margin-bottom:15px;background:#0298c3">
</div>
% }
<div style="margin-bottom:5px;">
% my $display = defined $dir && length $dir ? 'tree' : 'tree_top';
%= include '/include/branch_select', display => $display, Path => $dir, ssh_rep_url => $ssh_rep_url;
</div>
<div style="margin-bottom:30px">
%= include '/include/tree', dir => $dir;
</div>
%= include '/include/readme', dir => $dir;
% } elsif ($state eq 'init' && $api->logined($user_id)) {
<h4 class="topic1">SSH</h4>
<div class="text-center" style="margin-bottom:10px">
<b>Create a new repository on the command line via ssh</b>
</div>
<pre class="command-line">
touch README
git init
git add README
git commit -m "first commit"
git remote add origin <%= $ssh_rep_url %>
git push -u origin master</pre>
<div class="text-center" style="margin-bottom:10px">
<b>Push an existing repository from the command line via ssh</b>
</div>
<pre class="command-line">
git remote add origin <%= $ssh_rep_url %>
git push -u origin master</pre>
<hr>
% my $http_rep_url = url_for("$user_id/$project_id.git")->to_abs;
<h4 class="topic1"><%= uc url_for->to_abs->scheme %></h4>
<div class="text-center" style="margin-bottom:10px">
<b>Create a new repository on the command line via <%= url_for->to_abs->scheme %></b>
</div>
<pre class="command-line">
touch README
git init
git add README
git commit -m "first commit"
git remote add origin <%= $http_rep_url %>
git push -u origin master</pre>
<div class="text-center" style="margin-bottom:10px">
<b>Push an existing repository from the command line via <%= url_for->to_abs->scheme %></b>
</div>
<pre class="command-line">
git remote add origin <%= $http_rep_url %>
git push -u origin master</pre>
% } else {
<div class="not-yet-created">
<b>Repository is not yet created.</b>
</div>
% }
</div>
%= include '/include/footer';