line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::Display; |
2
|
1
|
|
|
1
|
|
1947
|
use Kwiki::Plugin -Base; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
const config_file => 'display.yaml'; |
6
|
|
|
|
|
|
|
const class_id => 'display'; |
7
|
|
|
|
|
|
|
const class_title => 'Page Display'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub register { |
10
|
|
|
|
|
|
|
my $registry = shift; |
11
|
|
|
|
|
|
|
$registry->add(action => 'display'); |
12
|
|
|
|
|
|
|
$registry->add(toolbar => 'home_button', |
13
|
|
|
|
|
|
|
template => 'home_button.html', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
$registry->add(preference => $self->display_changed_by); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub display_changed_by { |
19
|
|
|
|
|
|
|
my $p = $self->new_preference('display_changed_by'); |
20
|
|
|
|
|
|
|
$p->query('Show a "Changed by ..." section on each page?'); |
21
|
|
|
|
|
|
|
$p->default(0); |
22
|
|
|
|
|
|
|
return $p; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub display { |
26
|
|
|
|
|
|
|
my $page = $self->pages->current; |
27
|
|
|
|
|
|
|
return $self->redirect('') |
28
|
|
|
|
|
|
|
unless $page; |
29
|
|
|
|
|
|
|
my $page_title = $page->title; |
30
|
|
|
|
|
|
|
my $page_uri = $page->uri; |
31
|
|
|
|
|
|
|
return $self->redirect("action=edit;page_name=$page_uri") |
32
|
|
|
|
|
|
|
if not($page->exists) and $self->have_plugin('edit'); |
33
|
|
|
|
|
|
|
my $script = $self->config->script_name; |
34
|
|
|
|
|
|
|
my $screen_title = $self->hub->have_plugin('search') |
35
|
|
|
|
|
|
|
? "$page_title" |
36
|
|
|
|
|
|
|
: $page_title; |
37
|
|
|
|
|
|
|
eval { |
38
|
|
|
|
|
|
|
$page->content; |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
if ($@) { |
41
|
|
|
|
|
|
|
my $main_page = $self->config->main_page; |
42
|
|
|
|
|
|
|
die $@ if $page->title eq $main_page; |
43
|
|
|
|
|
|
|
return $self->redirect($main_page); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
$self->render_screen( |
46
|
|
|
|
|
|
|
screen_title => $screen_title, |
47
|
|
|
|
|
|
|
page_html => $page->to_html, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__DATA__ |