line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::Revisions; |
2
|
1
|
|
|
1
|
|
82252
|
use Kwiki::Plugin -Base; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
4
|
|
|
|
|
|
|
our $VERSION = '0.15'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
const class_id => 'revisions'; |
7
|
|
|
|
|
|
|
const cgi_class => 'Kwiki::Revisions::CGI'; |
8
|
|
|
|
|
|
|
field revision_id => 0; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub register { |
11
|
|
|
|
|
|
|
my $registry = shift; |
12
|
|
|
|
|
|
|
$registry->add(prerequisite => 'archive'); |
13
|
|
|
|
|
|
|
$registry->add(action => 'revisions'); |
14
|
|
|
|
|
|
|
$registry->add(toolbar => 'revisions_button', |
15
|
|
|
|
|
|
|
template => 'revisions_button.html', |
16
|
|
|
|
|
|
|
show_for => 'display', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
$registry->add(toolbar => 'revisions_controls', |
19
|
|
|
|
|
|
|
template => 'revisions_controls.html', |
20
|
|
|
|
|
|
|
show_for => 'revisions', |
21
|
|
|
|
|
|
|
params_class => $self->class_id, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub revisions { |
26
|
|
|
|
|
|
|
$self->render_screen($self->toolbar_params); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub toolbar_params { |
30
|
|
|
|
|
|
|
my $page = $self->pages->current; |
31
|
|
|
|
|
|
|
$page->load; |
32
|
|
|
|
|
|
|
my $revision_id = $self->cgi->revision_id |
33
|
|
|
|
|
|
|
or return $self->redirect($page->url); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $revisions = $page->revision_numbers; |
36
|
|
|
|
|
|
|
$revision_id = $revisions->[-$revision_id] if ($revision_id < 0); |
37
|
|
|
|
|
|
|
$self->revision_id($revision_id); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $archive = $self->hub->archive; |
40
|
|
|
|
|
|
|
$page->content($archive->fetch($page, $revision_id)); |
41
|
|
|
|
|
|
|
my $page_title = $page->title; |
42
|
|
|
|
|
|
|
my $screen_title = "$page_title (Revision $revision_id)"; |
43
|
|
|
|
|
|
|
my ($prev, $next); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
REVISIONS: { |
46
|
|
|
|
|
|
|
foreach my $index (0..$#$revisions) { |
47
|
|
|
|
|
|
|
$revisions->[$index] == $revision_id or next; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$prev = $revisions->[$index+1]; |
50
|
|
|
|
|
|
|
$next = $revisions->[$index-1] if $index; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$page->metadata->from_hash( |
53
|
|
|
|
|
|
|
$archive->fetch_metadata($page, $revision_id) |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
last REVISIONS; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
die "No such revision: $revision_id"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return ( |
62
|
|
|
|
|
|
|
screen_title => $screen_title, |
63
|
|
|
|
|
|
|
page_html => $page->to_html, |
64
|
|
|
|
|
|
|
revision_id => $revision_id, |
65
|
|
|
|
|
|
|
previous_id => $prev, |
66
|
|
|
|
|
|
|
next_id => $next, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
package Kwiki::Revisions::CGI; |
71
|
|
|
|
|
|
|
use Kwiki::CGI -base; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
cgi 'revision_id'; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
package Kwiki::Revisions; |
76
|
|
|
|
|
|
|
__DATA__ |