Showing 5 changed files with 38 additions and 29 deletions
+17 -16
templates/commit.html.ep
... ...
@@ -3,7 +3,8 @@
3 3
   my $api = gitprep_api;
4 4
   
5 5
   # Paramters
6
-  my $project = param('project');
6
+  my $user_id = param('user');
7
+  my $project_id = param('project');
7 8
   my $diff = param('diff');
8 9
   my ($from_rev, $rev) = $diff =~ /(.+)\.\.(.+)/;
9 10
   $rev = $diff unless defined $rev;
... ...
@@ -12,7 +13,7 @@
12 13
   my $git = app->git;
13 14
   
14 15
   # Commit
15
-  my $commit = $git->get_commit(app->rep_info($user, $project), $rev);
16
+  my $commit = $git->get_commit(app->rep_info($user_id, $project_id), $rev);
16 17
   
17 18
   unless ($commit) {
18 19
     $self->reply->not_found;
... ...
@@ -33,19 +34,19 @@
33 34
   )->value;
34 35
   
35 36
   # Branches
36
-  my $branch_refs = $git->references(app->rep_info($user, $project), 'heads');
37
+  my $branch_refs = $git->references(app->rep_info($user_id, $project_id), 'heads');
37 38
   my $branches = $branch_refs->{$commit->{id}} || [];
38 39
   
39 40
   # Tags
40
-  my $tag_refs = $git->references(app->rep_info($user, $project), 'tags');
41
+  my $tag_refs = $git->references(app->rep_info($user_id, $project_id), 'tags');
41 42
   my $tags = $tag_refs->{$commit->{id}} || [];
42 43
   
43
-  # Global variable for included template
44
-  stash(
44
+  # commit_body args
45
+  my %commit_body_args = (
46
+    user => $user_id,
47
+    project => $project_id,
45 48
     rev => $rev,
46
-    from_rev => $from_rev,
47
-    commit => $commit,
48
-    parents => $commit->{parents}
49
+    from_rev => $from_rev
49 50
   );
50 51
 
51 52
   layout 'common', title => "$commit->{title_short} \x{30fb} $commit_short_id";
... ...
@@ -86,19 +87,19 @@
86 87
           % if (@$branches || @$tags) {
87 88
             <div>
88 89
               % for my $branch (@$branches) {
89
-                <i class="icon-share-alt" style="padding-right:1px"></i><a href="<%= url_for("/$user/$project/tree/$branch") %>"><%= $branch %></a>
90
+                <i class="icon-share-alt" style="padding-right:1px"></i><a href="<%= url_for("/$user_id/$project_id/tree/$branch") %>"><%= $branch %></a>
90 91
               % }
91 92
               
92 93
               % for my $tag (@$tags) {
93 94
                 <span style="padding-left:5px">
94
-                  <i class="icon-tag" style="padding-right:2px"></i><a href="<%= url_for("/$user/$project/tree/$tag") %>"><%= $tag %></a>
95
+                  <i class="icon-tag" style="padding-right:2px"></i><a href="<%= url_for("/$user_id/$project_id/tree/$tag") %>"><%= $tag %></a>
95 96
                 </span>
96 97
               % }
97 98
             </div>
98 99
           % }
99 100
         </li>
100 101
         <li class="last-child">
101
-          <a class="btn btn-primary" href="<%= url_for("/$user/$project/tree/$commit->{id}") %>">
102
+          <a class="btn btn-primary" href="<%= url_for("/$user_id/$project_id/tree/$commit->{id}") %>">
102 103
             Browse files
103 104
           </a>
104 105
         </li>
... ...
@@ -126,7 +127,7 @@
126 127
           % } elsif (@$parents == 1) {
127 128
             <div class="commits-summary-parent">
128 129
               <span>1 parent</span>
129
-              <a href="<%= url_for("/$user/$project/commit/$parents->[0]") %>">
130
+              <a href="<%= url_for("/$user_id/$project_id/commit/$parents->[0]") %>">
130 131
                 <%= substr($parents->[0], 0, 7) %>
131 132
               </a>
132 133
             </div>
... ...
@@ -134,11 +135,11 @@
134 135
             <div class="commits-summary-parent">
135 136
               <span>2 parents</span>:
136 137
               
137
-              <a class="font-black" href="<%= url_for("/$user/$project/commit/$parents->[0]") %>">
138
+              <a class="font-black" href="<%= url_for("/$user_id/$project_id/commit/$parents->[0]") %>">
138 139
                 <%= substr($parents->[0], 0, 7) %>
139 140
               </a>
140 141
               +
141
-              <a class="font-black" href="<%= url_for("/$user/$project/commit/$parents->[1]") %>">
142
+              <a class="font-black" href="<%= url_for("/$user_id/$project_id/commit/$parents->[1]") %>">
142 143
                 <%= substr($parents->[1], 0, 7) %>
143 144
               </a>
144 145
             </div>
... ...
@@ -151,7 +152,7 @@
151 152
     </li>
152 153
   </ul>
153 154
 
154
-  %= include '/include/commit_body';
155
+  %= include '/include/commit_body', %commit_body_args;
155 156
 </div>
156 157
 
157 158
 %= include '/include/footer';
+2
templates/compare.html.ep
... ...
@@ -259,6 +259,8 @@
259 259
   
260 260
   # commit_body args
261 261
   my %commit_body_args = (
262
+    user => $base_user_id,
263
+    project => $base_project_id,
262 264
     rep_info => $work_rep_info,
263 265
     rev => $end_commit_id,
264 266
     from_rev => $start_commit_id
+12 -10
templates/include/blob_diff_body.html.ep
... ...
@@ -1,4 +1,6 @@
1 1
 <%
2
+  my $user_id = stash('user');
3
+  my $project_id = stash('project');
2 4
   my $rev = stash('rev');
3 5
   my $from_rev = stash('from_rev');
4 6
   
... ...
@@ -21,22 +23,22 @@
21 23
   
22 24
   if ($blob_diff->{binary}) {
23 25
     if ($status eq 'A') {
24
-      if ($git->blob_is_image(app->rep_info($user, $project), $rev, $file)) {
26
+      if ($git->blob_is_image(app->rep_info($user_id, $project_id), $rev, $file)) {
25 27
         $binary_rev_shown = 1;
26 28
       }
27 29
       else {
28 30
         $binary_not_shown = 1;
29 31
       }
30 32
     } elsif ($status eq 'D') {
31
-      if ($git->blob_is_image(app->rep_info($user, $project), $from_rev, $file)) {
33
+      if ($git->blob_is_image(app->rep_info($user_id, $project_id), $from_rev, $file)) {
32 34
         $binary_from_rev_shown = 1;
33 35
       }
34 36
       else {
35 37
         $binary_not_shown = 1;
36 38
       }
37 39
     } else {
38
-      if ($git->blob_is_image(app->rep_info($user, $project), $from_rev, $file)
39
-        && $git->blob_is_image(app->rep_info($user, $project), $from_rev, $file)) {
40
+      if ($git->blob_is_image(app->rep_info($user_id, $project_id), $from_rev, $file)
41
+        && $git->blob_is_image(app->rep_info($user_id, $project_id), $from_rev, $file)) {
40 42
         $binary_from_rev_shown = 1;
41 43
         $binary_rev_shown = 1;
42 44
       }
... ...
@@ -62,11 +64,11 @@
62 64
       </div>
63 65
       <div class="last-child">
64 66
         % if ($status eq 'D') {
65
-          <a class="btn" href="<%= url_for("/$user/$project/blob/$from_rev/$file") %>">
67
+          <a class="btn" href="<%= url_for("/$user_id/$project_id/blob/$from_rev/$file") %>">
66 68
             <b>View</b>
67 69
           </a>
68 70
         % } else {
69
-          <a class="btn" href="<%= url_for("/$user/$project/blob/$rev/$file") %>">
71
+          <a class="btn" href="<%= url_for("/$user_id/$project_id/blob/$rev/$file") %>">
70 72
             <b>View</b>
71 73
           </a>
72 74
         % }
... ...
@@ -88,14 +90,14 @@
88 90
           % } else {
89 91
             <div class="commit-diff-image">
90 92
               % if ($binary_from_rev_shown) {
91
-                <a href="<%= url_for("/$user/$project/blob/$from_rev/$file") %>">
92
-                  <img src="<%= url_for("/$user/$project/raw/$from_rev/$file") %>" style="border:1px solid red;padding:1px;margin-right:20px">
93
+                <a href="<%= url_for("/$user_id/$project_id/blob/$from_rev/$file") %>">
94
+                  <img src="<%= url_for("/$user_id/$project_id/raw/$from_rev/$file") %>" style="border:1px solid red;padding:1px;margin-right:20px">
93 95
                 </a>          
94 96
               % }
95 97
               
96 98
               % if ($binary_rev_shown) {
97
-                <a href="<%= url_for("/$user/$project/blob/$rev/$file") %>">
98
-                  <img src="<%= url_for("/$user/$project/raw/$rev/$file") %>" style="border:1px solid green;padding:1px;margin-left:20px">
99
+                <a href="<%= url_for("/$user_id/$project_id/blob/$rev/$file") %>">
100
+                  <img src="<%= url_for("/$user_id/$project_id/raw/$rev/$file") %>" style="border:1px solid green;padding:1px;margin-left:20px">
99 101
                 </a>
100 102
               % }
101 103
             </div>
+4 -2
templates/include/commit_body.html.ep
... ...
@@ -1,6 +1,8 @@
1 1
 <%
2 2
   # Parameters
3
-  my $rep_info = stash('rep_info') // app->rep_info($user, $project);
3
+  my $user_id = stash('user');
4
+  my $project_id = stash('project');
5
+  my $rep_info = stash('rep_info') // app->rep_info($user_id, $project_id);
4 6
   my $rev = stash('rev');
5 7
   my $from_rev = stash('from_rev');
6 8
 
... ...
@@ -12,7 +14,7 @@
12 14
   else {
13 15
     $ignore_space_change = app->dbi->model('project')->select(
14 16
       'ignore_space_change',
15
-      where => {user_id => $user, name => $project}
17
+      where => {user_id => $user_id, name => $project_id}
16 18
     )->value;
17 19
   }
18 20
   
+3 -1
templates/pull.html.ep
... ...
@@ -301,8 +301,10 @@
301 301
   my $pre_content_http = "git pull $http_rep_url $target_branch";
302 302
   my $pre_content_ssh = "git pull $ssh_rep_url $target_branch";
303 303
   
304
-  # Commit body arguments
304
+  # commit_body args
305 305
   my %commit_body_args = (
306
+    user => $base_user_id,
307
+    project => $base_project_id,
306 308
     rep_info => $work_rep_info,
307 309
     rev => $end_commit_id,
308 310
     from_rev => $start_commit_id