gitprep / templates / include / readme.html.ep /
196f419 10 years ago
2 contributor
28 lines | 0.86kb
<%
  use Mojo::ByteStream ();
  use Text::Markdown ();
  
  # README
  my $lines;
  eval { $lines = app->git->blob($user, $project, $rev, 'README') };
  my $readme_e;
  if ($lines) {
    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.md') };
    if ($lines) {
      my $readme = join "\n", @$lines;
      $readme_e = Text::Markdown::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 README"><%== $readme_e %></pre>
% }