... | ... |
@@ -86,8 +86,10 @@ sub startup { |
86 | 86 |
|
87 | 87 |
# Repository |
88 | 88 |
$r->get('/:user/:repository')->to('#repository'); |
89 |
+ |
|
90 |
+ # Commits |
|
91 |
+ $r->get('/:user/:repository/commits/(:id)', {id => 'HEAD'})->to('#commits'); |
|
89 | 92 |
|
90 |
-=pod |
|
91 | 93 |
# Projects |
92 | 94 |
$r->get('/(*home)/projects')->to('#projects')->name('projects'); |
93 | 95 |
|
... | ... |
@@ -147,7 +149,6 @@ sub startup { |
147 | 149 |
$r->get('/snapshot/(:id)', {id => 'HEAD'}) |
148 | 150 |
->to('#snapshot')->name('snapshot'); |
149 | 151 |
} |
150 |
-=cut |
|
151 | 152 |
|
152 | 153 |
# File cache |
153 | 154 |
$git->search_projects; |
... | ... |
@@ -346,11 +346,20 @@ sub heads { |
346 | 346 |
); |
347 | 347 |
} |
348 | 348 |
|
349 |
-sub log { |
|
349 |
+=pod |
|
350 |
+sub commits { |
|
350 | 351 |
my ($self, %opt) = @_; |
352 |
+ |
|
353 |
+ # API |
|
354 |
+ my $api = Gitprep::API->new($self); |
|
355 |
+ |
|
356 |
+ my $user = $self->param('user'); |
|
357 |
+ my $repository = $self->param('repository'); |
|
351 | 358 |
|
359 |
+ my $root_ns = $api->root_ns($self->config->{root}); |
|
360 |
+ |
|
352 | 361 |
# Parameters |
353 |
- my $project_ns = $self->param('project'); |
|
362 |
+ my $project_ns = "$root_ns/$user/$repository.git"; |
|
354 | 363 |
my $project = "/$project_ns"; |
355 | 364 |
my $home_ns = dirname $project_ns; |
356 | 365 |
my $home = "/$home_ns"; |
... | ... |
@@ -392,6 +401,7 @@ sub log { |
392 | 401 |
page_count => $page_count |
393 | 402 |
); |
394 | 403 |
}; |
404 |
+=cut |
|
395 | 405 |
|
396 | 406 |
sub _root_ns { |
397 | 407 |
my $self = shift; |
... | ... |
@@ -689,4 +699,54 @@ sub _quote_command { |
689 | 699 |
map { my $a = $_; $a =~ s/(['!])/'\\$1'/g; "'$a'" } @_ ); |
690 | 700 |
} |
691 | 701 |
|
702 |
+#---- No need ----# |
|
703 |
+ |
|
704 |
+ |
|
705 |
+sub log { |
|
706 |
+ my ($self, %opt) = @_; |
|
707 |
+ |
|
708 |
+ # Parameters |
|
709 |
+ my $project_ns = $self->param('project'); |
|
710 |
+ my $project = "/$project_ns"; |
|
711 |
+ my $home_ns = dirname $project_ns; |
|
712 |
+ my $home = "/$home_ns"; |
|
713 |
+ my $id = $self->param('id'); |
|
714 |
+ my $page = $self->param('page'); |
|
715 |
+ $page = 0 if !defined $page; |
|
716 |
+ my $short = $self->param('short'); |
|
717 |
+ |
|
718 |
+ # Git |
|
719 |
+ my $git = $self->app->git; |
|
720 |
+ |
|
721 |
+ # Commit |
|
722 |
+ my $commit = $git->parse_commit($project, $id); |
|
723 |
+ |
|
724 |
+ # Commits |
|
725 |
+ my $page_count = $short ? 50 : 20; |
|
726 |
+ my $commits = $git->parse_commits( |
|
727 |
+ $project, $commit->{id},$page_count, $page_count * $page); |
|
728 |
+ for my $commit (@$commits) { |
|
729 |
+ my $author_date |
|
730 |
+ = $git->parse_date($commit->{author_epoch}, $commit->{author_tz}); |
|
731 |
+ $commit->{author_date} = $git->timestamp($author_date); |
|
732 |
+ } |
|
733 |
+ |
|
734 |
+ # References |
|
735 |
+ my $refs = $git->references($project); |
|
736 |
+ |
|
737 |
+ # Render |
|
738 |
+ $self->stash->{action} = 'shortlog' if $short; |
|
739 |
+ $self->render( |
|
740 |
+ home => $home, |
|
741 |
+ home_ns => $home_ns, |
|
742 |
+ project => $project, |
|
743 |
+ project_ns => $project_ns, |
|
744 |
+ id => $id, |
|
745 |
+ commits => $commits, |
|
746 |
+ refs => $refs, |
|
747 |
+ page => $page, |
|
748 |
+ page_count => $page_count |
|
749 |
+ ); |
|
750 |
+}; |
|
751 |
+ |
|
692 | 752 |
1; |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
<div class="page_nav"> |
2 |
- % my $id = stash('id') || gitpub_get_head_id($project); |
|
2 |
+ % my $id = stash('id') || gitprep_get_head_id($project); |
|
3 | 3 |
% if ($current eq 'summary') { |
4 | 4 |
Summary |
5 | 5 |
% } else { |
... | ... |
@@ -0,0 +1,77 @@ |
1 |
+<% |
|
2 |
+ # API |
|
3 |
+ my $api = Gitprep::API->new($self); |
|
4 |
+ |
|
5 |
+ my $user = param('user'); |
|
6 |
+ my $repository = param('repository'); |
|
7 |
+ |
|
8 |
+ my $root_ns = $api->root_ns(config->{root}); |
|
9 |
+ |
|
10 |
+ # Parameters |
|
11 |
+ my $project_ns = "$root_ns/$user/$repository.git"; |
|
12 |
+ my $project = "/$project_ns"; |
|
13 |
+ my $home_ns = $api->dirname($project_ns); |
|
14 |
+ my $home = "/$home_ns"; |
|
15 |
+ my $id = param('id'); |
|
16 |
+ my $page = $self->param('page'); |
|
17 |
+ $page = 0 if !defined $page; |
|
18 |
+ |
|
19 |
+ # Git |
|
20 |
+ my $git = $self->app->git; |
|
21 |
+ |
|
22 |
+ # Commit |
|
23 |
+ my $commit = $git->parse_commit($project, $id); |
|
24 |
+ |
|
25 |
+ # Commits |
|
26 |
+ my $page_count = 20; |
|
27 |
+ my $commits = $git->parse_commits( |
|
28 |
+ $project, $commit->{id},$page_count, $page_count * $page); |
|
29 |
+ for my $commit (@$commits) { |
|
30 |
+ my $author_date |
|
31 |
+ = $git->parse_date($commit->{author_epoch}, $commit->{author_tz}); |
|
32 |
+ $commit->{author_date} = $git->timestamp($author_date); |
|
33 |
+ } |
|
34 |
+ |
|
35 |
+ # References |
|
36 |
+ my $refs = $git->references($project); |
|
37 |
+%> |
|
38 |
+ |
|
39 |
+% layout 'common'; |
|
40 |
+ %= include '/include/header', title => 'Commits', project => $project; |
|
41 |
+ |
|
42 |
+ % for my $commit (@$commits) { |
|
43 |
+ <div class="header"> |
|
44 |
+ <a class="title" href="<%= url_for('commit', project => $project_ns, id => $commit->{id}) %>"> |
|
45 |
+ <span class="age" style="font-size:70%"> |
|
46 |
+ <%= $commit->{age_string} %> |
|
47 |
+ </span> |
|
48 |
+ |
|
49 |
+ <%= $commit->{title} %> |
|
50 |
+ </a> |
|
51 |
+ </div> |
|
52 |
+ <div class="title_text"> |
|
53 |
+ <div class="log_link"> |
|
54 |
+ <a href="<%= url_for('commit', project => $project_ns, id => $commit->{id}) %>">commit</a> | |
|
55 |
+ <a href="<%= url_for('commitdiff', project => $project_ns, diff => $commit->{id}) %>"> |
|
56 |
+ commitdiff |
|
57 |
+ </a> |
|
58 |
+ | |
|
59 |
+ <a href="<%= url_for('tree', project => $project_ns, |
|
60 |
+ id_dir => $commit->{id}) %>"> |
|
61 |
+ tree |
|
62 |
+ </a><br/> |
|
63 |
+ </div> |
|
64 |
+ <span class="author_date"><%= $commit->{author_name} %> [<%= $commit->{author_date} %>]</span> |
|
65 |
+ <br/> |
|
66 |
+ </div> |
|
67 |
+ <div class="log_body"> |
|
68 |
+ %= include 'include/refs', project_ns => $project_ns, commit => $commit, refs => $refs; |
|
69 |
+ <%= $commit->{title} %><br/> |
|
70 |
+ <br/> |
|
71 |
+ </div> |
|
72 |
+ % } |
|
73 |
+ |
|
74 |
+ <%= include '/include/page_navi2', current => 'log', id => $id, |
|
75 |
+ page => $page, page_count => $page_count, commits => $commits, |
|
76 |
+ project_ns => $project_ns; |
|
77 |
+ %> |
... | ... |
@@ -281,7 +281,7 @@ |
281 | 281 |
</div> |
282 | 282 |
</div> |
283 | 283 |
<a href="<%= url_for %>"><div class="code_menu_files">Files</div></a> |
284 |
- <a href="<%= url_for('/commits/master') %>"><div class="code_menu_commits">Commits</div></a> |
|
284 |
+ <a href="<%= url_for("/$user/$repository/commits/master") %>"><div class="code_menu_commits">Commits</div></a> |
|
285 | 285 |
<a href="<%= url_for('/branches') %> %>"><div class="code_menu_branches">Branches</div></a> |
286 | 286 |
</div> |
287 | 287 |
<div class="code_menu_right"> |