Showing 3 changed files with 18 additions and 20 deletions
+16 -4
templates/include/readme.html.ep
... ...
@@ -1,4 +1,16 @@
1
-<div class="border-gray bk-gray-light" style="border-radius:1px;font-size:17px;padding:10px">
2
-  <i class="icon-book" style="margin-top:2px"></i> README
3
-</div>
4
-<pre class="border-gray " style="background:white;border-top-left-radius:0;border-radius:1px;border-top:none;padding:27px;font-size:16px;margin-bottom:80px"><%= $readme %></pre>
1
+<%
2
+  use Mojo::ByteStream ();
3
+  
4
+  # README
5
+  my $readme;
6
+  eval { $readme = app->git->blob_plain($user, $project, $rev, 'README') };
7
+  my $readme_e = Mojo::ByteStream->new($readme)->xml_escape->to_string;
8
+  $readme_e =~ s#(^|\s)(http(?:s)?://.+?)($|\s)#$1<a href="$2">$2</a>$3#msg;
9
+%>
10
+
11
+% if (defined $readme) {
12
+  <div class="border-gray bk-gray-light" style="border-radius:1px;font-size:17px;padding:10px">
13
+    <i class="icon-book" style="margin-top:2px"></i> README
14
+  </div>
15
+  <pre class="border-gray " style="background:white;border-top-left-radius:0;border-radius:1px;border-top:none;padding:27px;font-size:16px;margin-bottom:80px"><%== $readme_e %></pre>
16
+% }
+1 -8
templates/project.html.ep
... ...
@@ -17,7 +17,6 @@
17 17
   
18 18
   # Check exsitence
19 19
   my $commits_number;
20
-  my $readme;
21 20
   if ($git->branch_exists($user, $project)) {
22 21
     # Directory
23 22
     
... ...
@@ -30,16 +29,12 @@
30 29
     # Commits number
31 30
     $commits_number = $git->commits_number($user, $project, $rev);
32 31
     
33
-    # README
34
-    eval { $readme = $git->blob_plain($user, $project, $rev, 'README') };
35
-    
36 32
     # Variable for included template
37 33
     stash(
38 34
       commit => $commit,
39 35
       trees => $trees,
40 36
       rev => $rev,
41 37
       title => "$user/$project",
42
-      readme => $readme
43 38
     );
44 39
     
45 40
     $state = 'display';
... ...
@@ -154,9 +149,7 @@
154 149
         %= include '/include/tree';
155 150
       </div>
156 151
       
157
-      % if (defined $readme) {
158
-        %= include '/include/readme';
159
-      % }
152
+      %= include '/include/readme';
160 153
       
161 154
     % } elsif ($state eq 'init' && $logined) {
162 155
     
+1 -8
templates/tree.html.ep
... ...
@@ -22,17 +22,12 @@
22 22
   # Commits number
23 23
   my $commits_number = $git->commits_number($user, $project, $rev);
24 24
   
25
-  # README
26
-  my $readme;
27
-  eval { $readme = $git->blob_plain($user, $project, $rev, 'README') };
28
-  
29 25
   # Variable for included templates
30 26
   stash(
31 27
     rev => $rev,
32 28
     commit => $commit,
33 29
     trees => $trees,
34 30
     dir => $dir,
35
-    readme => $readme
36 31
   );
37 32
 %>
38 33
 
... ...
@@ -46,9 +41,7 @@
46 41
     %= include '/include/page_path', type => 'tree', Path => $dir;
47 42
     %= include '/include/tree';
48 43
 
49
-    % if ($top && defined $readme) {
50
-      %= include '/include/readme';
51
-    % }
44
+    %= include '/include/readme';
52 45
   </div>
53 46
   
54 47
   %= include '/include/footer';