Showing 5 changed files with 215 additions and 146 deletions
+3
lib/Gitprep.pm
... ...
@@ -93,6 +93,9 @@ sub startup {
93 93
   # Branches
94 94
   $r->get('/:user/:repository/branches')->to('#branches');
95 95
 
96
+  # Tags
97
+  $r->get('/:user/:repository/tags')->to('#new_tags');
98
+
96 99
   # Projects
97 100
   $r->get('/(*home)/projects')->to('#projects')->name('projects');
98 101
   
+157 -141
lib/Gitprep/Main.pm
... ...
@@ -321,121 +321,6 @@ sub commitdiff {
321 321
   }
322 322
 }
323 323
 
324
-sub heads {
325
-  my $self = shift;
326
-  
327
-  # Parameters
328
-  my $project_ns = $self->param('project');
329
-  my $project = "/$project_ns";
330
-  my $home_ns = dirname $project_ns;
331
-  my $home = "/$home_ns";
332
-  
333
-  # Git
334
-  my $git = $self->app->git;
335
-  
336
-  # Ref names
337
-  my $heads  = $git->heads($project);
338
-  
339
-  # Render
340
-  $self->render(
341
-    home => $home,
342
-    home_ns => $home_ns,
343
-    project => $project,
344
-    project_ns => $project_ns,
345
-    heads => $heads,
346
-  );
347
-}
348
-
349
-sub branches {
350
-  my $self = shift;
351
-
352
-  # API
353
-  my $api = Gitprep::API->new($self);
354
-
355
-  my $user = $self->param('user');
356
-  my $repository = $self->param('repository');
357
-
358
-  my $root_ns = $api->root_ns($self->config->{root});
359
-  
360
-  # Parameters
361
-  my $project_ns = "$root_ns/$user/$repository.git";
362
-  my $project = "/$project_ns";
363
-  my $home_ns = $api->dirname($project_ns);
364
-  my $home = "/$home_ns";
365
-  
366
-  # Git
367
-  my $git = $self->app->git;
368
-  
369
-  # Ref names
370
-  my $heads  = $git->heads($project);
371
-  
372
-  # Render
373
-  $self->render(
374
-    home => $home,
375
-    home_ns => $home_ns,
376
-    project => $project,
377
-    project_ns => $project_ns,
378
-    heads => $heads,
379
-  );
380
-}
381
-
382
-=pod
383
-sub commits {
384
-  my ($self, %opt) = @_;
385
-  
386
-  # API
387
-  my $api = Gitprep::API->new($self);
388
-  
389
-  my $user = $self->param('user');
390
-  my $repository = $self->param('repository');
391
-
392
-  my $root_ns = $api->root_ns($self->config->{root});
393
-  
394
-  # Parameters
395
-  my $project_ns = "$root_ns/$user/$repository.git";
396
-  my $project = "/$project_ns";
397
-  my $home_ns = dirname $project_ns;
398
-  my $home = "/$home_ns";
399
-  my $id = $self->param('id');
400
-  my $page = $self->param('page');
401
-  $page = 0 if !defined $page;
402
-  my $short = $self->param('short');
403
-  
404
-  # Git
405
-  my $git = $self->app->git;
406
-  
407
-  # Commit
408
-  my $commit = $git->parse_commit($project, $id);
409
-  
410
-  # Commits
411
-  my $page_count = $short ? 50 : 20;
412
-  my $commits = $git->parse_commits(
413
-    $project, $commit->{id},$page_count, $page_count * $page);
414
-  for my $commit (@$commits) {
415
-    my $author_date
416
-      = $git->parse_date($commit->{author_epoch}, $commit->{author_tz});
417
-    $commit->{author_date} = $git->timestamp($author_date);
418
-  }
419
-  
420
-  # References
421
-  my $refs = $git->references($project);
422
-
423
-  # Render
424
-  $self->stash->{action} = 'shortlog' if $short;
425
-  $self->render(
426
-    home => $home,
427
-    home_ns => $home_ns,
428
-    project => $project,
429
-    project_ns => $project_ns,
430
-    id => $id,
431
-    commits => $commits,
432
-    refs => $refs,
433
-    page => $page,
434
-    page_count => $page_count
435
-  );
436
-};
437
-=cut
438
-
439 324
 sub _root_ns {
440 325
   my $self = shift;
441 326
   
... ...
@@ -580,31 +465,6 @@ sub tag {
580 465
   );
581 466
 }
582 467
 
583
-sub tags {
584
-  my $self = shift;
585
-  
586
-  # Parameters
587
-  my $project_ns = $self->param('project');
588
-  my $project = "/$project_ns";
589
-  my $home_ns = dirname $project_ns;
590
-  my $home = "/$home_ns";
591
-  
592
-  # Git
593
-  my $git = $self->app->git;
594
-  
595
-  # Ref names
596
-  my $tags  = $git->tags($project);
597
-  
598
-  # Render
599
-  $self->render(
600
-    home => $home,
601
-    home_ns => $home_ns,
602
-    project => $project,
603
-    project_ns => $project_ns,
604
-    tags => $tags,
605
-  );
606
-}
607
-
608 468
 sub tree {
609 469
   my $self = shift;
610 470
   
... ...
@@ -732,9 +592,22 @@ sub _quote_command {
732 592
     map { my $a = $_; $a =~ s/(['!])/'\\$1'/g; "'$a'" } @_ );
733 593
 }
734 594
 
735
-#---- No need ----#
736 595
 
737 596
 
597
+
598
+
599
+
600
+
601
+
602
+
603
+
604
+
605
+
606
+
607
+
608
+
609
+
610
+#---------- No need -------------#
738 611
 sub log {
739 612
   my ($self, %opt) = @_;
740 613
 
... ...
@@ -782,4 +655,147 @@ sub log {
782 655
   );
783 656
 };
784 657
 
658
+sub tags {
659
+  my $self = shift;
660
+  
661
+  # Parameters
662
+  my $project_ns = $self->param('project');
663
+  my $project = "/$project_ns";
664
+  my $home_ns = dirname $project_ns;
665
+  my $home = "/$home_ns";
666
+  
667
+  # Git
668
+  my $git = $self->app->git;
669
+  
670
+  # Ref names
671
+  my $tags  = $git->tags($project);
672
+  
673
+  # Render
674
+  $self->render(
675
+    home => $home,
676
+    home_ns => $home_ns,
677
+    project => $project,
678
+    project_ns => $project_ns,
679
+    tags => $tags,
680
+  );
681
+}
682
+
683
+=pod
684
+sub branches {
685
+  my $self = shift;
686
+
687
+  # API
688
+  my $api = Gitprep::API->new($self);
689
+
690
+  my $user = $self->param('user');
691
+  my $repository = $self->param('repository');
692
+
693
+  my $root_ns = $api->root_ns($self->config->{root});
694
+  
695
+  # Parameters
696
+  my $project_ns = "$root_ns/$user/$repository.git";
697
+  my $project = "/$project_ns";
698
+  my $home_ns = $api->dirname($project_ns);
699
+  my $home = "/$home_ns";
700
+  
701
+  # Git
702
+  my $git = $self->app->git;
703
+  
704
+  # Ref names
705
+  my $heads  = $git->heads($project);
706
+  
707
+  # Render
708
+  $self->render(
709
+    home => $home,
710
+    home_ns => $home_ns,
711
+    project => $project,
712
+    project_ns => $project_ns,
713
+    heads => $heads,
714
+  );
715
+}
716
+
717
+=cut
718
+
719
+=pod
720
+sub commits {
721
+  my ($self, %opt) = @_;
722
+  
723
+  # API
724
+  my $api = Gitprep::API->new($self);
725
+  
726
+  my $user = $self->param('user');
727
+  my $repository = $self->param('repository');
728
+
729
+  my $root_ns = $api->root_ns($self->config->{root});
730
+  
731
+  # Parameters
732
+  my $project_ns = "$root_ns/$user/$repository.git";
733
+  my $project = "/$project_ns";
734
+  my $home_ns = dirname $project_ns;
735
+  my $home = "/$home_ns";
736
+  my $id = $self->param('id');
737
+  my $page = $self->param('page');
738
+  $page = 0 if !defined $page;
739
+  my $short = $self->param('short');
740
+  
741
+  # Git
742
+  my $git = $self->app->git;
743
+  
744
+  # Commit
745
+  my $commit = $git->parse_commit($project, $id);
746
+  
747
+  # Commits
748
+  my $page_count = $short ? 50 : 20;
749
+  my $commits = $git->parse_commits(
750
+    $project, $commit->{id},$page_count, $page_count * $page);
751
+  for my $commit (@$commits) {
752
+    my $author_date
753
+      = $git->parse_date($commit->{author_epoch}, $commit->{author_tz});
754
+    $commit->{author_date} = $git->timestamp($author_date);
755
+  }
756
+  
757
+  # References
758
+  my $refs = $git->references($project);
759
+
760
+  # Render
761
+  $self->stash->{action} = 'shortlog' if $short;
762
+  $self->render(
763
+    home => $home,
764
+    home_ns => $home_ns,
765
+    project => $project,
766
+    project_ns => $project_ns,
767
+    id => $id,
768
+    commits => $commits,
769
+    refs => $refs,
770
+    page => $page,
771
+    page_count => $page_count
772
+  );
773
+};
774
+=cut
775
+
776
+sub heads {
777
+  my $self = shift;
778
+  
779
+  # Parameters
780
+  my $project_ns = $self->param('project');
781
+  my $project = "/$project_ns";
782
+  my $home_ns = dirname $project_ns;
783
+  my $home = "/$home_ns";
784
+  
785
+  # Git
786
+  my $git = $self->app->git;
787
+  
788
+  # Ref names
789
+  my $heads  = $git->heads($project);
790
+  
791
+  # Render
792
+  $self->render(
793
+    home => $home,
794
+    home_ns => $home_ns,
795
+    project => $project,
796
+    project_ns => $project_ns,
797
+    heads => $heads,
798
+  );
799
+}
800
+
785 801
 1;
+25 -3
templates/main/branches.html.ep
... ...
@@ -1,8 +1,30 @@
1
+<%
2
+  use Gitprep::API;
3
+  
4
+  # API
5
+  my $api = Gitprep::API->new($self);
6
+
7
+  my $user = param('user');
8
+  my $repository = param('repository');
9
+
10
+  my $root_ns = $api->root_ns(config->{root});
11
+  
12
+  # Parameters
13
+  my $project_ns = "$root_ns/$user/$repository.git";
14
+  my $project = "/$project_ns";
15
+  my $home_ns = $api->dirname($project_ns);
16
+  my $home = "/$home_ns";
17
+  
18
+  # Git
19
+  my $git = $self->app->git;
20
+  
21
+  # Ref names
22
+  my $heads  = $git->heads($project);
23
+%>
24
+
1 25
 % layout 'common';
2 26
   %= include '/include/header', title => 'Branches', project => $project;
3
-  %= include '/include/current_directory', home_ns => $home_ns, home => $home;
4
-  %= include '/include/page_navi', project_ns => $project_ns, current => 'heads';
5 27
   <div class="header">
6
-    <a class="title" href="<%= url_for('heads', project => $project_ns) %>">Heads</a>
28
+    <a class="title" href="<%= url_for('heads', project => $project_ns) %>">Branches</a>
7 29
   </div>
8 30
   %= include '/include/heads', project_ns => $project_ns, heads => $heads;
+28
templates/main/new_tags.html.ep
... ...
@@ -0,0 +1,28 @@
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
+  
16
+  # Git
17
+  my $git = $self->app->git;
18
+  
19
+  # Ref names
20
+  my $tags  = $git->tags($project);
21
+%>
22
+
23
+% layout 'common';
24
+  %= include '/include/header', title => 'Tags', project => $project;
25
+  <div class="header">
26
+    <a class="title" href="<%= url_for('tags', project => $project_ns) %>">Tags</a>
27
+  </div>
28
+  %= include '/include/tags', home => $home, project_ns => $project_ns, tags => $tags;
+2 -2
templates/main/repository.html.ep
... ...
@@ -285,8 +285,8 @@
285 285
         <a href="<%= url_for("/$user/$repository/branches") %>"><div class="code_menu_branches">Branches</div></a>
286 286
       </div>
287 287
       <div class="code_menu_right">
288
-        <a href="<%= url_for('/tags') %>"><div class="code_menu_downloads"><s>Downloads</s></div></a>
289
-        <a href="<%= url_for('/downloads') %>"><div class="code_menu_tags">Tags</div></a>
288
+        <a href="<%= url_for("/$user/$repository/downloads") %>"><div class="code_menu_downloads"><s>Downloads</s></div></a>
289
+        <a href="<%= url_for("/$user/$repository/tags") %>"><div class="code_menu_tags">Tags</div></a>
290 290
       </div>
291 291
     </div>
292 292