line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DocLife::Markdown; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
31120
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
891
|
use parent 'DocLife'; |
|
1
|
|
|
|
|
276
|
|
|
1
|
|
|
|
|
4
|
|
6
|
1
|
|
|
1
|
|
157
|
use Plack::Util::Accessor qw(tm); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
1287
|
use Text::Markdown; |
|
1
|
|
|
|
|
39984
|
|
|
1
|
|
|
|
|
599
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub prepare_app { |
10
|
5
|
|
|
5
|
1
|
39961
|
my ($self, $env) = @_; |
11
|
5
|
|
|
|
|
33
|
$self->SUPER::prepare_app($env); |
12
|
5
|
|
|
|
|
1110
|
my $tm = Text::Markdown->new; |
13
|
5
|
|
|
|
|
97
|
$self->tm($tm); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub format { |
17
|
3
|
|
|
3
|
0
|
8
|
my ($self, $req, $res, $file) = @_; |
18
|
3
|
|
|
|
|
16
|
my $text = $file->slurp; |
19
|
3
|
|
|
|
|
818
|
my ($title) = $text=~m|^#\s(.*)|; |
20
|
3
|
50
|
|
|
|
12
|
unless ($title) { |
21
|
0
|
|
|
|
|
0
|
$title = $file->basename; |
22
|
0
|
|
|
|
|
0
|
my $suffix = $self->suffix; |
23
|
0
|
|
|
|
|
0
|
$title=~s|\Q$suffix\E$||; |
24
|
|
|
|
|
|
|
} |
25
|
3
|
|
|
|
|
14
|
my $body = $self->html_header($title,$req); |
26
|
3
|
|
|
|
|
15
|
$body.= $self->tm->markdown($text); |
27
|
3
|
|
|
|
|
6892
|
$body.= $self->html_footer; |
28
|
3
|
|
|
|
|
25
|
$res->body($body); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub script { |
32
|
3
|
|
|
3
|
0
|
7
|
my ($self,$req) = @_; |
33
|
3
|
50
|
|
|
|
10
|
return unless $req; |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
14
|
my $int = $req->param('refresh'); |
36
|
3
|
50
|
|
|
|
608
|
return '' unless $int; |
37
|
|
|
|
|
|
|
<<"EOF" |
38
|
|
|
|
|
|
|
window.setInterval( function() { |
39
|
|
|
|
|
|
|
window.location.reload(); |
40
|
|
|
|
|
|
|
}, $int ); |
41
|
|
|
|
|
|
|
EOF |
42
|
0
|
|
|
|
|
0
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub style { |
45
|
|
|
|
|
|
|
<<"EOF" |
46
|
|
|
|
|
|
|
*{ margin:0; padding:0; font-family: arial,sans-serif; } |
47
|
|
|
|
|
|
|
body{ margin: 0 auto; width: 920px; padding: 0 0 30px; font-size: 14px; line-height: 23px; overflow-y: scroll; } |
48
|
|
|
|
|
|
|
a{ color: #4183C4; text-decoration: none; } |
49
|
|
|
|
|
|
|
header {margin: 15px 0 15px;} |
50
|
|
|
|
|
|
|
header nav{text-align: center;} |
51
|
|
|
|
|
|
|
article{padding: .7em;border: 1px solid #E9E9E9;background-color: #F8F8F8;} |
52
|
|
|
|
|
|
|
article h1,article h2,article h3,article h4,article h5,article h6{border:0!important;} |
53
|
|
|
|
|
|
|
article h1{font-size:170%!important;border-top:4px solid #aaa!important;padding-top:.5em!important;margin-top:1.5em!important;} |
54
|
|
|
|
|
|
|
article h1:first-child{margin-top:0!important;padding-top:.25em!important;border-top:none!important;} |
55
|
|
|
|
|
|
|
article h2{font-size:150%!important;margin-top:1.5em!important;border-top:4px solid #e0e0e0!important;padding-top:.5em!important;} |
56
|
|
|
|
|
|
|
article h3{margin-top:1em!important;} |
57
|
|
|
|
|
|
|
article hr{border:1px solid #ddd;} |
58
|
|
|
|
|
|
|
article p{margin:1em 0!important;line-height:1.5em!important;} |
59
|
|
|
|
|
|
|
article a.absent{color:#a00;} |
60
|
|
|
|
|
|
|
article ul{margin:1em 0 1em 2em!important;} |
61
|
|
|
|
|
|
|
article ol{margin:1em 0 1em 2em!important;} |
62
|
|
|
|
|
|
|
article ul li{margin-top:.5em;margin-bottom:.5em;} |
63
|
|
|
|
|
|
|
article ul ul,article ul ol,article ol ol,article ol ul{margin-top:0!important;margin-bottom:0!important;} |
64
|
|
|
|
|
|
|
article blockquote{margin:1em 0!important;border-left:5px solid #ddd!important;padding-left:.6em!important;color:#555!important;} |
65
|
|
|
|
|
|
|
article dt{font-weight:bold!important;margin-left:1em!important;} |
66
|
|
|
|
|
|
|
article dd{margin-left:2em!important;margin-bottom:1em!important;} |
67
|
|
|
|
|
|
|
article table{margin:1em 0!important;} |
68
|
|
|
|
|
|
|
article table th{border-bottom:1px solid #bbb!important;padding:.2em 1em!important;} |
69
|
|
|
|
|
|
|
article table td{border-bottom:1px solid #ddd!important;padding:.2em 1em!important;} |
70
|
|
|
|
|
|
|
article pre{margin:1em 0;font-size:12px;background-color:#eee;border:1px solid #ddd;padding:5px;line-height:1.5em;color:#444;overflow:auto;-webkit-box-shadow:rgba(0,0,0,0.07) 0 1px 2px inset;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;} |
71
|
|
|
|
|
|
|
article pre::-webkit-scrollbar{height:8px;width:8px;} |
72
|
|
|
|
|
|
|
article pre::-webkit-scrollbar-track-piece{margin-bottom:10px;background-color:#e5e5e5;border-bottom-left-radius:4px 4px;border-bottom-right-radius:4px 4px;border-top-left-radius:4px 4px;border-top-right-radius:4px 4px;} |
73
|
|
|
|
|
|
|
article pre::-webkit-scrollbar-thumb:vertical{height:25px;background-color:#ccc;-webkit-border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(255,255,255,1);} |
74
|
|
|
|
|
|
|
article pre::-webkit-scrollbar-thumb:horizontal{width:25px;background-color:#ccc;-webkit-border-radius:4px;} |
75
|
|
|
|
|
|
|
article pre code{ |
76
|
|
|
|
|
|
|
font-family: Monaco, Monospace; |
77
|
|
|
|
|
|
|
padding:0!important;font-size:12px!important;background-color:#eee!important;border:none!important; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
article code{ |
80
|
|
|
|
|
|
|
font-size:12px!important;background-color:#f8f8ff!important;color:#444!important;padding:0 .2em!important;border:1px solid #dedede!important; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
article a code,article a:link code,article a:visited code{color:#4183c4!important;} |
83
|
|
|
|
|
|
|
article img{max-width:100%;} |
84
|
|
|
|
|
|
|
EOF |
85
|
3
|
|
|
3
|
0
|
8
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub html_header { |
88
|
3
|
|
|
3
|
0
|
6
|
my ($self, $title, $req) = @_; |
89
|
3
|
|
50
|
|
|
10
|
$title ||= 'Index'; |
90
|
|
|
|
|
|
|
|
91
|
3
|
|
|
|
|
12
|
my $style = $self->style; |
92
|
3
|
|
|
|
|
14
|
my $script = $self->script( $req ); |
93
|
|
|
|
|
|
|
|
94
|
3
|
|
|
|
|
13
|
my $top = $self->base_url; |
95
|
|
|
|
|
|
|
<<"EOF" |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$title |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
TOP |
106
|
|
|
|
|
|
|
Auto Refresh |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
EOF |
110
|
3
|
|
|
|
|
60
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub html_footer { |
113
|
|
|
|
|
|
|
<<"EOF" |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
EOF |
118
|
3
|
|
|
3
|
0
|
12
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 NAME |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
DocLife::Markdown - Markdown Viewer. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SYNOPSIS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# app.psgi |
127
|
|
|
|
|
|
|
use DocLife::Markdown; |
128
|
|
|
|
|
|
|
DocLife::Markdown->new( root => "./doc", suffix => ".md" ); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# one-liner |
131
|
|
|
|
|
|
|
plackup -MDocLife::Markdown -e 'DocLife::Markdown->new( root => "./doc" )->to_app' |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SEE ALSO |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L, L |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |