line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CogWiki; |
2
|
2
|
|
|
2
|
|
1083
|
use 5.008003; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
3
|
2
|
|
|
2
|
|
859
|
use Mouse; |
|
2
|
|
|
|
|
46060
|
|
|
2
|
|
|
|
|
9
|
|
4
|
|
|
|
|
|
|
extends 'Cog::App'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
640
|
use constant webapp_class => 'CogWiki::WebApp'; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
213
|
|
9
|
2
|
|
|
2
|
|
9
|
use constant maker_class => 'CogWiki::Maker'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
93
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package CogWiki::WebApp; |
12
|
2
|
|
|
2
|
|
8
|
use Mouse; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
6
|
|
13
|
|
|
|
|
|
|
extends 'Cog::WebApp'; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
477
|
use constant SHARE_DIST => 'CogWiki'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
129
|
|
16
|
2
|
|
|
|
|
131
|
use constant url_map => [ |
17
|
|
|
|
|
|
|
'()', |
18
|
|
|
|
|
|
|
['/' => 'redirect', ('/pages/')], |
19
|
|
|
|
|
|
|
['/home/?' => 'home_page'], |
20
|
|
|
|
|
|
|
['/pages/?' => 'page_list'], |
21
|
|
|
|
|
|
|
['/page/([A-Z0-9]{4})/?' => 'page_display', ('$1')], |
22
|
|
|
|
|
|
|
['/page/name/([^/]+)/?' => 'page_by_name', ('$1')], |
23
|
|
|
|
|
|
|
['/tags/' => 'tag_list' ], |
24
|
|
|
|
|
|
|
['/tag/([^/]+)/?' => 'tag_page_list', ('$1')], |
25
|
2
|
|
|
2
|
|
7
|
]; |
|
2
|
|
|
|
|
2
|
|
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
80
|
use constant site_navigation => [ |
28
|
|
|
|
|
|
|
'()', |
29
|
|
|
|
|
|
|
['Home' => '/home/'], |
30
|
|
|
|
|
|
|
['Recent Changes' => '/pages/'], |
31
|
|
|
|
|
|
|
['Tags' => '/tags/'], |
32
|
2
|
|
|
2
|
|
8
|
]; |
|
2
|
|
|
|
|
2
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
package CogWiki::Maker; |
35
|
2
|
|
|
2
|
|
8
|
use Mouse; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
6
|
|
36
|
|
|
|
|
|
|
extends 'Cog::Maker'; |
37
|
2
|
|
|
2
|
|
1586
|
use IO::All; |
|
2
|
|
|
|
|
20081
|
|
|
2
|
|
|
|
|
16
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub all_files { |
40
|
0
|
|
|
0
|
|
|
my $self = shift; |
41
|
0
|
|
|
|
|
|
return grep { |
42
|
0
|
|
|
|
|
|
$_->filename =~ /\.cog$/; |
43
|
|
|
|
|
|
|
} io($self->config->content_root)->all_files; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub make_cache { |
47
|
0
|
|
|
0
|
|
|
my $self = shift; |
48
|
0
|
|
|
|
|
|
io('cache')->mkdir; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $time = time; |
51
|
0
|
|
|
|
|
|
my $page_list = []; |
52
|
0
|
|
|
|
|
|
my $blobs = {}; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$self->config->store->delete_tag_index; # XXX Temporary solution until can do smarter |
55
|
0
|
|
|
|
|
|
for my $page_file ($self->all_files) { |
56
|
0
|
|
|
|
|
|
my $page = $self->config->classes->{page}->from_text($page_file->all); |
57
|
0
|
0
|
|
|
|
|
my $id = $page->Short or next; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
for my $Name (@{$page->Name}) { |
|
0
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $name = $self->config->store->index_name($Name, $id); |
61
|
0
|
|
|
|
|
|
io->file("cache/name/$name.txt")->assert->print($id); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$self->config->store->index_tag($_, $id) |
65
|
0
|
|
|
|
|
|
for $self->all_tags($page); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $blob = { |
68
|
|
|
|
|
|
|
%$page, |
69
|
|
|
|
|
|
|
Id => $id, |
70
|
|
|
|
|
|
|
Type => $page->Type, |
71
|
|
|
|
|
|
|
Title => $page->Title, |
72
|
|
|
|
|
|
|
Time => $page->Time, |
73
|
|
|
|
|
|
|
size => length($page->Content), |
74
|
|
|
|
|
|
|
duration => $page->duration, |
75
|
|
|
|
|
|
|
}; |
76
|
0
|
|
|
|
|
|
delete $blob->{Content}; |
77
|
0
|
|
|
|
|
|
delete $blob->{Name}; |
78
|
0
|
|
|
|
|
|
push @$page_list, $blob; |
79
|
0
|
|
|
|
|
|
$blobs->{$id} = $blob; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$self->make_page_html($page, $page_file); |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
delete $page->{content}; |
84
|
0
|
|
|
|
|
|
io("cache/$id.json")->print($self->json->encode($blob)); |
85
|
|
|
|
|
|
|
} |
86
|
0
|
|
|
|
|
|
io("cache/page-list.json")->print($self->json->encode($page_list)); |
87
|
0
|
|
|
|
|
|
$self->make_tag_cloud($blobs); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub make_page_html { |
91
|
0
|
|
|
0
|
|
|
my $self = shift; |
92
|
0
|
|
|
|
|
|
my $page = shift; |
93
|
0
|
|
|
|
|
|
my $page_file = shift; |
94
|
0
|
|
|
|
|
|
my $id = $page->Short; |
95
|
0
|
|
|
|
|
|
my $html_filename = "cache/$id.html"; |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
0
|
|
|
|
return if -e $html_filename and -M $html_filename < -M $page_file->name; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
0
|
|
|
|
my $markup = $page->markup || 'simple'; |
100
|
0
|
|
|
|
|
|
my $method = "${markup}_to_html"; |
101
|
0
|
|
|
|
|
|
my $html = $self->$method($page->Content); |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
print $page_file->filename . " -> $html_filename\n"; |
104
|
0
|
|
|
|
|
|
io($html_filename)->assert->print($html); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub html_to_html { |
108
|
0
|
|
|
0
|
|
|
return $_[1]; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub txt_to_html { |
112
|
0
|
|
|
0
|
|
|
my $self = shift; |
113
|
0
|
|
|
|
|
|
my $html = shift; |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$html =~ s/&/&/g; |
116
|
0
|
|
|
|
|
|
$html =~ s/</g; |
117
|
0
|
|
|
|
|
|
$html =~ s/>/>/g; |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
$html = "$html \n"; |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
return $html; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub pod_to_html { |
125
|
0
|
|
|
0
|
|
|
my $self = shift; |
126
|
0
|
|
|
|
|
|
my $pod = shift; |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $html; |
129
|
0
|
|
|
|
|
|
my $p = Pod::Simple::HTML->new; |
130
|
0
|
|
|
|
|
|
$p->output_string(\$html); |
131
|
0
|
|
|
|
|
|
$p->parse_string_document($pod); |
132
|
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
|
$html =~ s/.*!-- start doc -->(.*?) |