45 |
|
|
46 |
}; |
}; |
47 |
|
|
48 |
=head2 name_diff |
=head2 errors |
49 |
|
|
50 |
=cut |
=cut |
51 |
|
|
52 |
template 'name_diff' => page { |
template 'errors' => page { |
53 |
|
|
54 |
title is _('Strix name differences'); |
title is _('Strix errors'); |
55 |
|
|
56 |
render_region( |
render_region( |
57 |
name => 'selected-instances', |
name => 'selected-instances', |
58 |
path => '/strix/selected-instances' |
path => '/strix/selected-instances' |
59 |
); |
); |
60 |
|
|
61 |
|
h2 { _('Name differences') } |
62 |
|
|
63 |
my $name_diff = A3C::SQL->new({ query => qq{ |
my $name_diff = A3C::SQL->new({ query => qq{ |
64 |
select |
select |
65 |
instance,hreduorgurl, |
instance,hreduorgurl, |
94 |
|
|
95 |
}; |
}; |
96 |
|
|
97 |
|
=head2 instances |
98 |
|
|
99 |
|
=cut |
100 |
|
|
101 |
|
template 'instances' => page { |
102 |
|
|
103 |
|
title is _('Strix instances'); |
104 |
|
|
105 |
|
my $sql = A3C::SQL->new({ query => qq{ |
106 |
|
select |
107 |
|
hrEduOrgUrl, o, l, postalAddress, telephoneNumber, facsimileTelephoneNumber |
108 |
|
from strix_instances |
109 |
|
join hr_edu_orgs on cn = instance |
110 |
|
order by l,o |
111 |
|
}}); |
112 |
|
|
113 |
|
if ( $sql->count > 0 ) { |
114 |
|
|
115 |
|
table { |
116 |
|
row { |
117 |
|
th { _('hrEduOrgUrl') } |
118 |
|
th { _('o') } |
119 |
|
th { _('l') } |
120 |
|
th { _('postalAddress') } |
121 |
|
th { _('telephoneNumber') } |
122 |
|
th { _('facsimileTelephoneNumber') } |
123 |
|
}; |
124 |
|
while ( my $row = $sql->next ) { |
125 |
|
row { |
126 |
|
cell { outs_raw '<a href="http://' . $row->hrEduOrgUrl . '">' . $row->hrEduOrgUrl . '</a>' } |
127 |
|
cell { $row->o } |
128 |
|
cell { $row->l } |
129 |
|
cell { $row->postalAddress } |
130 |
|
cell { $row->telephoneNumber } |
131 |
|
cell { $row->facsimileTelephoneNumber } |
132 |
|
} |
133 |
|
} |
134 |
|
} |
135 |
|
|
136 |
|
div { _("Found total of %1 strix instances", $sql->count) } |
137 |
|
|
138 |
|
} else { |
139 |
|
div { _("Can't find any strix instances") } |
140 |
|
} |
141 |
|
|
142 |
|
}; |
143 |
|
|
144 |
=head2 sql |
=head2 sql |
145 |
|
|
146 |
Execute SQL query on instance |
Execute SQL query on instance |
171 |
sub strix_link { |
sub strix_link { |
172 |
my ( $url, $label ) = @_; |
my ( $url, $label ) = @_; |
173 |
hyperlink( |
hyperlink( |
174 |
url => 'http://' . get('instance') . '.cms-qa.skole.hr' . $url, |
url => 'http://' . get('instance') . Jifty->config->app('strix')->{domain} . $url, |
175 |
label => $label || $url, |
label => $label || $url, |
176 |
target => 'strix', |
target => 'strix', |
177 |
); |
); |
197 |
|
|
198 |
}; |
}; |
199 |
|
|
|
=head2 layout |
|
|
|
|
|
=cut |
|
|
|
|
|
template 'layout' => sub { |
|
|
|
|
|
my $url = get('url') || '/'; |
|
|
|
|
|
my $category = strix->category( $url ); |
|
|
|
|
|
warn dump( $category ); |
|
|
|
|
|
strix_link( $category->{url}, $category->{naziv} ); |
|
|
|
|
|
my $layout = strix->layout( $url ); |
|
|
|
|
|
pre { |
|
|
dump( $layout ); |
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
200 |
=head1 REGIONS |
=head1 REGIONS |
201 |
|
|
202 |
=head2 execute-sql |
=head2 execute-sql |
207 |
|
|
208 |
template 'execute-sql' => sub { |
template 'execute-sql' => sub { |
209 |
|
|
210 |
|
my $sql = get('sql') || Jifty->web->session->get('sql'); |
211 |
|
warn ">>>> sql = $sql"; |
212 |
|
my $instance = get('instance'); |
213 |
|
warn ">>>> instance = $instance"; |
214 |
|
|
215 |
my $action = new_action( |
my $action = new_action( |
216 |
class => 'StrixSQL', |
class => 'StrixSQL', |
217 |
moniker => 'strix-sql', |
moniker => 'strix-sql', |
218 |
sticky_on_success => 1, |
sticky_on_success => 1, |
219 |
sticky_on_failure => 1, |
sticky_on_failure => 1, |
220 |
arguments => { |
arguments => { |
221 |
instance => get('instance') |
instance => $instance, |
222 |
} |
sql => $sql, |
223 |
|
}, |
224 |
); |
); |
225 |
|
|
226 |
form { |
form { |
227 |
render_action( $action => [ 'instance', 'sql' ] ); |
render_action( $action, [ 'instance', 'sql' ] ); |
228 |
form_submit( label => _('Execute SQL') ); |
form_submit( label => _('Execute SQL') ); |
229 |
}; |
}; |
230 |
|
|
231 |
if ( my $sql = $action->result->content('sql') ) { |
if ( my $sql = $action->result->content('sql') ) { |
232 |
div { _('Found %1 results', $sql->count ) } |
Jifty->web->session->set( sql => $sql->query ); |
233 |
|
div { _('Found %1 results for %2', $sql->count, $instance ) } |
234 |
table { |
table { |
235 |
row { map { th { $_ } } $sql->_column_names }; |
row { map { th { $_ } } $sql->_column_names }; |
236 |
while (my $row = $sql->next) { |
while (my $row = $sql->next) { |
242 |
} |
} |
243 |
} |
} |
244 |
} |
} |
245 |
|
warn ">>>> sql (at end) = ",Jifty->web->session->get('sql'); |
246 |
}; |
}; |
247 |
|
|
248 |
=head2 search-instances |
=head2 search-instances |
440 |
); |
); |
441 |
|
|
442 |
if ( my $site_id = $action->result->content('site_id') ) { |
if ( my $site_id = $action->result->content('site_id') ) { |
443 |
show('strix-site-navigation-tree', $action->result->content('instance'), $site_id); |
show('navigation-tree', $action->result->content('instance'), $site_id); |
444 |
|
} |
445 |
|
}; |
446 |
|
|
447 |
|
=head2 layout |
448 |
|
|
449 |
|
Shows layout for C<url> |
450 |
|
|
451 |
|
=cut |
452 |
|
|
453 |
|
template 'layout' => sub { |
454 |
|
|
455 |
|
my $url = get('url') || '/'; |
456 |
|
my $category = strix->category( $url ); |
457 |
|
my $layout = strix->layout( $url ); |
458 |
|
|
459 |
|
h1 { $category->{naziv} } |
460 |
|
pre { |
461 |
|
dump( $layout ); |
462 |
} |
} |
463 |
|
|
464 |
|
}; |
465 |
|
|
466 |
|
=head2 category |
467 |
|
|
468 |
|
Show category data for C<url> |
469 |
|
|
470 |
|
=cut |
471 |
|
|
472 |
|
template 'category' => sub { |
473 |
|
|
474 |
|
my $url = get('url') || '/'; |
475 |
|
my $category = strix->category( $url ); |
476 |
|
|
477 |
|
h1 { $category->{naziv} } |
478 |
|
pre { |
479 |
|
dump( $category ); |
480 |
|
} |
481 |
|
|
482 |
}; |
}; |
483 |
|
|
484 |
=head1 PRIVATE TEMPLATES |
=head1 PRIVATE TEMPLATES |
485 |
|
|
486 |
=head2 strix-site-navigation-tree |
=head2 navigation-tree-category |
487 |
|
|
488 |
show('strix-site-navigation-tree',$instance,$site_id); |
show('navigation-tree-category',$kat_row); |
489 |
|
|
490 |
=cut |
=cut |
491 |
|
|
492 |
private template 'select-category' => sub { |
private template 'navigation-tree-category' => sub { |
493 |
my $self = shift; |
my $self = shift; |
494 |
|
#warn "## navigation-tree-category",dump( @_ ); |
495 |
my $p = shift; |
my $p = shift; |
496 |
strix_link( $p->{url}, $p->{naziv} ); |
hyperlink( |
497 |
|
onclick => { |
498 |
|
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
499 |
|
replace_with => '/strix/category', |
500 |
|
args => { |
501 |
|
url => $p->{url}, |
502 |
|
instance => get('instance'), |
503 |
|
} |
504 |
|
}, |
505 |
|
label => $p->{naziv}, |
506 |
|
); |
507 |
|
outs_raw(' '); |
508 |
if ( $p->{type} eq 'category' ) { |
if ( $p->{type} eq 'category' ) { |
|
outs_raw(' '); |
|
509 |
hyperlink( |
hyperlink( |
510 |
# url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), |
# url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), |
511 |
onclick => { |
onclick => { |
512 |
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
region => 'strix-site-layout', # FIXME do we have to hard-code region name here? |
513 |
replace_with => '/strix/layout', |
replace_with => '/strix/layout', |
520 |
class => 'layout', |
class => 'layout', |
521 |
); |
); |
522 |
} |
} |
523 |
|
outs_raw(' '); |
524 |
|
strix_link( $p->{url}, '>>' ); |
525 |
}; |
}; |
526 |
|
|
527 |
private template 'strix-site-navigation-tree' => sub { |
=head2 navigation-tree |
528 |
|
|
529 |
|
show('navigation-tree',$instance,$site_id); |
530 |
|
|
531 |
|
=cut |
532 |
|
|
533 |
|
private template 'navigation-tree' => sub { |
534 |
my $self = shift; |
my $self = shift; |
535 |
my ( $instance, $site_id ) = @_; |
my ( $instance, $site_id ) = @_; |
536 |
|
|
537 |
warn ">>>> instance: $instance site_id: $site_id"; |
warn "## navigation-tree instance: $instance site_id: $site_id"; |
538 |
|
|
539 |
set 'instance' => $instance; |
set 'instance' => $instance; |
540 |
|
|
|
|
|
541 |
sub children { |
sub children { |
542 |
my $c = shift; |
my $c = shift; |
543 |
return unless defined $c->{children}; |
return unless defined $c->{children}; |
547 |
if ( defined( $p->{class} ) ) { |
if ( defined( $p->{class} ) ) { |
548 |
{ class is $p->{class} }; |
{ class is $p->{class} }; |
549 |
} |
} |
550 |
show( 'select-category', $p ); |
show( 'navigation-tree-category', $p ); |
551 |
children( $p ); |
children( $p ); |
552 |
} |
} |
553 |
} |
} |
556 |
|
|
557 |
my $strix = Strix->new({ instance => $instance }); |
my $strix = Strix->new({ instance => $instance }); |
558 |
|
|
559 |
my @navigation = @{ $strix->site_navigation( $site_id ) }; |
my $navigation = $strix->site_navigation( $site_id ); |
560 |
if ( @navigation ) { |
#warn "## navigation = ",dump( $navigation ); |
561 |
|
if ( $navigation ) { |
562 |
ul { |
ul { |
563 |
foreach my $p ( @navigation ) { |
{ class is 'navigation' }; |
564 |
|
foreach my $p ( @$navigation ) { |
565 |
li { |
li { |
566 |
show( 'select-category', $p ); |
show( 'navigation-tree-category', $p ); |
567 |
children( $p ); |
children( $p ); |
568 |
} |
} |
569 |
} |
} |