Showing 4 changed files with 40 additions and 16 deletions
+1 -1
cpanfile
... ...
@@ -21,5 +21,5 @@ requires 'Params::Check', '== 0.36';
21 21
 requires 'ExtUtils::ParseXS', '== 3.18';
22 22
 requires 'Test::MockModule', '== 0.05';
23 23
 requires 'Digest::SHA', '== 5.84';
24
-requires 'Text::Markdown', '== 1.000031';
24
+requires 'Text::Markdown::Discount', '== 0.10';
25 25
 requires 'Compress::Zlib', '== 2.062';
+1
lib/Gitprep/Git.pm
... ...
@@ -686,6 +686,7 @@ sub path_to_hash {
686 686
   my $line = $self->_dec(scalar <$fh>);
687 687
   close $fh or return;
688 688
   my ($t, $id) = ($line || '') =~ m/^[0-9]+ (.+) ([0-9a-fA-F]{40})\t/;
689
+  $t ||= '';
689 690
   return if defined $type && $type ne $t;
690 691
 
691 692
   return $id;
+24 -10
templates/css/common.html.ep
... ...
@@ -47,7 +47,8 @@
47 47
   border:1px solid #c5d5dd;
48 48
 }
49 49
 
50
-pre.README {
50
+/* Plain text */
51
+.plain-text {
51 52
   background             : white;
52 53
   border-radius          : 1px;
53 54
   border-top             : none;
... ...
@@ -58,21 +59,34 @@ pre.README {
58 59
   padding                : 27px;
59 60
 }
60 61
 
61
-pre.README h1 { margin: 0; font-size: 2em;    }
62
-pre.README h2 { margin: 0; font-size: 1.5em;  }
63
-pre.README h3 { margin: 0; font-size: 1.17em; }
64
-pre.README h5 { margin: 0; font-size:  .83em; }
65
-pre.README h6 { margin: 0; font-size:  .75em; }
62
+/* Markdown */
63
+.markdown {
64
+  background             : white;
65
+  border-radius          : 1px;
66
+  border-top             : none;
67
+  border-top-left-radius : 0;
68
+  font-size              : 14px;
69
+  line-height            : 1.5em;
70
+  margin-bottom          : 80px;
71
+  padding                : 27px;
72
+  font-color:#aaa;
73
+}
74
+
75
+.markdown h1 { margin-bottom:10px; padding:10px 0; font-size: 36px; }
76
+.markdown h2 { margin: 0; font-size: 1.5em;  }
77
+.markdown h3 { margin: 0; font-size: 1.17em; }
78
+.markdown h5 { margin: 0; font-size:  .83em; }
79
+.markdown h6 { margin: 0; font-size:  .75em; }
66 80
 
67
-pre.README h1 {
81
+.markdown h1 {
68 82
   border-bottom : 1px solid #DDDDDD;
69 83
 }
70 84
 
71
-pre.README p {
85
+.markdown p {
72 86
   margin  : 0;
73
-  padding : 0;
87
+  padding:10px 0;
74 88
 }
75 89
 
76
-pre.README ul {
90
+.markdown ul {
77 91
   padding : 0 1em;
78 92
 }
+14 -5
templates/include/readme.html.ep
... ...
@@ -1,12 +1,14 @@
1 1
 <%
2 2
   use Mojo::ByteStream ();
3
-  use Text::Markdown ();
3
+  use Text::Markdown::Discount ();
4 4
   
5 5
   # README
6
+  my $type;
6 7
   my $lines;
7 8
   eval { $lines = app->git->blob($user, $project, $rev, 'README') };
8 9
   my $readme_e;
9 10
   if ($lines) {
11
+    $type = 'plain';
10 12
     my $readme = join "\n", @$lines;
11 13
     $readme_e = Mojo::ByteStream->new($readme)->xml_escape->to_string;
12 14
     $readme_e =~ s#(^|\s|[^\x00-\x7F])(http(?:s)?://.+?)($|\s|[^\x00-\x7F])#$1<a href="$2">$2</a>$3#msg;
... ...
@@ -14,15 +16,22 @@
14 16
   else {
15 17
     eval { $lines = app->git->blob($user, $project, $rev, 'README.md') };
16 18
     if ($lines) {
19
+      $type = 'markdown';
17 20
       my $readme = join "\n", @$lines;
18
-      $readme_e = Text::Markdown::markdown($readme);
21
+      $readme_e = Text::Markdown::Discount::markdown($readme);
19 22
     }
20 23
   }
21 24
 %>
22 25
 
23 26
 % if (defined $readme_e) {
24
-  <div class="border-gray bk-gray-light" style="border-radius:1px;font-size:17px;padding:10px">
25
-    <i class="icon-book" style="margin-top:2px"></i> README
27
+  <div class="README">
28
+    <div class="border-gray bk-gray-light" style="border-radius:1px;font-size:17px;padding:10px">
29
+      <i class="icon-book" style="margin-top:2px"></i> README
30
+    </div>
31
+    % if ($type eq 'plain') {
32
+      <pre class="plain-text border-gray"><%== $readme_e %></pre>
33
+    % } else {
34
+      <div class="markdown border-gray"><%== $readme_e %></div>
35
+    % }
26 36
   </div>
27
-  <pre class="border-gray README"><%== $readme_e %></pre>
28 37
 % }