improve commits header desig...
|
1 |
<% |
2 |
my $api = gitprep_api; |
|
3 |
|
|
improve branch select design
|
4 |
my $user = param('user'); |
5 |
my $project = param('project'); |
|
improve commits header desig...
|
6 |
my $display = stash('display') || ''; |
7 |
my $rev = stash('rev'); |
|
8 |
$rev = '' unless defined $rev; |
|
9 |
my $branches = stash('branches'); |
|
improve branch select design
|
10 |
my $ssh_rep_url = stash('ssh_rep_url'); |
improve commits header desig...
|
11 | |
12 |
my $logined = $api->logined; |
|
improve branch select design
|
13 | |
14 |
my $type |
|
cleanup branch select
|
15 |
= $display eq 'tree' || $display eq 'tree_top' || $display eq 'blob' |
improve branch select design
|
16 |
? 'tree' : 'commits'; |
fix tree bug and improve tre...
|
17 |
|
improve blog page page path
|
18 |
my $path = stash('Path'); |
improve branch select design
|
19 | |
20 |
my $title; |
|
21 |
my $rev_short; |
|
22 |
if (defined $rev && length $rev == 40) { |
|
improve tree design
|
23 |
$title = 'Tree'; |
improve branch select design
|
24 |
$rev_short = substr($rev, 0, 10); |
25 |
} |
|
26 |
else { |
|
improve tree design
|
27 |
$title = 'Branch'; |
improve branch select design
|
28 |
$rev_short = $rev; |
29 |
} |
|
improve branch select design
|
30 |
|
improve commits header desig...
|
31 |
%> |
32 | ||
33 |
%= javascript begin |
|
34 |
$(document).ready(function () { |
|
35 |
|
|
cleanup
|
36 |
// Switch branches and tags |
37 |
var revs_init = false; |
|
38 |
$('#rev-btn').on('click', function () { |
|
improve commits header desig...
|
39 |
|
cleanup
|
40 |
if (!revs_init) { |
41 |
$.get('<%= url_for("/$user/$project/api/revs") %>', function (result) { |
|
42 |
var branch_names = result.branch_names; |
|
43 |
var tag_names = result.tag_names; |
|
44 |
var style = 'style="border-top-left-radius:0px;border-top-right-radius:0px;"'; |
|
45 |
|
|
46 |
if (branch_names.length === 0) { |
|
47 |
$('#branch-names-list').append( |
|
48 |
'<li><a ' + style + ' href="#">No branches</a></li>' |
|
49 |
); |
|
50 |
} |
|
51 |
else { |
|
52 |
for (var i = 0; i < branch_names.length; i++) { |
|
53 |
var branch_name = branch_names[i]; |
|
improve commits header desig...
|
54 |
$('#branch-names-list').append( |
cleanup
|
55 |
'<li><a ' + style + ' href="<%= url_for("/$user/$project/$type/") %>' + branch_name + '">' + branch_name + '</a></li>' |
improve commits header desig...
|
56 |
); |
57 |
} |
|
cleanup
|
58 |
} |
59 |
|
|
60 |
if (tag_names.length === 0) { |
|
61 |
$('#tag-names-list').append( |
|
62 |
'<li><a ' + style + ' href="#">No tags</a></li>' |
|
63 |
); |
|
64 |
} |
|
65 |
else { |
|
66 |
for (var i = 0; i < tag_names.length; i++) { |
|
67 |
var tag_name = tag_names[i]; |
|
improve commits header desig...
|
68 |
$('#tag-names-list').append( |
cleanup
|
69 |
'<li><a ' + style + ' href="<%= url_for("/$user/$project/$type/") %>' + tag_name + '">' + tag_name + '</a></li>' |
improve commits header desig...
|
70 |
); |
71 |
} |
|
cleanup
|
72 |
} |
improve commits header desig...
|
73 |
$('#rev-popup') |
74 |
.css('display', 'block') |
|
75 |
.css('top', '5px') |
|
76 |
.css('left', '0px') |
|
77 |
; |
|
cleanup
|
78 |
}); |
79 |
revs_init = true; |
|
80 |
} |
|
81 |
else { |
|
improve commits header desig...
|
82 |
$('#rev-popup') |
83 |
.css('display', 'block') |
|
84 |
.css('top', '5px') |
|
85 |
.css('left', '0px') |
|
86 |
; |
|
cleanup
|
87 |
} |
88 |
}); |
|
89 | ||
90 |
$('#revs-tab a').click(function (e) { |
|
91 |
e.preventDefault(); |
|
92 |
$(this).tab('show'); |
|
93 |
}) |
|
94 |
|
|
95 |
$('#rev-close').on('click', function () { |
|
96 |
$('#rev-popup').css('display', 'none'); |
|
97 |
}); |
|
improve branch select design
|
98 |
|
99 |
|
|
100 |
// Repository URL buttons |
|
101 |
var http_rep_url = '<%= url_for("$user/$project.git")->to_abs %>'; |
|
102 |
|
|
103 |
var logined = <%= $logined ? 'true' : 'false' %>; |
|
104 |
var ssh_rep_url = '<%= $ssh_rep_url %>'; |
|
105 |
|
|
106 |
// Click HTTP button |
|
107 |
$('#btn_http').on('click', function () { |
|
108 |
$('#rep_url').val(http_rep_url); |
|
109 |
$('#btn_http').addClass('btn-info'); |
|
110 |
$('#btn_ssh').removeClass('btn-info'); |
|
111 |
}); |
|
112 | ||
113 |
// Click SSH button |
|
114 |
$('#btn_ssh').on('click', function () { |
|
115 |
$('#rep_url').val(ssh_rep_url); |
|
116 |
$('#btn_http').removeClass('btn-info'); |
|
117 |
$('#btn_ssh').addClass('btn-info'); |
|
118 |
}); |
|
119 | ||
120 |
// Initialize |
|
121 |
if (logined) { |
|
122 |
$('#btn_ssh').trigger('click'); |
|
123 |
} |
|
124 |
else { |
|
125 |
$('#btn_http').trigger('click'); |
|
126 |
} |
|
improve commits header desig...
|
127 |
}); |
128 |
% end |
|
129 | ||
improve branch select design
|
130 |
<div class="branch-select-container"> |
fix branch select design bug
|
131 |
<div class="branch-select-left-container <%= $display eq 'tree' || $display eq 'blob' ? 'branch-select-left-container-page-path' : '' %>"> |
improve branch select design
|
132 |
<button id="rev-btn" class="btn btn-small"> |
133 |
<span><%= $title %>:</span> <b><%= $rev_short %></b> <i class="icon-arrow-down"></i> |
|
cleanup
|
134 |
</button> |
complete branch select desig...
|
135 |
% if ($display eq 'tree' || $display eq 'blob') { |
136 |
%= include '/include/page_path', Path => $path; |
|
137 |
% } |
|
cleanup
|
138 |
</div> |
improve branch select design
|
139 |
% if ($display eq 'tree_top') { |
complete branch select desig...
|
140 |
<div class="branch-select-right-container"> |
141 |
<ul class="git-url-container"> |
|
142 |
% if ($logined) { |
|
143 |
<li> |
|
144 |
<button class="btn btn-small btn-info" id="btn_ssh">SSH</button> |
|
145 |
</li> |
|
146 |
% } |
|
improve branch select design
|
147 |
<li> |
complete branch select desig...
|
148 |
<button class="btn btn-small <%= !$logined ? 'btn-info' : '' %>" id="btn_http"><%= $self->req->is_secure ? 'HTTPS' : 'HTTP' %></button> |
improve branch select design
|
149 |
</li> |
complete branch select desig...
|
150 |
<li> |
151 |
<input id="rep_url" type="text"> |
|
152 |
</li> |
|
153 |
<li> |
|
154 |
<div class="donwload-zip"> |
|
add tar.gz donwload button
|
155 |
<a title="Download ZIP" class="btn btn-small" href="<%= url_for("/$user/$project/archive/$rev.zip") %>"> |
156 |
ZIP |
|
157 |
</a> |
|
158 |
<a title="Download tar.gz" class="btn btn-small" href="<%= url_for("/$user/$project/archive/$rev.tar.gz") %>"> |
|
159 |
tar.gz |
|
complete branch select desig...
|
160 |
</a> |
161 |
</div> |
|
162 |
</li> |
|
163 |
</ul> |
|
improve commits header desig...
|
164 |
</div> |
improve branch select design
|
165 |
% } |
improve commits header desig...
|
166 |
</div> |
167 | ||
168 |
<div style="position:relative"> |
|
cleanup
|
169 |
<div id="rev-popup" style="display:none;width:330px;position:absolute"> |
170 |
<div class="radius-top border-gray" style="background:#E6E6FA;padding:10px"> |
|
improve tag select design
|
171 |
<div style="overflow:hidden"> |
172 |
<div style="float:left;width:90%"> |
|
cleanup
|
173 |
<b>Switch branches/tags</b> |
improve commits header desig...
|
174 |
</div> |
improve tag select design
|
175 |
<div style="width:10%;float:right;text-align:right"> |
cleanup
|
176 |
<i id="rev-close" class="icon-remove-circle"></i> |
improve commits header desig...
|
177 |
</div> |
178 |
</div> |
|
179 |
</div> |
|
cleanup
|
180 |
<ul class="nav nav-tabs" id="revs-tab" style="background:#F5F5F5;margin-bottom:0"> |
181 |
<li class="active"><a href="#branches">Branches</a></li> |
|
182 |
<li><a href="#tags">Tags</a></li> |
|
183 |
</ul> |
|
184 |
<div class="tab-content"> |
|
185 |
<div class="tab-pane active" id="branches" style="background:white;max-height:300px;overflow:auto;margin-top:0"> |
|
186 |
<ul id="branch-names-list" class="nav nav-tabs nav-stacked"> |
|
187 |
</ul> |
|
188 |
</div> |
|
189 |
<div class="tab-pane" id="tags" style="background:white;max-height:300px;overflow:auto;margin-top:0"> |
|
190 |
<ul id="tag-names-list" class="nav nav-tabs nav-stacked"> |
|
191 |
</ul> |
|
improve commits header desig...
|
192 |
</div> |
193 |
</div> |
|
cleanup
|
194 |
</div> |
simplify commits page
|
195 |
</div> |