3 contributor
<%
use Mojo::ByteStream ();
use Text::Markdown::Hoedown;
my $dir = stash('dir');
# README
my $type = '';
my $lines;
my $readme_path = (defined $dir && $dir ne '') ? "$dir/README" : 'README';
eval { $lines = app->git->blob($user, $project, $rev, $readme_path) };
my $readme_e;
if ($lines) {
$type = 'plain';
my $readme = join "\n", @$lines;
$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_path.md") };
if ($lines) {
$type = 'markdown';
my $readme = join "\n", @$lines;
$readme_e = Text::Markdown::Hoedown::markdown($readme, extensions => HOEDOWN_EXT_FENCED_CODE);
}
}
%>
% if (defined $readme_e) {
<div class="README">
<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> <%= $type eq 'plain' ? 'README' : 'README.md' %>
</div>
% if ($type eq 'plain') {
<pre class="plain-text border-gray"><%== $readme_e %></pre>
% } else {
<div class="markdown border-gray"><%== $readme_e %></div>
% }
</div>
% }