| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Kwiki::Widgets::RandomQuote; |
|
2
|
1
|
|
|
1
|
|
1194
|
use Kwiki::Plugin -Base; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
|
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
const class_id => 'widgets_random_quote'; |
|
7
|
|
|
|
|
|
|
const class_title => 'Random Qoute'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub register { |
|
10
|
|
|
|
|
|
|
my $registry = shift; |
|
11
|
|
|
|
|
|
|
$registry->add(widget => 'random_quote', |
|
12
|
|
|
|
|
|
|
template => 'widgets_random_quote.html'); |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# This could be a really slow function. |
|
16
|
|
|
|
|
|
|
sub show { |
|
17
|
|
|
|
|
|
|
my @pages = $self->pages->all_ids_newest_first; |
|
18
|
|
|
|
|
|
|
my $page = $self->pages->new_page($pages[int(rand(@pages))]); |
|
19
|
|
|
|
|
|
|
my @paragraphs = split(/\n+/,$page->content); |
|
20
|
|
|
|
|
|
|
my $choosen = @paragraphs[int(rand(@paragraphs))]; |
|
21
|
|
|
|
|
|
|
return $self->hub->formatter->text_to_html($choosen); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__DATA__ |