line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Blikistan::MagicEngine::Perl; |
2
|
1
|
|
|
1
|
|
997
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
4
|
1
|
|
|
1
|
|
4
|
use base 'Blikistan::MagicEngine::TT2'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
665
|
|
5
|
|
|
|
|
|
|
use base 'Blikistan::MagicEngine::YamlConfig'; |
6
|
|
|
|
|
|
|
use URI::Escape; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub print_blog { |
9
|
|
|
|
|
|
|
my $self = shift; |
10
|
|
|
|
|
|
|
my $r = $self->{rester}; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $params = $self->load_config; |
13
|
|
|
|
|
|
|
$params->{rester} = $r; |
14
|
|
|
|
|
|
|
$params->{blog_tag} ||= $self->{blog_tag}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
if (my $who = $self->{subblog}) { |
17
|
|
|
|
|
|
|
my $sub_tag = $params->{subblogs}{$who}; |
18
|
|
|
|
|
|
|
$params->{blog_tag} = $sub_tag ? $sub_tag->{blog_tag} : $who; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $show_latest = delete $params->{show_latest_posts} |
22
|
|
|
|
|
|
|
|| $self->{show_latest_posts}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my @posts = $r->get_taggedpages($params->{blog_tag}); |
25
|
|
|
|
|
|
|
@posts = splice @posts, 0, $show_latest; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$r->accept('text/html'); |
28
|
|
|
|
|
|
|
$params->{posts} = [ |
29
|
|
|
|
|
|
|
map { |
30
|
|
|
|
|
|
|
title => $_, |
31
|
|
|
|
|
|
|
content => _get_page($r, $_), |
32
|
|
|
|
|
|
|
permalink => _linkify($r, $_), |
33
|
|
|
|
|
|
|
date => scalar($r->response->header('Last-Modified')), |
34
|
|
|
|
|
|
|
}, @posts, |
35
|
|
|
|
|
|
|
]; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
return $self->render_template( $params ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _linkify { |
41
|
|
|
|
|
|
|
my $r = shift; |
42
|
|
|
|
|
|
|
my $page = uri_escape(shift); |
43
|
|
|
|
|
|
|
return $r->server . '/' . $r->workspace . "/index.cgi?$page"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _get_page { |
47
|
|
|
|
|
|
|
my $r = shift; |
48
|
|
|
|
|
|
|
my $page_name = shift; |
49
|
|
|
|
|
|
|
my $html = $r->get_page($page_name) || ''; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
while ($html =~ s/
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$html =~ s#^ (.+) \s*$#$1#s; |
54
|
|
|
|
|
|
|
return $html; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|