Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request yuki-kimoto#17 from maspalio/master
Browse files Browse the repository at this point in the history
Add README.md markdown support.
  • Loading branch information
yuki-kimoto committed Aug 30, 2013
2 parents 3b62c2f + bc9582f commit a80b1a7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ requires 'Params::Check', '== 0.36';
requires 'ExtUtils::ParseXS', '== 3.18';
requires 'Test::MockModule', '== 0.05';
requires 'Digest::SHA', '== 5.84';
requires 'Text::Markdown', '== 1.000031';
29 changes: 29 additions & 0 deletions public/css/readme.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pre.README {
background : white;
border-radius : 1px;
border-top : none;
border-top-left-radius : 0;
font-size : 12px;
line-height : 1em;
margin-bottom : 80px;
padding : 27px;
}

pre.README h1 { margin: 0; font-size: 2em; }
pre.README h2 { margin: 0; font-size: 1.5em; }
pre.README h3 { margin: 0; font-size: 1.17em; }
pre.README h5 { margin: 0; font-size: .83em; }
pre.README h6 { margin: 0; font-size: .75em; }

pre.README h1 {
border-bottom : 1px solid #DDDDDD;
}

pre.README p {
margin : 0;
padding : 0;
}

pre.README ul {
padding : 0 1em;
}
10 changes: 9 additions & 1 deletion templates/include/readme.html.ep
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<%
use Mojo::ByteStream ();
use Text::Markdown qw( markdown );

# README
my $lines;
Expand All @@ -10,11 +11,18 @@
$readme_e = Mojo::ByteStream->new($readme)->xml_escape->to_string;
$readme_e =~ s#(^|\s|[^\x00-\x7F])(http(?:s)?://.+?)($|\s|[^\x00-\x7F])#$1<a href="$2">$2</a>$3#msg;
}
else {
eval { $lines = app->git->blob($user, $project, $rev, 'README.md') };
if ($lines) {
my $readme = join "\n", @$lines;
$readme_e = markdown($readme);
}
}
%>

% if (defined $readme_e) {
<div class="border-gray bk-gray-light" style="border-radius:1px;font-size:17px;padding:10px">
<i class="icon-book" style="margin-top:2px"></i> README
</div>
<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>
<pre class="border-gray README"><%== $readme_e %></pre>
% }
1 change: 1 addition & 0 deletions templates/layouts/common.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
% my $title = stash('title');
<title><%= $title ? "$title \x{30fb} Gitprep" : 'Gitprep' %></title>
%= stylesheet '/css/bootstrap.min.css', rel => 'stylesheet', media => 'screen';
%= stylesheet '/css/readme.css', rel => 'stylesheet', media => 'screen';
% for my $stylesheet (@$stylesheets) {
%= stylesheet $stylesheet;
% }
Expand Down

0 comments on commit a80b1a7

Please sign in to comment.