line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ado::Control::Doc; |
2
|
2
|
|
|
2
|
|
12263
|
use Mojo::Base 'Ado::Control'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#Renders the page found in md_file |
5
|
|
|
|
|
|
|
sub show { |
6
|
26
|
|
|
26
|
1
|
251
|
my $c = shift; |
7
|
26
|
|
100
|
|
|
278
|
my $document = $c->md_to_html() || return; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#What will be the tag to wrap around produced HTML? |
10
|
25
|
|
|
|
|
9421
|
my $md_file = $c->stash('md_file'); |
11
|
25
|
|
|
|
|
407
|
my ($tag, $class, $toc) = ('aside', 'ui large vertical inverted labeled icon sidebar', ''); |
12
|
|
|
|
|
|
|
|
13
|
25
|
100
|
|
|
|
193
|
if ($md_file =~ /toc/) { |
14
|
2
|
|
|
|
|
5
|
($tag) = ('aside'); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
else { |
17
|
23
|
|
|
|
|
251
|
my ($lang) = $md_file =~ m|([^/]{2})/[^/]+$|; |
18
|
23
|
|
|
|
|
276
|
$toc = qq|<$tag id="toc" class="$class">| . $c->md_to_html("$lang/toc.md") . qq|$tag>|; |
19
|
23
|
|
|
|
|
3845
|
($tag, $class) = ('article', 'main container'); |
20
|
|
|
|
|
|
|
} |
21
|
25
|
|
|
|
|
232
|
my ($md_id) = ($md_file =~ /([^\/]+)\.md$/); |
22
|
25
|
|
|
|
|
144
|
$document = Mojo::DOM->new(qq|<$tag id="$md_id" class="$class">$document$tag>|); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#Is the request made via Ajax? Respond directly - no template. |
25
|
25
|
50
|
50
|
|
|
32282
|
if ($c->req->headers->header('X-Requested-With') // '' eq 'XMLHttpRequest') { |
26
|
0
|
|
|
|
|
0
|
return $c->render(text => $document->to_string); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#Prepare a title for the HTML |
30
|
25
|
|
|
|
|
1338
|
$c->_set_title($document); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#Use template show.html.ep with layout doc.html.ep |
33
|
25
|
|
|
|
|
217
|
return $c->render(document => $toc . $document); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#prepare a title for the html>head |
37
|
|
|
|
|
|
|
sub _set_title { |
38
|
25
|
|
|
25
|
|
49
|
my ($c, $document) = @_; |
39
|
25
|
|
|
|
|
139
|
my $title = $document->find('h1,h2,h3')->[0]; |
40
|
|
|
|
|
|
|
|
41
|
25
|
100
|
|
|
|
19147
|
if (not $title) { |
42
|
1
|
|
|
|
|
3
|
$title = 'Няма Заглавие!'; |
43
|
1
|
|
|
|
|
11
|
$c->title($title); |
44
|
1
|
|
|
|
|
48
|
$document->at('article')->prepend_content(qq|$title|); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
24
|
|
|
|
|
208
|
$c->title($title->text); |
48
|
|
|
|
|
|
|
} |
49
|
25
|
|
|
|
|
2868
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=encoding utf8 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Ado::Control::Doc - The controller for the end-user documentation |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SYNOPSIS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#in your browser go to |
66
|
|
|
|
|
|
|
http://your-host/help |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This is a minimal controller to display and browse end-user documentation |
71
|
|
|
|
|
|
|
written in markdown format. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS/ACTIONS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L inherits all the methods from |
76
|
|
|
|
|
|
|
L and defines the following ones. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 show |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Renders the page found in C<$c-Estash('md_file');>. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SPONSORS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The original author |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Become a sponsor and help make L the ERP for the enterprise! |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SEE ALSO |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
L, |
91
|
|
|
|
|
|
|
L, L, |
92
|
|
|
|
|
|
|
L, |
93
|
|
|
|
|
|
|
L |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Красимир Беров (Krasimir Berov) |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Copyright 2013-2014 Красимир Беров (Krasimir Berov). |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or |
105
|
|
|
|
|
|
|
modify it under the terms of the |
106
|
|
|
|
|
|
|
GNU Lesser General Public License v3 (LGPL-3.0). |
107
|
|
|
|
|
|
|
You may copy, distribute and modify the software provided that |
108
|
|
|
|
|
|
|
modifications are open source. However, software that includes |
109
|
|
|
|
|
|
|
the license may release under a different license. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
See http://opensource.org/licenses/lgpl-3.0.html for more information. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |