line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::UserName; |
2
|
1
|
|
|
1
|
|
33849
|
use Kwiki::Plugin -Base; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
4
|
|
|
|
|
|
|
use Kwiki ':char_classes'; |
5
|
|
|
|
|
|
|
our $VERSION = '0.14'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
const class_id => 'user_name'; |
8
|
|
|
|
|
|
|
const css_file => 'user_name.css'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub register { |
11
|
|
|
|
|
|
|
my $registry = shift; |
12
|
|
|
|
|
|
|
$registry->add(preload => 'user_name'); |
13
|
|
|
|
|
|
|
$registry->add(preference => $self->user_name); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub user_name { |
17
|
|
|
|
|
|
|
my $p = $self->new_preference('user_name'); |
18
|
|
|
|
|
|
|
$p->query('Enter a KwikiUserName to identify yourself.'); |
19
|
|
|
|
|
|
|
$p->type('input'); |
20
|
|
|
|
|
|
|
$p->size(15); |
21
|
|
|
|
|
|
|
$p->edit('check_user_name'); |
22
|
|
|
|
|
|
|
$p->default(''); |
23
|
|
|
|
|
|
|
return $p; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub check_user_name { |
27
|
|
|
|
|
|
|
my $preference = shift; |
28
|
|
|
|
|
|
|
my $value = $preference->new_value; |
29
|
|
|
|
|
|
|
$self->utf8_decode($value); |
30
|
|
|
|
|
|
|
return unless length $value; |
31
|
|
|
|
|
|
|
return $preference->error('Must be all alphanumeric characters.') |
32
|
|
|
|
|
|
|
unless $value =~ /^[$ALPHANUM]+$/; |
33
|
|
|
|
|
|
|
return $preference->error('Must be less than 30 characters.') |
34
|
|
|
|
|
|
|
unless length($value) < 30; |
35
|
|
|
|
|
|
|
$self->users->current(undef); |
36
|
|
|
|
|
|
|
return 1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__DATA__ |