$Yukki::Web::Router::VERSION
=
'0.990_001'
;
$Yukki::Web::Router::VERSION
=
'0.990001'
;
use
v5.24;
has
'+route_class'
=> (
default
=>
'Yukki::Web::Router::Route'
);
has
'+inline'
=> (
default
=> 0 );
has
app
=> (
is
=>
'ro'
,
isa
=> class_type(
'Yukki'
),
required
=> 1,
weak_ref
=> 1,
handles
=>
'Yukki::Role::App'
,
);
sub
BUILD {
my
$self
=
shift
;
$self
->add_route(
''
=> (
defaults
=> {
redirect
=>
'page/view/main'
,
},
acl
=> [
[
none
=> {
action
=>
sub
{ 1 } } ],
],
target
=>
$self
->controller(
'Redirect'
),
));
$self
->add_route(
'login/?:action'
=> (
defaults
=> {
action
=>
'page'
,
},
validations
=> {
action
=>
qr/^(?:page|submit|exit)$/
,
},
acl
=> [
[
none
=> {
action
=>
sub
{ 1 } } ],
],
target
=>
$self
->controller(
'Login'
),
));
$self
->add_route(
'profile/?:action'
=> (
defaults
=> {
action
=>
'profile'
,
},
validations
=> {
action
=>
qr/^(?:profile|update)$/
,
},
acl
=> [
[
none
=> {
action
=>
sub
{ 1 } } ],
],
target
=>
$self
->controller(
'Login'
),
));
$self
->add_route(
'logout'
=> (
defaults
=> {
action
=>
'exit'
,
},
acl
=> [
[
none
=> {
action
=>
'exit'
} ]
],
target
=>
$self
->controller(
'Login'
),
));
$self
->add_route(
'page/:action/:repository/*:page'
=> (
defaults
=> {
action
=>
'view'
,
repository
=>
'main'
,
},
validations
=> {
action
=>
qr/^(?:view|edit|history|diff|preview|attach|rename|remove)$/
,
repository
=>
qr/^[_a-z0-9]+$/
i,
page
=> declare as ArrayRef[Str], where {
all { /^[_a-z0-9-.]+(?:\.[_a-z0-9-]+)*$/i }
@$_
},
},
acl
=> [
[
read
=> {
action
=> [
qw( view preview history diff )
] } ],
[
write
=> {
action
=> [
qw( edit attach rename remove )
] } ],
],
target
=>
$self
->controller(
'Page'
),
));
$self
->add_route(
'attachment/:action/:repository/+:file'
=> (
defaults
=> {
action
=>
'download'
,
repository
=>
'main'
,
file
=> [
'untitled.txt'
],
},
validations
=> {
action
=>
qr/^(?:view|upload|download|rename|remove)$/
,
repository
=>
qr/^[_a-z0-9]+$/
i,
file
=> declare as ArrayRef[Str], where {
all { /^[_a-z0-9-]+(?:\.[_a-z0-9-]+)*$/i }
@$_
},
},
acl
=> [
[
read
=> {
action
=> [
qw( view download )
] } ],
[
write
=> {
action
=> [
qw( upload rename remove )
] } ],
],
target
=>
$self
->controller(
'Attachment'
),
));
}
1;