119 |
return Strix->new({ instance => $instance }); |
return Strix->new({ instance => $instance }); |
120 |
} |
} |
121 |
|
|
|
=head2 navigation |
|
|
|
|
|
=cut |
|
|
|
|
122 |
sub strix_link { |
sub strix_link { |
123 |
my ( $url, $label ) = @_; |
my ( $url, $label ) = @_; |
124 |
hyperlink( |
hyperlink( |
128 |
); |
); |
129 |
} |
} |
130 |
|
|
131 |
|
=head2 navigation |
132 |
|
|
133 |
|
=cut |
134 |
|
|
135 |
template 'navigation' => page { |
template 'navigation' => page { |
136 |
|
|
137 |
title is _('Site navigation'); |
title is _('Site navigation'); |
142 |
); |
); |
143 |
|
|
144 |
render_region( |
render_region( |
145 |
name => 'select-strix-site', |
name => 'strix-site', |
146 |
path => '/strix/select-site' |
path => '/strix/site' |
|
); |
|
|
|
|
|
}; |
|
|
|
|
|
=head2 layout |
|
|
|
|
|
=cut |
|
|
|
|
|
template 'layout' => page { |
|
|
|
|
|
my $url = get('url') || '/'; |
|
|
|
|
|
my $category = strix->category( $url ); |
|
|
|
|
|
warn dump( $category ); |
|
|
|
|
|
title is _('Layout %1 : %2', |
|
|
$category->{sitename}, |
|
|
$category->{naziv}, |
|
|
); |
|
|
|
|
|
render_region( |
|
|
name => 'selected-instances', |
|
|
path => '/strix/selected-instances' |
|
147 |
); |
); |
148 |
|
|
|
strix_link( $category->{url}, $category->{naziv} ); |
|
|
|
|
|
my $layout = strix->layout( $url ); |
|
|
|
|
|
pre { |
|
|
dump( $layout ); |
|
|
} |
|
|
|
|
149 |
}; |
}; |
150 |
|
|
151 |
=head1 REGIONS |
=head1 REGIONS |
238 |
# warn "## IN selected-instances ",dump( @_ ); |
# warn "## IN selected-instances ",dump( @_ ); |
239 |
|
|
240 |
if ( my $op = get 'op' ) { |
if ( my $op = get 'op' ) { |
241 |
my $op_instance = get 'op_instance' or die "no op_instance?"; |
my $op_instance = get 'op_instance'; |
242 |
|
return unless $op_instance; |
243 |
warn "# selected-instances $op on $op_instance"; |
warn "# selected-instances $op on $op_instance"; |
244 |
|
|
245 |
my $a; |
my $a; |
339 |
|
|
340 |
}; |
}; |
341 |
|
|
342 |
=head2 select-site |
=head2 site |
343 |
|
|
344 |
=cut |
=cut |
345 |
|
|
346 |
template 'select-site' => sub { |
template 'site' => sub { |
347 |
|
|
348 |
my $action = new_action( |
my $action = new_action( |
349 |
class => 'StrixSelectSite', |
class => 'StrixSelectSite', |
365 |
# this is basically a closure |
# this is basically a closure |
366 |
{ refresh => 'selected-instances', path => '/strix/selected-instances', args => { |
{ refresh => 'selected-instances', path => '/strix/selected-instances', args => { |
367 |
instance => { result_of => $action, name => 'instance' } |
instance => { result_of => $action, name => 'instance' } |
368 |
} } |
} }, |
369 |
|
{ refresh => 'strix-site-layout', path => '/__jifty/empty' }, |
370 |
]; |
]; |
371 |
|
|
372 |
form { |
form { |
377 |
|
|
378 |
warn "## select-site action ",dump( $action->result ); |
warn "## select-site action ",dump( $action->result ); |
379 |
|
|
380 |
|
render_region( |
381 |
|
name => 'layout', |
382 |
|
path => '/__jifty/empty', |
383 |
|
); |
384 |
|
|
385 |
if ( my $site_id = $action->result->content('site_id') ) { |
if ( my $site_id = $action->result->content('site_id') ) { |
386 |
show('strix-site-navigation-tree', $action->result->content('instance'), $site_id); |
show('navigation-tree', $action->result->content('instance'), $site_id); |
387 |
|
} |
388 |
|
}; |
389 |
|
|
390 |
|
=head2 layout |
391 |
|
|
392 |
|
Shows layout for C<url> |
393 |
|
|
394 |
|
=cut |
395 |
|
|
396 |
|
template 'layout' => sub { |
397 |
|
|
398 |
|
my $url = get('url') || '/'; |
399 |
|
my $category = strix->category( $url ); |
400 |
|
my $layout = strix->layout( $url ); |
401 |
|
|
402 |
|
h1 { $category->{naziv} } |
403 |
|
pre { |
404 |
|
dump( $layout ); |
405 |
|
} |
406 |
|
|
407 |
|
}; |
408 |
|
|
409 |
|
=head2 category |
410 |
|
|
411 |
|
Show category data for C<url> |
412 |
|
|
413 |
|
=cut |
414 |
|
|
415 |
|
template 'category' => sub { |
416 |
|
|
417 |
|
my $url = get('url') || '/'; |
418 |
|
my $category = strix->category( $url ); |
419 |
|
|
420 |
|
h1 { $category->{naziv} } |
421 |
|
pre { |
422 |
|
dump( $category ); |
423 |
} |
} |
424 |
|
|
425 |
}; |
}; |
426 |
|
|
427 |
=head1 PRIVATE TEMPLATES |
=head1 PRIVATE TEMPLATES |
428 |
|
|
429 |
=head2 strix-site-navigation-tree |
=head2 navigation-tree-category |
430 |
|
|
431 |
show('strix-site-navigation-tree',$instance,$site_id); |
show('navigation-tree-category',$kat_row); |
432 |
|
|
433 |
=cut |
=cut |
434 |
|
|
435 |
private template 'strix-site-navigation-tree' => sub { |
private template 'navigation-tree-category' => sub { |
436 |
|
my $self = shift; |
437 |
|
#warn "## navigation-tree-category",dump( @_ ); |
438 |
|
my $p = shift; |
439 |
|
hyperlink( |
440 |
|
onclick => { |
441 |
|
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
442 |
|
replace_with => '/strix/category', |
443 |
|
args => { |
444 |
|
url => $p->{url}, |
445 |
|
instance => get('instance'), |
446 |
|
} |
447 |
|
}, |
448 |
|
label => $p->{naziv}, |
449 |
|
); |
450 |
|
outs_raw(' '); |
451 |
|
if ( $p->{type} eq 'category' ) { |
452 |
|
hyperlink( |
453 |
|
# url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), |
454 |
|
onclick => { |
455 |
|
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
456 |
|
replace_with => '/strix/layout', |
457 |
|
args => { |
458 |
|
url => $p->{url}, |
459 |
|
instance => get('instance'), |
460 |
|
} |
461 |
|
}, |
462 |
|
label => _('layout'), |
463 |
|
class => 'layout', |
464 |
|
); |
465 |
|
} |
466 |
|
outs_raw(' '); |
467 |
|
strix_link( $p->{url}, '>>' ); |
468 |
|
}; |
469 |
|
|
470 |
|
=head2 navigation-tree |
471 |
|
|
472 |
|
show('navigation-tree',$instance,$site_id); |
473 |
|
|
474 |
|
=cut |
475 |
|
|
476 |
|
private template 'navigation-tree' => sub { |
477 |
my $self = shift; |
my $self = shift; |
478 |
my ( $instance, $site_id ) = @_; |
my ( $instance, $site_id ) = @_; |
479 |
|
|
480 |
warn ">>>> instance: $instance site_id: $site_id"; |
warn "## navigation-tree instance: $instance site_id: $site_id"; |
481 |
|
|
482 |
set 'instance' => $instance; |
set 'instance' => $instance; |
483 |
|
|
|
sub full_url { |
|
|
my $p = shift; |
|
|
strix_link( $p->{url}, $p->{naziv} ); |
|
|
if ( $p->{type} eq 'category' ) { |
|
|
outs_raw(' '); |
|
|
hyperlink( |
|
|
url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), |
|
|
label => _('layout'), |
|
|
class => 'layout', |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
484 |
sub children { |
sub children { |
485 |
my $c = shift; |
my $c = shift; |
486 |
return unless defined $c->{children}; |
return unless defined $c->{children}; |
487 |
ul { |
ul { |
488 |
foreach my $p ( @{ $c->{children} } ) { |
foreach my $p ( @{ $c->{children} } ) { |
489 |
li { |
li { |
490 |
{ class is $p->{class} }; |
if ( defined( $p->{class} ) ) { |
491 |
full_url( $p ); |
{ class is $p->{class} }; |
492 |
|
} |
493 |
|
show( 'navigation-tree-category', $p ); |
494 |
children( $p ); |
children( $p ); |
495 |
} |
} |
496 |
} |
} |
499 |
|
|
500 |
my $strix = Strix->new({ instance => $instance }); |
my $strix = Strix->new({ instance => $instance }); |
501 |
|
|
502 |
my @navigation = @{ $strix->site_navigation( $site_id ) }; |
my $navigation = $strix->site_navigation( $site_id ); |
503 |
if ( @navigation ) { |
#warn "## navigation = ",dump( $navigation ); |
504 |
|
if ( $navigation ) { |
505 |
ul { |
ul { |
506 |
foreach my $p ( @navigation ) { |
{ class is 'navigation' }; |
507 |
|
foreach my $p ( @$navigation ) { |
508 |
li { |
li { |
509 |
full_url( $p ); |
show( 'navigation-tree-category', $p ); |
510 |
children( $p ); |
children( $p ); |
511 |
} |
} |
512 |
} |
} |