line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::ShortcutLinks; |
2
|
1
|
|
|
1
|
|
35074
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
373
|
use Kwiki::Plugin '-Base'; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Kwiki::Installer '-base'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#use Kwiki::ShortcutLinks::Config; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.03; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
const class_title => 'Shortcut Links'; |
12
|
|
|
|
|
|
|
const class_id => 'shortcut_links'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
field shortcuts => undef; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub register { |
17
|
|
|
|
|
|
|
my $registry = shift; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my %config = Kwiki::ShortcutLinks::Config->new->all; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
foreach my $key (keys %config) { |
22
|
|
|
|
|
|
|
$registry->add(wafl => $key => 'Kwiki::ShortcutLinks::Wafl'); |
23
|
|
|
|
|
|
|
$registry->add(shortcut_links => $key => $config{$key}); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
package Kwiki::ShortcutLinks::Wafl; |
28
|
|
|
|
|
|
|
use Spoon::Formatter (); |
29
|
|
|
|
|
|
|
use base 'Spoon::Formatter::WaflPhrase'; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub html { |
32
|
|
|
|
|
|
|
my $text = $self->arguments; |
33
|
|
|
|
|
|
|
my $key = $self->method; |
34
|
|
|
|
|
|
|
my $shortcut = $self->hub->registry->lookup->{shortcut_links}{$key}[1]; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my ($url_prefix, $link_prefix) = ($shortcut =~ /^(\S+)\s*(.*)?$/); |
37
|
|
|
|
|
|
|
my ($url_param, $link_text) = ($text =~ /\A(.+?)(?:\|(.*))?\Z/); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$link_text ||= ($link_prefix ? "$link_prefix " : '') |
40
|
|
|
|
|
|
|
. $self->html_escape($url_param); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $url = $url_prefix; |
43
|
|
|
|
|
|
|
$url_param = $self->uri_escape($url_param); |
44
|
|
|
|
|
|
|
$url .= "%s" unless ($url =~ /%s/); |
45
|
|
|
|
|
|
|
$url =~ s/%s/$url_param/g; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
qq{$link_text}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
package Kwiki::ShortcutLinks::Config; |
51
|
|
|
|
|
|
|
use Spoon::Config '-Base'; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
const class_title => 'Shortcut Links Configuration'; |
54
|
|
|
|
|
|
|
const class_id => 'shortcut_links_config'; |
55
|
|
|
|
|
|
|
const config_file => 'shortcuts.yaml'; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub default_configs { $self->config_file } |
58
|
|
|
|
|
|
|
sub default_config { return { }; } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
package Kwiki::ShortcutLinks; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__DATA__ |