added readme link feature
|
1 |
<% |
2 |
use Mojo::ByteStream (); |
|
support markdown table
|
3 |
|
4 |
my $api = gitprep_api; |
|
added readme link feature
|
5 |
|
show readme in sub directory
|
6 |
my $dir = stash('dir'); |
7 |
|
|
added readme link feature
|
8 |
# README |
fix sub directory readme mar...
|
9 |
my $type = ''; |
cleanup
|
10 |
my $lines; |
show readme file in sub dire...
|
11 |
my $readme_path = (defined $dir && $dir ne '') ? "$dir/README" : 'README'; |
cleanup rep_info
|
12 |
eval { $lines = app->git->blob(app->rep_info($user, $project), $rev, $readme_path) }; |
cleanup
|
13 |
my $readme_e; |
fix markdown image bug
|
14 |
|
cleanup
|
15 |
if ($lines) { |
change markdown engine to Te...
|
16 |
$type = 'plain'; |
cleanup
|
17 |
my $readme = join "\n", @$lines; |
18 |
$readme_e = Mojo::ByteStream->new($readme)->xml_escape->to_string; |
|
improve README link
|
19 |
$readme_e =~ s#(^|\s|[^\x00-\x7F])(http(?:s)?://.+?)($|\s|[^\x00-\x7F])#$1<a href="$2">$2</a>$3#msg; |
cleanup
|
20 |
} |
now also tries to read READM...
|
21 |
else { |
cleanup rep_info
|
22 |
eval { $lines = app->git->blob(app->rep_info($user, $project), $rev, "$readme_path.md") }; |
now also tries to read READM...
|
23 |
if ($lines) { |
change markdown engine to Te...
|
24 |
$type = 'markdown'; |
now also tries to read READM...
|
25 |
my $readme = join "\n", @$lines; |
fix CGI not display image bu...
|
26 |
$readme =~ s#^(\[.*\]:)(?!\s*https?://)\s*(\S*)#{"$1 " . url_for("/$user/$project/raw/$rev/$2")}#mge; |
27 |
$readme =~ s#^(!\[.*\]\()(?!https?://)(\S*)#{$1 . url_for("/$user/$project/raw/$rev/$2")}#mge; |
|
support markdown table
|
28 |
$readme_e = $api->markdown($readme); |
now also tries to read READM...
|
29 |
} |
30 |
} |
|
added readme link feature
|
31 |
%> |
32 | ||
cleanup
|
33 |
% if (defined $readme_e) { |
complete readme design
|
34 |
<div class="readme"> |
35 |
<div class="readme-header"> |
|
36 |
<i class="icon-book"></i> <%= $type eq 'plain' ? 'README' : 'README.md' %> |
|
37 |
</div> |
|
38 |
<div class="readme-frame"> |
|
39 |
% if ($type eq 'plain') { |
|
40 |
<pre class="plain-text"><%== $readme_e %></pre> |
|
41 |
% } else { |
|
42 |
<div class="markdown-body"><%== $readme_e %></div> |
|
43 |
% } |
|
change markdown engine to Te...
|
44 |
</div> |
added readme link feature
|
45 |
</div> |
use hoedown for fenced code ...
|
46 |
% } |