line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::TypeKey; |
2
|
1
|
|
|
1
|
|
29158
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
47
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
584
|
use Kwiki::UserName '-Base'; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 0.08; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
const class_id => 'user_name'; |
10
|
|
|
|
|
|
|
const class_title => 'Kwiki with TypeKey authentication'; |
11
|
|
|
|
|
|
|
const css_file => 'user_name.css'; |
12
|
|
|
|
|
|
|
const cgi_class => 'Kwiki::TypeKey::CGI'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
field -package => 'Kwiki::PageMeta', 'edit_by_icon'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub register { |
17
|
|
|
|
|
|
|
my $registry = shift; |
18
|
|
|
|
|
|
|
$registry->add(preload => 'user_name'); |
19
|
|
|
|
|
|
|
$registry->add(action => "return_typekey"); |
20
|
|
|
|
|
|
|
$registry->add(action => "logout_typekey"); |
21
|
|
|
|
|
|
|
$registry->add(hook => "page_metadata:sort_order", post => 'sort_order_hook'); |
22
|
|
|
|
|
|
|
$registry->add(hook => "page_metadata:update", post => 'update_hook'); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub sort_order_hook { |
26
|
|
|
|
|
|
|
my $hook = pop; |
27
|
|
|
|
|
|
|
return $hook->returned, 'edit_by_icon'; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub update_hook { |
31
|
|
|
|
|
|
|
my $meta = $self->hub->pages->current->metadata; |
32
|
|
|
|
|
|
|
$meta->edit_by_icon($self->hub->users->current->icon); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub return_typekey { |
36
|
|
|
|
|
|
|
my %cookie = map { ($_ => scalar $self->cgi->$_) } qw(email name nick ts sig); |
37
|
|
|
|
|
|
|
$cookie{icon} = $self->fetch_icon($cookie{name}); |
38
|
|
|
|
|
|
|
$self->hub->cookie->write(typekey => \%cookie); |
39
|
|
|
|
|
|
|
$self->redirect("?" . $self->cgi->page); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub fetch_icon { |
43
|
|
|
|
|
|
|
my $name = shift; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# WWW::Blog::Metadata is slow. Go easy with regexp. |
46
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
47
|
|
|
|
|
|
|
my $res = $ua->get("http://profile.typekey.com/$name/"); |
48
|
|
|
|
|
|
|
if ($res->is_success) { |
49
|
|
|
|
|
|
|
return ($res->content =~ m!\n\s*
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub logout_typekey { |
55
|
|
|
|
|
|
|
$self->hub->cookie->write(typekey => {}, { -expires => "-3d" }); |
56
|
|
|
|
|
|
|
$self->render_screen(content_pane => 'logout_typekey.html'); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
package Kwiki::TypeKey::CGI; |
60
|
|
|
|
|
|
|
use Kwiki::CGI '-Base'; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
cgi 'email'; |
63
|
|
|
|
|
|
|
cgi 'name'; |
64
|
|
|
|
|
|
|
cgi 'nick'; |
65
|
|
|
|
|
|
|
cgi 'ts'; |
66
|
|
|
|
|
|
|
cgi 'sig'; |
67
|
|
|
|
|
|
|
cgi 'page'; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
package Kwiki::TypeKey; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__DATA__ |