Showing 11 changed files with 557 additions and 1235 deletions
+4 -37
lib/Gitprep.pm
... ...
@@ -88,7 +88,7 @@ sub startup {
88 88
   $r->get('/:user/:repository')->to('#repository');
89 89
   
90 90
   # Commit
91
-  $r->get('/:user/:repository/commit/:id')->to('#new_commit');
91
+  $r->get('/:user/:repository/commit/:id')->to('#commit');
92 92
   
93 93
   # Commits
94 94
   $r->get('/:user/:repository/commits/(:id)', {id => 'HEAD'})->to('#commits');
... ...
@@ -97,16 +97,16 @@ sub startup {
97 97
   $r->get('/:user/:repository/branches')->to('#branches');
98 98
 
99 99
   # Tags
100
-  $r->get('/:user/:repository/tags')->to('#new_tags');
100
+  $r->get('/:user/:repository/tags')->to('#tags');
101 101
 
102 102
   # Downloads
103 103
   $r->get('/:user/:repository/downloads')->to('#downloads');
104 104
   
105 105
   # Tree
106
-  $r->get('/:user/:repository/tree/(*id_dir)')->to('#new_tree');
106
+  $r->get('/:user/:repository/tree/(*id_dir)')->to('#tree');
107 107
   
108 108
   # Blob
109
-  $r->get('/:user/:repository/blob/(*id_file)')->to('#new_blob');
109
+  $r->get('/:user/:repository/blob/(*id_file)')->to('#blob');
110 110
 
111 111
   # Projects
112 112
   $r->get('/(*home)/projects')->to('#projects')->name('projects');
... ...
@@ -115,19 +115,6 @@ sub startup {
115 115
   {
116 116
     my $r = $r->route('/(*project)', project => qr/.+?\.git/);
117 117
     
118
-    # Summary
119
-    $r->get('/summary')->to('#summary')->name('summary');
120
-    
121
-    # Short log
122
-    $r->get('/shortlog/(*id)', {id => 'HEAD'})
123
-      ->to('#log', short => 1)->name('shortlog');
124
-    
125
-    # Log
126
-    $r->get('/log/(*id)', {id => 'HEAD'})->to('#log')->name('log');
127
-    
128
-    # Commit
129
-    $r->get('/commit/(*id)')->to('#commit')->name('commit');
130
-    
131 118
     # Commit diff
132 119
     $r->get('/commitdiff/(*diff)')->to('#commitdiff')->name('commitdiff');
133 120
     
... ...
@@ -135,22 +122,6 @@ sub startup {
135 122
     $r->get('/commitdiff-plain/(*diff)')
136 123
       ->to('#commitdiff', plain => 1)->name('commitdiff_plain');
137 124
     
138
-    # Tags
139
-    $r->get('/tags')->to('#tags')->name('tags');
140
-    
141
-    # Tag
142
-    $r->get('/tag/(*id)')->to('#tag')->name('tag');
143
-    
144
-    # Heads
145
-    $r->get('/heads')->to('#heads')->name('heads');
146
-    
147
-    # Tree
148
-    $r->get('/tree/(*id_dir)', {id_dir => 'HEAD'})
149
-      ->to('#tree')->name('tree');
150
-    
151
-    # Blob
152
-    $r->get('/blob/(*id_file)')->to('#blob')->name('blob');
153
-    
154 125
     # Blob plain
155 126
     $r->get('/blob-plain/(*id_file)')
156 127
       ->to('#blob', plain => 1)->name('blob_plain');
... ...
@@ -162,10 +133,6 @@ sub startup {
162 133
     # Blob diff plain
163 134
     $r->get('/blobdiff-plain/(#diff)/(*file)')
164 135
       ->to('#blobdiff', plain => 1)->name('blobdiff_plain');
165
-    
166
-    # Snapshot
167
-    $r->get('/snapshot/(:id)', {id => 'HEAD'})
168
-      ->to('#snapshot')->name('snapshot');
169 136
   }
170 137
   
171 138
   # File cache
-410
lib/Gitprep/Main.pm
... ...
@@ -388,414 +388,4 @@ sub _quote_command {
388 388
     map { my $a = $_; $a =~ s/(['!])/'\\$1'/g; "'$a'" } @_ );
389 389
 }
390 390
 
391
-
392
-
393
-
394
-
395
-
396
-
397
-
398
-
399
-
400
-
401
-
402
-
403
-
404
-
405
-
406
-#---------- No need -------------#
407
-sub log {
408
-  my ($self, %opt) = @_;
409
-
410
-  # Parameters
411
-  my $project_ns = $self->param('project');
412
-  my $project = "/$project_ns";
413
-  my $home_ns = dirname $project_ns;
414
-  my $home = "/$home_ns";
415
-  my $id = $self->param('id');
416
-  my $page = $self->param('page');
417
-  $page = 0 if !defined $page;
418
-  my $short = $self->param('short');
419
-  
420
-  # Git
421
-  my $git = $self->app->git;
422
-  
423
-  # Commit
424
-  my $commit = $git->parse_commit($project, $id);
425
-  
426
-  # Commits
427
-  my $page_count = $short ? 50 : 20;
428
-  my $commits = $git->parse_commits(
429
-    $project, $commit->{id},$page_count, $page_count * $page);
430
-  for my $commit (@$commits) {
431
-    my $author_date
432
-      = $git->parse_date($commit->{author_epoch}, $commit->{author_tz});
433
-    $commit->{author_date} = $git->timestamp($author_date);
434
-  }
435
-  
436
-  # References
437
-  my $refs = $git->references($project);
438
-
439
-  # Render
440
-  $self->stash->{action} = 'shortlog' if $short;
441
-  $self->render(
442
-    home => $home,
443
-    home_ns => $home_ns,
444
-    project => $project,
445
-    project_ns => $project_ns,
446
-    id => $id,
447
-    commits => $commits,
448
-    refs => $refs,
449
-    page => $page,
450
-    page_count => $page_count
451
-  );
452
-};
453
-
454
-sub tags {
455
-  my $self = shift;
456
-  
457
-  # Parameters
458
-  my $project_ns = $self->param('project');
459
-  my $project = "/$project_ns";
460
-  my $home_ns = dirname $project_ns;
461
-  my $home = "/$home_ns";
462
-  
463
-  # Git
464
-  my $git = $self->app->git;
465
-  
466
-  # Ref names
467
-  my $tags  = $git->tags($project);
468
-  
469
-  # Render
470
-  $self->render(
471
-    home => $home,
472
-    home_ns => $home_ns,
473
-    project => $project,
474
-    project_ns => $project_ns,
475
-    tags => $tags,
476
-  );
477
-}
478
-
479
-=pod
480
-sub branches {
481
-  my $self = shift;
482
-
483
-  # API
484
-  my $api = Gitprep::API->new($self);
485
-
486
-  my $user = $self->param('user');
487
-  my $repository = $self->param('repository');
488
-
489
-  my $root_ns = $api->root_ns($self->config->{root});
490
-  
491
-  # Parameters
492
-  my $project_ns = "$root_ns/$user/$repository.git";
493
-  my $project = "/$project_ns";
494
-  my $home_ns = $api->dirname($project_ns);
495
-  my $home = "/$home_ns";
496
-  
497
-  # Git
498
-  my $git = $self->app->git;
499
-  
500
-  # Ref names
501
-  my $heads  = $git->heads($project);
502
-  
503
-  # Render
504
-  $self->render(
505
-    home => $home,
506
-    home_ns => $home_ns,
507
-    project => $project,
508
-    project_ns => $project_ns,
509
-    heads => $heads,
510
-  );
511
-}
512
-
513
-=cut
514
-
515
-=pod
516
-sub commits {
517
-  my ($self, %opt) = @_;
518
-  
519
-  # API
520
-  my $api = Gitprep::API->new($self);
521
-  
522
-  my $user = $self->param('user');
523
-  my $repository = $self->param('repository');
524
-
525
-  my $root_ns = $api->root_ns($self->config->{root});
526
-  
527
-  # Parameters
528
-  my $project_ns = "$root_ns/$user/$repository.git";
529
-  my $project = "/$project_ns";
530
-  my $home_ns = dirname $project_ns;
531
-  my $home = "/$home_ns";
532
-  my $id = $self->param('id');
533
-  my $page = $self->param('page');
534
-  $page = 0 if !defined $page;
535
-  my $short = $self->param('short');
536
-  
537
-  # Git
538
-  my $git = $self->app->git;
539
-  
540
-  # Commit
541
-  my $commit = $git->parse_commit($project, $id);
542
-  
543
-  # Commits
544
-  my $page_count = $short ? 50 : 20;
545
-  my $commits = $git->parse_commits(
546
-    $project, $commit->{id},$page_count, $page_count * $page);
547
-  for my $commit (@$commits) {
548
-    my $author_date
549
-      = $git->parse_date($commit->{author_epoch}, $commit->{author_tz});
550
-    $commit->{author_date} = $git->timestamp($author_date);
551
-  }
552
-  
553
-  # References
554
-  my $refs = $git->references($project);
555
-
556
-  # Render
557
-  $self->stash->{action} = 'shortlog' if $short;
558
-  $self->render(
559
-    home => $home,
560
-    home_ns => $home_ns,
561
-    project => $project,
562
-    project_ns => $project_ns,
563
-    id => $id,
564
-    commits => $commits,
565
-    refs => $refs,
566
-    page => $page,
567
-    page_count => $page_count
568
-  );
569
-};
570
-=cut
571
-
572
-sub heads {
573
-  my $self = shift;
574
-  
575
-  # Parameters
576
-  my $project_ns = $self->param('project');
577
-  my $project = "/$project_ns";
578
-  my $home_ns = dirname $project_ns;
579
-  my $home = "/$home_ns";
580
-  
581
-  # Git
582
-  my $git = $self->app->git;
583
-  
584
-  # Ref names
585
-  my $heads  = $git->heads($project);
586
-  
587
-  # Render
588
-  $self->render(
589
-    home => $home,
590
-    home_ns => $home_ns,
591
-    project => $project,
592
-    project_ns => $project_ns,
593
-    heads => $heads,
594
-  );
595
-}
596
-
597
-sub commit {
598
-  my $self = shift;
599
-
600
-  # Parameters
601
-  my $project_ns = $self->param('project');
602
-  my $project = "/$project_ns";
603
-  my $home_ns = dirname $project_ns;
604
-  my $home = "/$home_ns";
605
-  my $id = $self->param('id');
606
-  
607
-  # Git
608
-  my $git = $self->app->git;
609
-
610
-  # Commit
611
-  my $commit = $git->parse_commit($project, $id);
612
-  my $committer_date
613
-    = $git->parse_date($commit->{committer_epoch}, $commit->{committer_tz});
614
-  my $author_date
615
-    = $git->parse_date($commit->{author_epoch}, $commit->{author_tz});
616
-  $commit->{author_date} = $git->timestamp($author_date);
617
-  $commit->{committer_date} = $git->timestamp($committer_date);
618
-  
619
-  # References
620
-  my $refs = $git->references($project);
621
-  
622
-  # Diff tree
623
-  my $parent = $commit->{parent};
624
-  my $parents = $commit->{parents};
625
-  my $difftrees = $git->difftree($project, $commit->{id}, $parent, $parents);
626
-  
627
-  # Render
628
-  $self->render(
629
-    home => $home,
630
-    home_ns => $home_ns,
631
-    project => $project,
632
-    project_ns => $project_ns,
633
-    id => $id,
634
-    commit => $commit,
635
-    refs => $refs,
636
-    difftrees => $difftrees,
637
-  );
638
-}
639
-
640
-sub tree {
641
-  my $self = shift;
642
-  
643
-  # Parameters
644
-  my $project_ns = $self->param('project');
645
-  my $project = "/$project_ns";
646
-  my $home_ns = dirname $project_ns;
647
-  my $home = "/$home_ns";
648
-  my $id_dir = $self->param('id_dir');
649
-
650
-  # Id and directory
651
-  my ($id, $dir) = $self->_parse_id_path($project, $id_dir);
652
-
653
-  # Git
654
-  my $git = $self->app->git;
655
-  
656
-  # Tree id
657
-  my $tid;
658
-  my $commit = $git->parse_commit($project, $id);
659
-  unless (defined $tid) {
660
-    if (defined $dir && $dir ne '') {
661
-      $tid = $git->id_by_path($project, $id, $dir, 'tree');
662
-    }
663
-    else { $tid = $commit->{tree} }
664
-  }
665
-  $self->render_not_found unless defined $tid;
666
-
667
-  # Get tree (command "git ls-tree")
668
-  my @entries = ();
669
-  my $show_sizes = 0;
670
-  open my $fh, '-|', $git->cmd($project), 'ls-tree', '-z',
671
-      ($show_sizes ? '-l' : ()), $tid
672
-    or croak 'Open git-ls-tree failed';
673
-  local $/ = "\0";
674
-  @entries = map { chomp; $git->dec($_) } <$fh>;
675
-  close $fh
676
-    or croak 404, "Reading tree failed";
677
-  
678
-  # Parse tree
679
-  my @trees;
680
-  for my $line (@entries) {
681
-    my $tree = $git->parse_ls_tree_line($line, -z => 1, -l => $show_sizes);
682
-    $tree->{mode_str} = $git->_mode_str($tree->{mode});
683
-    push @trees, $tree;
684
-  }
685
-  
686
-  # References
687
-  my $refs = $git->references($project);
688
-  
689
-  # Render
690
-  $self->render(
691
-    home => $home,
692
-    home_ns => $home_ns,
693
-    project => $project,
694
-    project_ns => $project_ns,
695
-    dir => $dir,
696
-    id => $id,
697
-    tid => $tid,
698
-    commit => $commit,
699
-    trees => \@trees,
700
-    refs => $refs
701
-  );
702
-}
703
-
704
-sub blob {
705
-  my $self = shift;
706
-
707
-  # Parameters
708
-  my $project_ns = $self->param('project');
709
-  my $project = "/$project_ns";
710
-  my $home_ns = dirname $project_ns;
711
-  my $home = "/$home_ns";
712
-  my $id_file = $self->param('id_file');
713
-
714
-  # Id and file
715
-  my ($id, $file) = $self->_parse_id_path($project, $id_file);
716
-
717
-  # Git
718
-  my $git = $self->app->git;
719
-
720
-  # Blob content
721
-  my $bid = $git->id_by_path($project, $id, $file, 'blob')
722
-    or croak 'Cannot find file';
723
-  my @cmd = ($git->cmd($project), 'cat-file', 'blob', $bid);
724
-  open my $fh, '-|', @cmd
725
-    or croak qq/Couldn't cat "$file", "$bid"/;
726
-  
727
-  # Blob plain
728
-  if ($self->stash('plain')) {
729
-    # Content type
730
-    my $type = $git->blob_contenttype($fh, $file);
731
-
732
-    # Convert text/* content type to text/plain
733
-    if ($self->config('prevent_xss') &&
734
-      ($type =~ m#^text/[a-z]+\b(.*)$# ||
735
-      ($type =~ m#^[a-z]+/[a-z]\+xml\b(.*)$# && -T $fh)))
736
-    {
737
-      my $rest = $1;
738
-      $rest = defined $rest ? $rest : '';
739
-      $type = "text/plain$rest";
740
-    }
741
-
742
-    # File name
743
-    my $file_name = $id;
744
-    if (defined $file) { $file_name = $file }
745
-    elsif ($type =~ m/^text\//) { $file_name .= '.txt' }
746
-    
747
-    # Content
748
-    my $content = do { local $/; <$fh> };
749
-    my $sandbox = $self->config('prevent_xss') &&
750
-      $type !~ m#^(?:text/[a-z]+|image/(?:gif|png|jpeg))(?:[ ;]|$)#;
751
-    my $content_disposition = $sandbox ? 'attachment' : 'inline';
752
-    $content_disposition .= "; filename=$file_name";
753
-    
754
-    # Render
755
-    $self->res->headers->content_disposition($content_disposition);
756
-    $self->res->headers->content_type($type);
757
-    $self->render_data($content);
758
-  }
759
-  
760
-  # Blob
761
-  else {
762
-    # MIME type
763
-    my $mimetype = $git->blob_mimetype($fh, $file);
764
-    
765
-    # Redirect to blob-plain if no display MIME type
766
-    if ($mimetype !~ m#^(?:text/|image/(?:gif|png|jpeg)$)# && -B $fh) {
767
-      close $fh;
768
-      my $url = $self->url_for('blob_plain',
769
-        project => $project_ns, id_file => "$id/$file");
770
-      
771
-      return $self->redirect_to($url);
772
-    }
773
-    
774
-    # Commit
775
-    my $commit = $git->parse_commit($project, $id);
776
-
777
-    # Parse line
778
-    my @lines;
779
-    while (my $line = $git->dec(scalar <$fh>)) {
780
-      chomp $line;
781
-      $line = $git->_tab_to_space($line);
782
-      push @lines, $line;
783
-    }
784
-    
785
-    # Render
786
-    $self->render(
787
-      home => $home,
788
-      home_ns => $home_ns,
789
-      project => $project,
790
-      project_ns => $project_ns,
791
-      commit => $commit,
792
-      id => $id,
793
-      file => $file,
794
-      bid => $bid,
795
-      lines => \@lines,
796
-      mimetype => $mimetype
797
-    );
798
-  }
799
-}
800
-
801 391
 1;
+3 -1
templates/include/header.html.ep
... ...
@@ -43,7 +43,9 @@
43 43
         <a href="<%= url_for("/setting/profile") %>"><s>Account setting</s></a>
44 44
       </li>
45 45
       <li><a href="<%= url_for("/new") %>"><s>Create a new repo</s></a></li>
46
-      <li><a href="<%= url_for("/$user") %>"><%= $user %></a></li>
46
+      % if (my $user = stash('user')) {
47
+        <li><a href="<%= url_for("/$user") %>"><%= $user %></a></li>
48
+      % }
47 49
     </ul>
48 50
   </div>
49 51
 </div>
+149 -35
templates/main/blob.html.ep
... ...
@@ -1,40 +1,154 @@
1
-% layout 'common';
2
-  %= include '/include/header', title => 'Blob', project => $project;
3
-  %= include '/include/current_directory', home_ns => $home_ns, home => $home;
4
-  %= include '/include/page_navi', current => 'blob', head_id => $id, project_ns => $project_ns;
5
-  <div class="page_nav">
6
-    <a href="<%= url_for('blob_plain', project => $project_ns, id_file => "$id/$file") %>">
7
-      Raw
8
-    </a>
9
-    |
10
-    % my $head_id = gitprep_get_head_id($project);
11
-    <a href="<%= url_for('blob', project => $project_ns, id_file => "HEAD/$file") %>">
12
-      HEAD
13
-    </a>
14
-    <br/>
15
-  </div>
16
-  <div class="header">
17
-  <a class="title" href= "<%= url_for('commit', project => $project_ns, id => $id) %>">
18
-    <%= $commit->{title} %>
19
-  </a>
20
-  </div>
1
+<%
2
+  # API
3
+  my $api = Gitprep::API->new($self);
4
+  
5
+  my $user = param('user');
6
+  my $repository = param('repository');
7
+  my $plain = param('plain');
8
+
9
+  my $root_ns = $api->root_ns(config->{root});
10
+  
11
+  # Parameters
12
+  my $rep_ns = "$root_ns/$user/$repository.git";
13
+  my $rep = "/$rep_ns";
14
+  my $home_ns = $api->dirname($rep_ns);
15
+  my $home = "/$home_ns";
16
+  my $id_file = param('id_file');
17
+
18
+  # Id and file
19
+  my ($id, $file) = $api->parse_id_path($rep, $id_file);
20
+
21
+  # Git
22
+  my $git = $self->app->git;
23
+  
24
+  # Commit
25
+  my $commit_log = $git->latest_commit_log($rep, $id, $file);
26
+  
27
+  # Blob content
28
+  my $bid = $git->id_by_path($rep, $id, $file, 'blob')
29
+    or $api->croak('Cannot find file');
30
+  my @cmd = ($git->cmd($rep), 'cat-file', 'blob', $bid);
31
+  open my $fh, '-|', @cmd
32
+    or $api->croak(qq/Couldn't cat "$file", "$bid"/);
33
+  
34
+  # Blob plain
35
+  my $commit;
36
+  my $mimetype;
37
+  my $lines =[];
38
+  if ($plain) {
39
+    # Content type
40
+    my $type = $git->blob_contenttype($fh, $file);
41
+
42
+    # Convert text/* content type to text/plain
43
+    if ($self->config('prevent_xss') &&
44
+      ($type =~ m#^text/[a-z]+\b(.*)$# ||
45
+      ($type =~ m#^[a-z]+/[a-z]\+xml\b(.*)$# && -T $fh)))
46
+    {
47
+      my $rest = $1;
48
+      $rest = defined $rest ? $rest : '';
49
+      $type = "text/plain$rest";
50
+    }
51
+
52
+    # File name
53
+    my $file_name = $id;
54
+    if (defined $file) { $file_name = $file }
55
+    elsif ($type =~ m/^text\//) { $file_name .= '.txt' }
56
+    
57
+    # Content
58
+    my $content = do { local $/; <$fh> };
59
+    my $sandbox = $self->config('prevent_xss') &&
60
+      $type !~ m#^(?:text/[a-z]+|image/(?:gif|png|jpeg))(?:[ ;]|$)#;
61
+    my $content_disposition = $sandbox ? 'attachment' : 'inline';
62
+    $content_disposition .= "; filename=$file_name";
63
+    
64
+    # Render
65
+    $self->res->headers->content_disposition($content_disposition);
66
+    $self->res->headers->content_type($type);
67
+    $self->render_data($content);
68
+  }
69
+  
70
+  # Blob
71
+  else {
72
+    # MIME type
73
+    $mimetype = $git->blob_mimetype($fh, $file);
74
+    
75
+    # Redirect to blob-plain if no display MIME type
76
+    if ($mimetype !~ m#^(?:text/|image/(?:gif|png|jpeg)$)# && -B $fh) {
77
+      close $fh;
78
+      my $url = $self->url_for('blob_plain',
79
+        project => $rep_ns, id_file => "$id/$file");
80
+      
81
+      return $self->redirect_to($url);
82
+    }
83
+    
84
+    # Commit
85
+    $commit = $git->parse_commit($rep, $id);
86
+
87
+    # Parse line
88
+    while (my $line = $git->dec(scalar <$fh>)) {
89
+      chomp $line;
90
+      $line = $git->_tab_to_space($line);
91
+      push @$lines, $line;
92
+    }
93
+  }
94
+  
95
+  # Global variable
96
+  stash(id => $id);
97
+%>
98
+
99
+% layout 'new_common';
100
+  %= include '/css/common';
101
+  
102
+  %= stylesheet begin
103
+    
104
+  % end
105
+
106
+  %= include '/include/header';
107
+
108
+  <div class="main_panel">
109
+    %= include '/include/sub_header';
21 110
 
22
-  %= include '/include/page_path', project_ns => $project_ns, id => $id, Path => $file, type => 'blob';
111
+    %= include '/include/code_menu';
112
+    %= stylesheet begin
113
+      /* Code menu */
114
+      .code_menu_files {
115
+        border:1px solid #E5E5E5;
116
+        border-bottom:none;
117
+        background-color:white;
118
+        font-weight:bold;
119
+      }
120
+      .code_menu_files a {
121
+        color:#333
122
+      }
123
+    % end
23 124
 
24
-  <div class="page_body">
25
-    % if ($mimetype =~ m#^image/#) {
26
-      <img type="<%= $mimetype %>
27
-        % if (defined $file) {
28
-          alt="<%= $file %>" title="<%= $file %>"
125
+    %= include '/include/new_page_path', type => 'blob', Path => $file;
126
+    
127
+    <div>
128
+      <div>
129
+        <div><%= $commit_log->{author} %></div>
130
+        <div><%= $commit_log->{author_date} %></div>
131
+        <div><%= $commit_log->{comment} %></div>
132
+      </div>
133
+      <div></div>
134
+    </div>
135
+    
136
+    <div class="page_body">
137
+      % if ($mimetype =~ m#^image/#) {
138
+        <img type="<%= $mimetype %>
139
+          % if (defined $file) {
140
+            alt="<%= $file %>" title="<%= $file %>"
141
+          % }
142
+          src="<%= url_for('blob_plain', project => $rep_ns, id_file => "$id/$file") %>"
143
+        />
144
+      % } else {
145
+        % my $nr = 1;
146
+        % for my $line (@$lines) {
147
+          % my $nr4 = sprintf("%4i", $nr);
148
+          <div class="pre"><a id="l<%= $nr %>" href="<%#l<%= $nr %>" class="linenr"><%= $nr4 %></a> <%= $line %></div>
149
+          % $nr++;
29 150
         % }
30
-        src="<%= url_for('blob_plain', project => $project_ns, id_file => "$id/$file") %>"
31
-      />
32
-    % } else {
33
-      % my $nr = 1;
34
-      % for my $line (@$lines) {
35
-        % my $nr4 = sprintf("%4i", $nr);
36
-        <div class="pre"><a id="l<%= $nr %>" href="<%#l<%= $nr %>" class="linenr"><%= $nr4 %></a> <%= $line %></div>
37
-        % $nr++;
38 151
       % }
39
-    % }
152
+    </div>
40 153
   </div>
154
+  %= include '/include/footer';
+40 -3
templates/main/commit.html.ep
... ...
@@ -1,7 +1,44 @@
1
+<%
2
+  # API
3
+  my $api = Gitprep::API->new($self);
4
+  
5
+  my $user = param('user');
6
+  my $repository = param('repository');
7
+  my $id = param('id');
8
+
9
+  my $root_ns = $api->root_ns(config->{root});
10
+  
11
+  # Parameters
12
+  my $project_ns = "$root_ns/$user/$repository.git";
13
+  my $project = "/$project_ns";
14
+  my $home_ns = $api->dirname($project_ns);
15
+  my $home = "/$home_ns";
16
+  
17
+  # Git
18
+  my $git = $self->app->git;
19
+
20
+  # Commit
21
+  my $commit = $git->parse_commit($project, $id);
22
+  my $committer_date
23
+    = $git->parse_date($commit->{committer_epoch}, $commit->{committer_tz});
24
+  my $author_date
25
+    = $git->parse_date($commit->{author_epoch}, $commit->{author_tz});
26
+  $commit->{author_date} = $git->timestamp($author_date);
27
+  $commit->{committer_date} = $git->timestamp($committer_date);
28
+  
29
+  # References
30
+  my $refs = $git->references($project);
31
+  
32
+  # Diff tree
33
+  my $parent = $commit->{parent};
34
+  my $parents = $commit->{parents};
35
+  my $difftrees = $git->difftree($project, $commit->{id}, $parent, $parents);
36
+
37
+%>
38
+
1 39
 % layout 'common';
2 40
   %= include '/include/header', title => 'Commit', project => $project;
3 41
   %= include '/include/current_directory', home_ns => $home_ns, home => $home;
4
-  %= include '/include/page_navi', current => 'commit', project_ns => $project_ns, id => $commit->{id};
5 42
 
6 43
   <div class="page_nav">
7 44
     % my $parent = $commit->{parent};
... ...
@@ -41,7 +78,7 @@
41 78
     % }
42 79
   </div>
43 80
   <div class="title_text">
44
-    %= include 'include/refs', project => $project_ns, commit => $commit, refs => $refs;
81
+    %= include 'include/refs', project_ns => $project_ns, project => $project_ns, commit => $commit, refs => $refs;
45 82
     <table class="object_header">
46 83
       <tr>
47 84
         <td>author</td>
... ...
@@ -119,4 +156,4 @@
119 156
   <div class="list_head">
120 157
   </div>
121 158
   <%= include '/include/difftree', id => $commit->{id}, from_id => $from_id,
122
-    difftrees => $difftrees, parents => $commit->{parents} %>
159
+    difftrees => $difftrees, parents => $commit->{parents}, project_ns => $project_ns%>
-154
templates/main/new_blob.html.ep
... ...
@@ -1,154 +0,0 @@
1
-<%
2
-  # API
3
-  my $api = Gitprep::API->new($self);
4
-  
5
-  my $user = param('user');
6
-  my $repository = param('repository');
7
-  my $plain = param('plain');
8
-
9
-  my $root_ns = $api->root_ns(config->{root});
10
-  
11
-  # Parameters
12
-  my $rep_ns = "$root_ns/$user/$repository.git";
13
-  my $rep = "/$rep_ns";
14
-  my $home_ns = $api->dirname($rep_ns);
15
-  my $home = "/$home_ns";
16
-  my $id_file = param('id_file');
17
-
18
-  # Id and file
19
-  my ($id, $file) = $api->parse_id_path($rep, $id_file);
20
-
21
-  # Git
22
-  my $git = $self->app->git;
23
-  
24
-  # Commit
25
-  my $commit_log = $git->latest_commit_log($rep, $id, $file);
26
-  
27
-  # Blob content
28
-  my $bid = $git->id_by_path($rep, $id, $file, 'blob')
29
-    or $api->croak('Cannot find file');
30
-  my @cmd = ($git->cmd($rep), 'cat-file', 'blob', $bid);
31
-  open my $fh, '-|', @cmd
32
-    or $api->croak(qq/Couldn't cat "$file", "$bid"/);
33
-  
34
-  # Blob plain
35
-  my $commit;
36
-  my $mimetype;
37
-  my $lines =[];
38
-  if ($plain) {
39
-    # Content type
40
-    my $type = $git->blob_contenttype($fh, $file);
41
-
42
-    # Convert text/* content type to text/plain
43
-    if ($self->config('prevent_xss') &&
44
-      ($type =~ m#^text/[a-z]+\b(.*)$# ||
45
-      ($type =~ m#^[a-z]+/[a-z]\+xml\b(.*)$# && -T $fh)))
46
-    {
47
-      my $rest = $1;
48
-      $rest = defined $rest ? $rest : '';
49
-      $type = "text/plain$rest";
50
-    }
51
-
52
-    # File name
53
-    my $file_name = $id;
54
-    if (defined $file) { $file_name = $file }
55
-    elsif ($type =~ m/^text\//) { $file_name .= '.txt' }
56
-    
57
-    # Content
58
-    my $content = do { local $/; <$fh> };
59
-    my $sandbox = $self->config('prevent_xss') &&
60
-      $type !~ m#^(?:text/[a-z]+|image/(?:gif|png|jpeg))(?:[ ;]|$)#;
61
-    my $content_disposition = $sandbox ? 'attachment' : 'inline';
62
-    $content_disposition .= "; filename=$file_name";
63
-    
64
-    # Render
65
-    $self->res->headers->content_disposition($content_disposition);
66
-    $self->res->headers->content_type($type);
67
-    $self->render_data($content);
68
-  }
69
-  
70
-  # Blob
71
-  else {
72
-    # MIME type
73
-    $mimetype = $git->blob_mimetype($fh, $file);
74
-    
75
-    # Redirect to blob-plain if no display MIME type
76
-    if ($mimetype !~ m#^(?:text/|image/(?:gif|png|jpeg)$)# && -B $fh) {
77
-      close $fh;
78
-      my $url = $self->url_for('blob_plain',
79
-        project => $rep_ns, id_file => "$id/$file");
80
-      
81
-      return $self->redirect_to($url);
82
-    }
83
-    
84
-    # Commit
85
-    $commit = $git->parse_commit($rep, $id);
86
-
87
-    # Parse line
88
-    while (my $line = $git->dec(scalar <$fh>)) {
89
-      chomp $line;
90
-      $line = $git->_tab_to_space($line);
91
-      push @$lines, $line;
92
-    }
93
-  }
94
-  
95
-  # Global variable
96
-  stash(id => $id);
97
-%>
98
-
99
-% layout 'new_common';
100
-  %= include '/css/common';
101
-  
102
-  %= stylesheet begin
103
-    
104
-  % end
105
-
106
-  %= include '/include/header';
107
-
108
-  <div class="main_panel">
109
-    %= include '/include/sub_header';
110
-
111
-    %= include '/include/code_menu';
112
-    %= stylesheet begin
113
-      /* Code menu */
114
-      .code_menu_files {
115
-        border:1px solid #E5E5E5;
116
-        border-bottom:none;
117
-        background-color:white;
118
-        font-weight:bold;
119
-      }
120
-      .code_menu_files a {
121
-        color:#333
122
-      }
123
-    % end
124
-
125
-    %= include '/include/new_page_path', type => 'blob', Path => $file;
126
-    
127
-    <div>
128
-      <div>
129
-        <div><%= $commit_log->{author} %></div>
130
-        <div><%= $commit_log->{author_date} %></div>
131
-        <div><%= $commit_log->{comment} %></div>
132
-      </div>
133
-      <div></div>
134
-    </div>
135
-    
136
-    <div class="page_body">
137
-      % if ($mimetype =~ m#^image/#) {
138
-        <img type="<%= $mimetype %>
139
-          % if (defined $file) {
140
-            alt="<%= $file %>" title="<%= $file %>"
141
-          % }
142
-          src="<%= url_for('blob_plain', project => $rep_ns, id_file => "$id/$file") %>"
143
-        />
144
-      % } else {
145
-        % my $nr = 1;
146
-        % for my $line (@$lines) {
147
-          % my $nr4 = sprintf("%4i", $nr);
148
-          <div class="pre"><a id="l<%= $nr %>" href="<%#l<%= $nr %>" class="linenr"><%= $nr4 %></a> <%= $line %></div>
149
-          % $nr++;
150
-        % }
151
-      % }
152
-    </div>
153
-  </div>
154
-  %= include '/include/footer';
-159
templates/main/new_commit.html.ep
... ...
@@ -1,159 +0,0 @@
1
-<%
2
-  # API
3
-  my $api = Gitprep::API->new($self);
4
-  
5
-  my $user = param('user');
6
-  my $repository = param('repository');
7
-  my $id = param('id');
8
-
9
-  my $root_ns = $api->root_ns(config->{root});
10
-  
11
-  # Parameters
12
-  my $project_ns = "$root_ns/$user/$repository.git";
13
-  my $project = "/$project_ns";
14
-  my $home_ns = $api->dirname($project_ns);
15
-  my $home = "/$home_ns";
16
-  
17
-  # Git
18
-  my $git = $self->app->git;
19
-
20
-  # Commit
21
-  my $commit = $git->parse_commit($project, $id);
22
-  my $committer_date
23
-    = $git->parse_date($commit->{committer_epoch}, $commit->{committer_tz});
24
-  my $author_date
25
-    = $git->parse_date($commit->{author_epoch}, $commit->{author_tz});
26
-  $commit->{author_date} = $git->timestamp($author_date);
27
-  $commit->{committer_date} = $git->timestamp($committer_date);
28
-  
29
-  # References
30
-  my $refs = $git->references($project);
31
-  
32
-  # Diff tree
33
-  my $parent = $commit->{parent};
34
-  my $parents = $commit->{parents};
35
-  my $difftrees = $git->difftree($project, $commit->{id}, $parent, $parents);
36
-
37
-%>
38
-
39
-% layout 'common';
40
-  %= include '/include/header', title => 'Commit', project => $project;
41
-  %= include '/include/current_directory', home_ns => $home_ns, home => $home;
42
-
43
-  <div class="page_nav">
44
-    % my $parent = $commit->{parent};
45
-    % my $parents = $commit->{parents};
46
-    % my $from_id = $parent;
47
-    
48
-    % if (!defined $parent) {
49
-      (initial)
50
-    % }
51
-    % elsif (@$parents == 1) {
52
-      (
53
-        parent:
54
-        <a href="<%= url_for('commit', project => $project_ns, id => $parent) %>">
55
-          <%= substr($parent, 0, 7) %>
56
-        </a>
57
-      )
58
-    % } else {
59
-      (
60
-        merge:
61
-        % for my $parent (@$parents) {
62
-          <a href="<%= url_for('commit', project => $project_ns, id => $parent) %>">
63
-            <%= substr($parent, 0, 7) %></a>
64
-        % }
65
-      )
66
-    % }
67
-  </div>
68
-
69
-  <div class="header">
70
-    % if (defined $parent) {
71
-      <a class="title" href="<%= url_for('commitdiff', project => $project_ns, diff => $commit->{id}) %>">
72
-        <%= $commit->{title} %>
73
-      </a>
74
-    % } else {
75
-      <a class="title" href="<%= url_for('tree', project => $project_ns, id_dir => $commit->{id}) %>">
76
-        <%= $commit->{title} %>
77
-      </a>
78
-    % }
79
-  </div>
80
-  <div class="title_text">
81
-    %= include 'include/refs', project_ns => $project_ns, project => $project_ns, commit => $commit, refs => $refs;
82
-    <table class="object_header">
83
-      <tr>
84
-        <td>author</td>
85
-        <td><%= $commit->{author} %></td>
86
-        <td rowspan="2"></td>
87
-      </tr>
88
-      <tr>
89
-        <td></td>
90
-        <td><%= $commit->{author_date} %></td>
91
-      </tr>
92
-      <tr>
93
-        <td>committer</td>
94
-        <td><%= $commit->{committer} %></td>
95
-        <td rowspan="2"></td>
96
-      </tr>
97
-      <tr>
98
-        <td></td>
99
-        <td><%= $commit->{committer_date} %></td>
100
-      </tr>
101
-      <tr>
102
-        <td>commit</td>
103
-        <td class="sha1"><%= $commit->{id} %></td>
104
-      </tr>
105
-      <tr>
106
-        <td>tree</td>
107
-        <td class="sha1">
108
-          <a class="list" href="<%= url_for('tree', project => $project_ns, id_dir => $commit->{id}) %>">
109
-            <%= $commit->{id} %>
110
-          </a>
111
-        </td>
112
-        <td class="link">
113
-          <a href="<%= url_for('tree', project => $project_ns, id_dir => $commit->{id}) %>">
114
-            tree
115
-          </a>
116
-          |
117
-          <a title="in format: tar.gz" rel="nofollow"
118
-              href="<%= url_for('snapshot', project => $project_ns, id => $commit->{id}) %>">
119
-            snapshot
120
-          </a>
121
-        </td>
122
-      </tr>
123
-      % for my $parent (@$parents) {
124
-        % my $from_id = $parent;
125
-        <tr>
126
-          <td>
127
-            parent
128
-          </td>
129
-          <td class="sha1">
130
-            <a class="list" href="<%= url_for('commit', project => $project_ns, id => $from_id) %>">
131
-              <%= $from_id %>
132
-            </a>
133
-          </td>
134
-          <td class="link">
135
-            <a href="<%= url_for('commit', project => $project_ns, id => $from_id) %>">
136
-              commit
137
-            </a>
138
-            |
139
-            <a href="<%= url_for('commitdiff', project => $project_ns,
140
-                diff => "$from_id..$commit->{id}") %>">
141
-              diff
142
-            </a>
143
-          </td>
144
-        </tr>
145
-      % }
146
-    </table>
147
-  </div>
148
-  <div class="page_body">
149
-    <%= $commit->{title} %><br/>
150
-    <br/>
151
-    % for (my $i = 1; $i < @{$commit->{comment}}; $i++) {
152
-      &nbsp;<%= $commit->{comment}->[$i] %>
153
-      <br>
154
-    % }
155
-  </div>
156
-  <div class="list_head">
157
-  </div>
158
-  <%= include '/include/difftree', id => $commit->{id}, from_id => $from_id,
159
-    difftrees => $difftrees, parents => $commit->{parents}, project_ns => $project_ns%>
-137
templates/main/new_tags.html.ep
... ...
@@ -1,137 +0,0 @@
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
-  for my $tag (@$tags) {
22
-    $tag->{commit} = $git->parse_commit($project, $tag->{name});
23
-  }
24
-%>
25
-
26
-% layout 'new_common';
27
-  %= include '/css/common';
28
-  
29
-  %= stylesheet begin
30
-    /* h2 */
31
-    h2 {
32
-      font-size:120%;
33
-      padding-bottom:15px;
34
-    }
35
-    
36
-    /* tags number */
37
-    .tags_number {
38
-      color:#666;
39
-      padding-bottom:5px;
40
-    }
41
-    
42
-    /* tags */
43
-    .tags {
44
-      font-size:95%;
45
-      border-top:1px solid #E5E5E5;
46
-    }
47
-    .tag {
48
-      border-bottom:1px solid #E5E5E5;
49
-      padding:5px;
50
-    }
51
-    
52
-    .tag .top {
53
-      padding-bottom:3px;
54
-    }
55
-    .tag a.name {
56
-      font-weight:bold;
57
-      color:#4183C4;
58
-    }
59
-    .tag a.archive {
60
-      font-size:70%;
61
-      color:#4183C4;
62
-      display:none;
63
-    }
64
-    .tag a.commit {
65
-      color:#666;
66
-    }
67
-    .tag .uploaded {
68
-      color:#666;
69
-    }
70
-  % end
71
-  
72
-  %= javascript begin
73
-    $(document).ready(function () {
74
-      $(".tag").on({
75
-        "mouseenter": function () {
76
-          $(this).find('a.archive').css('display', 'inline');
77
-        },
78
-        "mouseleave": function () {
79
-          $(this).find('a.archive').css('display', 'none');
80
-        }
81
-      })
82
-    });
83
-  % end
84
-  
85
-  %= include '/include/header';
86
-
87
-  <div class="main_panel">
88
-    %= include '/include/sub_header';
89
-    
90
-    %= include '/include/code_menu';
91
-    %= stylesheet begin
92
-      /* Code menu */
93
-      .code_menu_tags {
94
-        border:1px solid #E5E5E5;
95
-        border-bottom:none;
96
-        background-color:white;
97
-        font-weight:bold;
98
-      }
99
-      .code_menu_tags a {
100
-        color:#333
101
-      }
102
-      
103
-    % end
104
-    
105
-    <h2><%= @$tags %> tags</h2>
106
-    
107
-    <div class="tags">
108
-      % for (my $i = 0; $i < @$tags; $i++) {
109
-        % my $tag = $tags->[$i];
110
-        % my $name = $tag->{name};
111
-        <div class="tag">
112
-          <div class="top">
113
-            <a class="name ubar" href="<%= url_for("/$user/$repository/archive/$name.zip") %>" title ="<%= $name %>">
114
-              <%= "$name.zip" %>
115
-            </a>
116
-            —
117
-            <span class="comment">
118
-              % if ($tag->{type} eq 'tag') {
119
-                <%= $tag->{comment_short} %>
120
-              % } else {
121
-                <%= $tag->{commit}{title_short} %>
122
-              % }
123
-            <span>
124
-            <a class="archive ubar" href="<%= url_for("/$user/$repository/archive/$name.zip") %>">ZIP</a>
125
-            <a class="archive ubar" href="<%= url_for("/$user/$repository/archive/$name.tar.gz") %>">TAR.GZ</a>
126
-          </div>
127
-          <div class="bottom">
128
-            <a class="commit ubar" href="<%= url_for("/$user/$repository/commit/$tag->{commit}{id}") %>"><%= substr($tag->{commit}{id}, 0, 10) %></a>
129
-             · 
130
-            <span class="uploaded">Uploaded <%= $tag->{commit}{age_string} %></span>
131
-          </div>
132
-        </div>
133
-      % }
134
-    </div>
135
-  </div>
136
-  
137
-  %= include '/include/footer';
-231
templates/main/new_tree.html.ep
... ...
@@ -1,231 +0,0 @@
1
-<%
2
-  use Gitprep::API;
3
-
4
-  # API
5
-  my $api = Gitprep::API->new($self);
6
-  
7
-  # Parameters
8
-  my $user = param('user');
9
-  my $repository = param('repository');
10
-  my $id_dir ||= param('id_dir') || 'master/';
11
-  my $root_ns = $api->root_ns(config->{root});
12
-  my $rep_ns = "$root_ns/$user/$repository.git";
13
-  my $rep = "/$rep_ns";
14
-  my $home_ns = $api->dirname($rep_ns);
15
-  my $home = "/$home_ns";
16
-
17
-  # Id and directory
18
-  my ($id, $dir) = $api->parse_id_path($rep, $id_dir);
19
-
20
-  # Git
21
-  my $git = app->git;
22
-  
23
-  # Tree id
24
-  my $tid;
25
-  my $commit = $git->parse_commit($rep, $id);
26
-  unless (defined $tid) {
27
-    if (defined $dir && $dir ne '') {
28
-      $tid = $git->id_by_path($rep, $id, $dir, 'tree');
29
-    }
30
-    else { $tid = $commit->{tree} }
31
-  }
32
-  $self->render_not_found unless defined $tid;
33
-  
34
-  # Commit log
35
-  my $latest_commit_log = $git->latest_commit_log($rep, $id);
36
-  
37
-  # Tree
38
-  my $trees = $api->trees($rep, $tid, $id, $dir);
39
-  
40
-  # Repository description
41
-  my $desc = $git->repository_description($rep);
42
-  
43
-  # Commits number
44
-  my $commits_number = $git->commits_number($rep, $id);
45
-  
46
-  # README
47
-  my $readme = $git->blob_plain($rep, $id, 'README');
48
-  
49
-  # Global variable
50
-  stash(
51
-    user => $user,
52
-    repository => $repository,
53
-    rep_ns => $rep_ns,
54
-    id => $id,
55
-    commit => $commit,
56
-    latest_commit_log => $latest_commit_log,
57
-    trees => $trees,
58
-    dir => $dir,
59
-    ref => $id,
60
-    title => "$repository/$dir at $id - $user/$repository"
61
-  );
62
-%>
63
-
64
-% layout 'new_common';
65
-  %= include '/css/common';
66
-  
67
-  %= javascript begin 
68
-    $(document).ready(function() {
69
-      
70
-      // Repository URL
71
-      var rep_url_bak_color = "#F5F5F5";
72
-      var http_rep_url = "<%= url_for("/$user/$repository.git")->to_abs %>";
73
-      var ssh_rep_url
74
-        = "<%= url_for("/$rep_ns")->to_abs->scheme('ssh')->userinfo($user)->port(config->{ssh_port}) %>";
75
-      var git_rep_url = "<%= url_for("/$user/$repository.git")->to_abs->scheme('git')->port('') %>";
76
-      $(".git_url_text").val(http_rep_url);
77
-      $(".git_url_http").css("background-color", "darkgray");
78
-      $(".git_url_http").on('click', function () {
79
-        $(".git_url_http").css("background-color", "darkgray");
80
-        $(".git_url_ssh").css("background-color", rep_url_bak_color);
81
-        $(".git_url_git").css("background-color", rep_url_bak_color);
82
-        
83
-        $(".git_url_text").val(http_rep_url);
84
-        $(".git_url_access").text("Read-only access");
85
-      });
86
-      $(".git_url_ssh").on('click', function () {
87
-        $(".git_url_http").css("background-color", rep_url_bak_color);
88
-        $(".git_url_ssh").css("background-color", "darkgray");
89
-        $(".git_url_git").css("background-color", rep_url_bak_color);
90
-        
91
-        $(".git_url_text").val(ssh_rep_url);
92
-        $(".git_url_access").text("Read-Write access");
93
-      });
94
-      $(".git_url_git").on('click', function () {
95
-        $(".git_url_http").css("background-color", rep_url_bak_color);
96
-        $(".git_url_ssh").css("background-color", rep_url_bak_color);
97
-        $(".git_url_git").css("background-color", "darkgray");
98
-        
99
-        $(".git_url_text").val(git_rep_url);
100
-        $(".git_url_access").text("Read-Only access");
101
-      });
102
-      
103
-    });
104
-  % end
105
-  
106
-  %= stylesheet begin
107
-    
108
-    /* Repository description */
109
-    .description {
110
-      padding:10px;
111
-      border:1px solid gray;
112
-      margin-top:-1px;
113
-    }
114
-    
115
-    /* Git URL */
116
-    .git_url {
117
-      border: 1px solid gray;
118
-      padding: 10px;
119
-      margin-top:-1px;
120
-      font-size:80%;
121
-    }
122
-    .git_url_zip {
123
-      padding:5px;
124
-      float:left;
125
-      border:1px solid gray;
126
-      margin-right:5px;
127
-      background-color:#F5F5F5;
128
-    }
129
-    .git_url_http {
130
-      padding:5px;
131
-      float:left;
132
-      border:1px solid gray;
133
-      background-color:#F5F5F5;
134
-    }
135
-    .git_url_ssh {
136
-      padding:5px;
137
-      float:left;
138
-      border:1px solid gray;
139
-      border-left:none;
140
-      background-color:#F5F5F5;
141
-    }
142
-    .git_url_git {
143
-      padding:5px;
144
-      float:left;
145
-      border:1px solid gray;
146
-      border-left:none;
147
-      background-color:#F5F5F5;
148
-    }
149
-    .git_url_text {
150
-      padding:3px;
151
-      float:left;
152
-      border:1px solid gray;
153
-      width:300px;
154
-      margin-right:10px;
155
-      border-left:none;
156
-      display:block;
157
-    }
158
-    .git_url_access {
159
-      padding:5px;
160
-    }
161
-    
162
-    /* Commit number */
163
-    .commit_number {
164
-      font-size:120%;
165
-    }
166
-    .commit_number_left {
167
-      width:700px;
168
-      float:left;
169
-    }
170
-    .commit_number_right {
171
-      text-align:right;
172
-    }
173
-    
174
-    /* README */
175
-    .readme {
176
-      width:100%;
177
-      margin: 5px auto;
178
-      border:2px solid gray;
179
-      margin-top:30px;
180
-      line-height:1.5em;
181
-    }
182
-    .readme_title {
183
-      border-bottom:1px solid gray;
184
-      font-size:130%;
185
-      font-weight:bold;
186
-      padding:10px;
187
-    }
188
-    .readme_body {
189
-      min-height: 50px;
190
-      font-size:120%;
191
-      padding:30px;
192
-    }
193
-  % end
194
-
195
-  %= include '/include/header';
196
-
197
-  <div class="main_panel">
198
-    %= include '/include/sub_header';
199
-
200
-    <div class="description"><%= $desc %></div>
201
-    
202
-    <div class="git_url">
203
-      <div class="git_url_zip"><a href="<%= url_for('/archive/master.zip') %>"><s>ZIP</s></a></div>
204
-      <div class="git_url_http">HTTP</div>
205
-      <div class="git_url_ssh">SSH</div>
206
-      <div class="git_url_git">Git Read-Only</div>
207
-      <input type="text" class="git_url_text">
208
-      <div class="git_url_access">Read-only access</div>
209
-    </div>
210
-    
211
-    %= include '/include/code_menu';
212
-    %= stylesheet begin
213
-      /* Code menu */
214
-      .code_menu_files {
215
-        border:1px solid #E5E5E5;
216
-        border-bottom:none;
217
-        background-color:white;
218
-        font-weight:bold;
219
-      }
220
-      .code_menu_files a {
221
-        color:#333
222
-      }
223
-    % end
224
-        
225
-    %= include '/include/new_page_path', type => 'tree', Path => $dir;
226
-
227
-    %= include '/include/tree';
228
-  </div>
229
-  
230
-  %= include '/include/footer';
231
-
+136 -7
templates/main/tags.html.ep
... ...
@@ -1,8 +1,137 @@
1
-% layout 'common';
2
-  %= include '/include/header', title => 'Tags', project => $project;
3
-  %= include '/include/current_directory', home_ns => $home_ns, home => $home;
4
-  %= include '/include/page_navi', current => 'tags';
5
-  <div class="header">
6
-    <a class="title" href="<%= url_for('tags', project => $project_ns) %>">Tags</a>
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
+  for my $tag (@$tags) {
22
+    $tag->{commit} = $git->parse_commit($project, $tag->{name});
23
+  }
24
+%>
25
+
26
+% layout 'new_common';
27
+  %= include '/css/common';
28
+  
29
+  %= stylesheet begin
30
+    /* h2 */
31
+    h2 {
32
+      font-size:120%;
33
+      padding-bottom:15px;
34
+    }
35
+    
36
+    /* tags number */
37
+    .tags_number {
38
+      color:#666;
39
+      padding-bottom:5px;
40
+    }
41
+    
42
+    /* tags */
43
+    .tags {
44
+      font-size:95%;
45
+      border-top:1px solid #E5E5E5;
46
+    }
47
+    .tag {
48
+      border-bottom:1px solid #E5E5E5;
49
+      padding:5px;
50
+    }
51
+    
52
+    .tag .top {
53
+      padding-bottom:3px;
54
+    }
55
+    .tag a.name {
56
+      font-weight:bold;
57
+      color:#4183C4;
58
+    }
59
+    .tag a.archive {
60
+      font-size:70%;
61
+      color:#4183C4;
62
+      display:none;
63
+    }
64
+    .tag a.commit {
65
+      color:#666;
66
+    }
67
+    .tag .uploaded {
68
+      color:#666;
69
+    }
70
+  % end
71
+  
72
+  %= javascript begin
73
+    $(document).ready(function () {
74
+      $(".tag").on({
75
+        "mouseenter": function () {
76
+          $(this).find('a.archive').css('display', 'inline');
77
+        },
78
+        "mouseleave": function () {
79
+          $(this).find('a.archive').css('display', 'none');
80
+        }
81
+      })
82
+    });
83
+  % end
84
+  
85
+  %= include '/include/header';
86
+
87
+  <div class="main_panel">
88
+    %= include '/include/sub_header';
89
+    
90
+    %= include '/include/code_menu';
91
+    %= stylesheet begin
92
+      /* Code menu */
93
+      .code_menu_tags {
94
+        border:1px solid #E5E5E5;
95
+        border-bottom:none;
96
+        background-color:white;
97
+        font-weight:bold;
98
+      }
99
+      .code_menu_tags a {
100
+        color:#333
101
+      }
102
+      
103
+    % end
104
+    
105
+    <h2><%= @$tags %> tags</h2>
106
+    
107
+    <div class="tags">
108
+      % for (my $i = 0; $i < @$tags; $i++) {
109
+        % my $tag = $tags->[$i];
110
+        % my $name = $tag->{name};
111
+        <div class="tag">
112
+          <div class="top">
113
+            <a class="name ubar" href="<%= url_for("/$user/$repository/archive/$name.zip") %>" title ="<%= $name %>">
114
+              <%= "$name.zip" %>
115
+            </a>
116
+            —
117
+            <span class="comment">
118
+              % if ($tag->{type} eq 'tag') {
119
+                <%= $tag->{comment_short} %>
120
+              % } else {
121
+                <%= $tag->{commit}{title_short} %>
122
+              % }
123
+            <span>
124
+            <a class="archive ubar" href="<%= url_for("/$user/$repository/archive/$name.zip") %>">ZIP</a>
125
+            <a class="archive ubar" href="<%= url_for("/$user/$repository/archive/$name.tar.gz") %>">TAR.GZ</a>
126
+          </div>
127
+          <div class="bottom">
128
+            <a class="commit ubar" href="<%= url_for("/$user/$repository/commit/$tag->{commit}{id}") %>"><%= substr($tag->{commit}{id}, 0, 10) %></a>
129
+             · 
130
+            <span class="uploaded">Uploaded <%= $tag->{commit}{age_string} %></span>
131
+          </div>
132
+        </div>
133
+      % }
134
+    </div>
7 135
   </div>
8
-  %= include '/include/tags', home => $home, project_ns => $project_ns, tags => $tags;
136
+  
137
+  %= include '/include/footer';
+225 -61
templates/main/tree.html.ep
... ...
@@ -1,67 +1,231 @@
1
-% layout 'common';
2
-  %= include '/include/header', title => 'Tree', project => $project;
3
-  %= include '/include/current_directory', home_ns => $home_ns, home => $home;
4
-  %= include '/include/page_navi', current => 'tree', home_ns => $home_ns, project_ns => $project_ns;
1
+<%
2
+  use Gitprep::API;
5 3
 
6
-  <div class="page_nav">
7
-    <a title="in format: tar.gz" rel="nofollow"
8
-        href="<%= url_for('snapshot', project => $project_ns, id => $id) %>">
9
-      snapshot
10
-    </a>
11
-  </div>
4
+  # API
5
+  my $api = Gitprep::API->new($self);
6
+  
7
+  # Parameters
8
+  my $user = param('user');
9
+  my $repository = param('repository');
10
+  my $id_dir ||= param('id_dir') || 'master/';
11
+  my $root_ns = $api->root_ns(config->{root});
12
+  my $rep_ns = "$root_ns/$user/$repository.git";
13
+  my $rep = "/$rep_ns";
14
+  my $home_ns = $api->dirname($rep_ns);
15
+  my $home = "/$home_ns";
12 16
 
13
-  <div class="header">
14
-    <a class="title" href="<%= url_for('commit', project => $project_ns, id => $id) %>">
15
-      <%= $commit->{title} %>
16
-    </a>
17
-  </div>
17
+  # Id and directory
18
+  my ($id, $dir) = $api->parse_id_path($rep, $id_dir);
18 19
 
19
-  %= include '/include/page_path', project_ns => $project_ns, id => $id, Path => $dir, type => 'tree';
20
+  # Git
21
+  my $git = app->git;
22
+  
23
+  # Tree id
24
+  my $tid;
25
+  my $commit = $git->parse_commit($rep, $id);
26
+  unless (defined $tid) {
27
+    if (defined $dir && $dir ne '') {
28
+      $tid = $git->id_by_path($rep, $id, $dir, 'tree');
29
+    }
30
+    else { $tid = $commit->{tree} }
31
+  }
32
+  $self->render_not_found unless defined $tid;
33
+  
34
+  # Commit log
35
+  my $latest_commit_log = $git->latest_commit_log($rep, $id);
36
+  
37
+  # Tree
38
+  my $trees = $api->trees($rep, $tid, $id, $dir);
39
+  
40
+  # Repository description
41
+  my $desc = $git->repository_description($rep);
42
+  
43
+  # Commits number
44
+  my $commits_number = $git->commits_number($rep, $id);
45
+  
46
+  # README
47
+  my $readme = $git->blob_plain($rep, $id, 'README');
48
+  
49
+  # Global variable
50
+  stash(
51
+    user => $user,
52
+    repository => $repository,
53
+    rep_ns => $rep_ns,
54
+    id => $id,
55
+    commit => $commit,
56
+    latest_commit_log => $latest_commit_log,
57
+    trees => $trees,
58
+    dir => $dir,
59
+    ref => $id,
60
+    title => "$repository/$dir at $id - $user/$repository"
61
+  );
62
+%>
20 63
 
21
-  <div class="page_body">
22
-    %= include 'include/refs', project => $project_ns, commit => $commit, refs => $refs;
23
-    <table class="tree">
24
-      % for (my $i = 0; $i <@$trees; $i++) {
64
+% layout 'new_common';
65
+  %= include '/css/common';
66
+  
67
+  %= javascript begin 
68
+    $(document).ready(function() {
69
+      
70
+      // Repository URL
71
+      var rep_url_bak_color = "#F5F5F5";
72
+      var http_rep_url = "<%= url_for("/$user/$repository.git")->to_abs %>";
73
+      var ssh_rep_url
74
+        = "<%= url_for("/$rep_ns")->to_abs->scheme('ssh')->userinfo($user)->port(config->{ssh_port}) %>";
75
+      var git_rep_url = "<%= url_for("/$user/$repository.git")->to_abs->scheme('git')->port('') %>";
76
+      $(".git_url_text").val(http_rep_url);
77
+      $(".git_url_http").css("background-color", "darkgray");
78
+      $(".git_url_http").on('click', function () {
79
+        $(".git_url_http").css("background-color", "darkgray");
80
+        $(".git_url_ssh").css("background-color", rep_url_bak_color);
81
+        $(".git_url_git").css("background-color", rep_url_bak_color);
82
+        
83
+        $(".git_url_text").val(http_rep_url);
84
+        $(".git_url_access").text("Read-only access");
85
+      });
86
+      $(".git_url_ssh").on('click', function () {
87
+        $(".git_url_http").css("background-color", rep_url_bak_color);
88
+        $(".git_url_ssh").css("background-color", "darkgray");
89
+        $(".git_url_git").css("background-color", rep_url_bak_color);
25 90
         
26
-        % my $tree = $trees->[$i];
27
-        % my $type = $tree->{type};
28
-        % my $name = $tree->{name};
91
+        $(".git_url_text").val(ssh_rep_url);
92
+        $(".git_url_access").text("Read-Write access");
93
+      });
94
+      $(".git_url_git").on('click', function () {
95
+        $(".git_url_http").css("background-color", rep_url_bak_color);
96
+        $(".git_url_ssh").css("background-color", rep_url_bak_color);
97
+        $(".git_url_git").css("background-color", "darkgray");
98
+        
99
+        $(".git_url_text").val(git_rep_url);
100
+        $(".git_url_access").text("Read-Only access");
101
+      });
102
+      
103
+    });
104
+  % end
105
+  
106
+  %= stylesheet begin
107
+    
108
+    /* Repository description */
109
+    .description {
110
+      padding:10px;
111
+      border:1px solid gray;
112
+      margin-top:-1px;
113
+    }
114
+    
115
+    /* Git URL */
116
+    .git_url {
117
+      border: 1px solid gray;
118
+      padding: 10px;
119
+      margin-top:-1px;
120
+      font-size:80%;
121
+    }
122
+    .git_url_zip {
123
+      padding:5px;
124
+      float:left;
125
+      border:1px solid gray;
126
+      margin-right:5px;
127
+      background-color:#F5F5F5;
128
+    }
129
+    .git_url_http {
130
+      padding:5px;
131
+      float:left;
132
+      border:1px solid gray;
133
+      background-color:#F5F5F5;
134
+    }
135
+    .git_url_ssh {
136
+      padding:5px;
137
+      float:left;
138
+      border:1px solid gray;
139
+      border-left:none;
140
+      background-color:#F5F5F5;
141
+    }
142
+    .git_url_git {
143
+      padding:5px;
144
+      float:left;
145
+      border:1px solid gray;
146
+      border-left:none;
147
+      background-color:#F5F5F5;
148
+    }
149
+    .git_url_text {
150
+      padding:3px;
151
+      float:left;
152
+      border:1px solid gray;
153
+      width:300px;
154
+      margin-right:10px;
155
+      border-left:none;
156
+      display:block;
157
+    }
158
+    .git_url_access {
159
+      padding:5px;
160
+    }
161
+    
162
+    /* Commit number */
163
+    .commit_number {
164
+      font-size:120%;
165
+    }
166
+    .commit_number_left {
167
+      width:700px;
168
+      float:left;
169
+    }
170
+    .commit_number_right {
171
+      text-align:right;
172
+    }
173
+    
174
+    /* README */
175
+    .readme {
176
+      width:100%;
177
+      margin: 5px auto;
178
+      border:2px solid gray;
179
+      margin-top:30px;
180
+      line-height:1.5em;
181
+    }
182
+    .readme_title {
183
+      border-bottom:1px solid gray;
184
+      font-size:130%;
185
+      font-weight:bold;
186
+      padding:10px;
187
+    }
188
+    .readme_body {
189
+      min-height: 50px;
190
+      font-size:120%;
191
+      padding:30px;
192
+    }
193
+  % end
194
+
195
+  %= include '/include/header';
196
+
197
+  <div class="main_panel">
198
+    %= include '/include/sub_header';
199
+
200
+    <div class="description"><%= $desc %></div>
201
+    
202
+    <div class="git_url">
203
+      <div class="git_url_zip"><a href="<%= url_for('/archive/master.zip') %>"><s>ZIP</s></a></div>
204
+      <div class="git_url_http">HTTP</div>
205
+      <div class="git_url_ssh">SSH</div>
206
+      <div class="git_url_git">Git Read-Only</div>
207
+      <input type="text" class="git_url_text">
208
+      <div class="git_url_access">Read-only access</div>
209
+    </div>
210
+    
211
+    %= include '/include/code_menu';
212
+    %= stylesheet begin
213
+      /* Code menu */
214
+      .code_menu_files {
215
+        border:1px solid #E5E5E5;
216
+        border-bottom:none;
217
+        background-color:white;
218
+        font-weight:bold;
219
+      }
220
+      .code_menu_files a {
221
+        color:#333
222
+      }
223
+    % end
29 224
         
30
-        % my $child_dir = defined $dir && length $dir ? join('/', $dir, $name) : $name;
31
-        <tr class="<%= $i % 2 ? 'light' : 'dark' %>">
32
-          <td class="mode">
33
-            <%= $tree->{mode_str} %>
34
-          </td>
35
-          % my $file = defined $dir ? "$dir/$name" : $name;
36
-          % $file =~ s/^\///;
37
-          
38
-          <td class="list">
39
-            % if ($type eq 'blob') {
40
-              <a class="list" href="<%= url_for('blob', project => $project_ns, id_file => "$id/$file") %>">
41
-                <%= $name %>
42
-              </a>
43
-            % } elsif ($tree) {
44
-              <a href="<%= url_for('tree', project => $project_ns, id_dir => "$id/$child_dir") %>">
45
-                <%= $name %>
46
-              </a>
47
-            % }
48
-          </td>
49
-          <td class="link">
50
-            % if ($type eq 'blob') {
51
-              <a href="<%= url_for('blob', project => $project_ns, id_file => "$id/$file") %>">
52
-                blob
53
-              </a>
54
-              |
55
-              <a href="<%= url_for('blob_plain', project => $project_ns, id_file => "$id/$file") %>">
56
-                raw
57
-              </a>
58
-            % } elsif ($type eq 'tree') {
59
-              <a href="<%= url_for('tree', project => $project_ns, id_dir => "$id/$child_dir") %>">
60
-                tree
61
-              </a>
62
-            % }
63
-          </td>
64
-        </tr>
65
-      % }
66
-    </table>
67
-  </div>
225
+    %= include '/include/new_page_path', type => 'tree', Path => $dir;
226
+
227
+    %= include '/include/tree';
228
+  </div>
229
+  
230
+  %= include '/include/footer';
231
+