/[A3C]/lib/A3C/View/Strix.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/A3C/View/Strix.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 212 by dpavlin, Fri Jun 20 17:04:20 2008 UTC revision 244 by dpavlin, Wed Oct 1 21:05:00 2008 UTC
# Line 45  template 'index.html' => page { Line 45  template 'index.html' => page {
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          my $name_diff = A3C::SQL->new({ query => qq{          h2 { _('Name differences') }
62    
63            my $diff = A3C::SQL->new({ query => qq{
64                  select                  select
65                          instance,hreduorgurl,                          instance,hreduorgurl,
66                          _site_name,o                          _site_name,o
# Line 67  template 'name_diff' => page { Line 69  template 'name_diff' => page {
69                  where o != _site_name                  where o != _site_name
70          }});          }});
71    
72          if ( $name_diff->count > 0 ) {          if ( $diff->count > 0 ) {
73    
74                    div { { class is 'note' } _("Found %1 instances with name in configuration different from name in LDAP", $diff->count) }
75    
76                  table {                  table {
77                          row {                          row {
# Line 76  template 'name_diff' => page { Line 80  template 'name_diff' => page {
80                                  th { _('Strix instance name') }                                  th { _('Strix instance name') }
81                                  th { _('hrEduOrg.o') }                                  th { _('hrEduOrg.o') }
82                          };                          };
83                          while ( my $row = $name_diff->next ) {                          while ( my $row = $diff->next ) {
84                                  row {                                  row {
85                                          cell { show( 'instance-op', 'Create', '+', $row->instance ) }                                          cell { show( 'instance-op', 'Create', '+', $row->instance ) }
86                                          cell { $row->instance }                                          cell { $row->instance }
# Line 90  template 'name_diff' => page { Line 94  template 'name_diff' => page {
94                  div { _("Can't find any instance of strix which has different name than data from LDAP") }                  div { _("Can't find any instance of strix which has different name than data from LDAP") }
95          }          }
96    
97            h2 { _('Missing instance configuration') }
98    
99            my $diff = A3C::SQL->new({ query => qq{
100                    select
101                            instance,hreduorgurl,o
102                    from strix_visits
103                    join hr_edu_orgs on cn = instance
104                    where instance not in (select instance from strix_instances)
105            }});
106    
107            if ( $diff->count > 0 ) {
108    
109                    div { { class is 'note' } _("Found %1 instances which have statistics but no conf.php", $diff->count) }
110    
111                    table {
112                            row {
113                                    th {}
114                                    th { _('Instance') }
115                                    th { _('hrEduOrg.o') }
116                            };
117                            while ( my $row = $diff->next ) {
118                                    row {
119                                            cell { show( 'instance-op', 'Create', '+', $row->instance ) }
120                                            cell { $row->instance }
121                                            cell { $row->o }
122                                    }
123                            }
124                    }
125            
126            } else {
127                    div { _("Can't find any instance of strix which has different name than data from LDAP") }
128            }
129    };
130    
131    =head2 instances
132    
133    =cut
134    
135    template 'instances' => page {
136    
137            title is _('Strix instances');
138    
139            my $sql = A3C::SQL->new({ query => qq{
140                    select
141                            hrEduOrgUrl, o, l, postalAddress, telephoneNumber, facsimileTelephoneNumber,
142                            strix_visits.instance, strix_visits.hits, strix_changes.modifications
143                    from strix_visits
144                    left outer join hr_edu_orgs on cn = instance
145                    left outer join strix_changes on strix_changes.instance = strix_visits.instance
146                    order by l,o
147            }});
148    
149            if ( $sql->count > 0 ) {
150    
151                    div { { class is 'note' } _("Found total of %1 strix instances", $sql->count) }
152    
153                    table {
154                            row {
155                                    th { _('hrEduOrgUrl') }
156                                    th { _('o') }
157                                    th { _('l') }
158                                    th { _('postalAddress') }
159                                    th { _('telephoneNumber') }
160                                    th { _('facsimileTelephoneNumber') }
161                                    th { _('hits') }
162                                    th { _('edits') }
163                            };
164                            while ( my $row = $sql->next ) {
165                                    row {
166                                            cell {
167                                                    if ( my $url = $row->hrEduOrgUrl ) {
168                                                            outs_raw qq{<a href="http://$url">$url</a>};
169                                                    } else {
170                                                            outs $row->instance;
171                                                    }
172                                            }
173                                            cell { $row->o }
174                                            cell { $row->l }
175                                            cell { $row->postalAddress }
176                                            cell { { class is 'center' } $row->telephoneNumber }
177                                            cell { { class is 'center' } $row->facsimileTelephoneNumber }
178                                            cell { { class is 'right' } $row->hits }
179                                            cell { { class is 'right' } $row->modifications }
180                                    }
181                            }
182                    }
183    
184            } else {
185                    div { _("Can't find any strix instances") }
186            }
187    
188  };  };
189    
190  =head2 sql  =head2 sql
# Line 122  sub strix { Line 217  sub strix {
217  sub strix_link {  sub strix_link {
218          my ( $url, $label ) = @_;          my ( $url, $label ) = @_;
219          hyperlink(          hyperlink(
220                  url => 'http://' . get('instance') . '.cms-qa.skole.hr' . $url,                  url => 'http://' . get('instance') . Jifty->config->app('strix')->{domain} . $url,
221                  label => $label || $url,                  label => $label || $url,
222                  target => 'strix',                  target => 'strix',
223          );          );
# Line 148  template 'navigation' => page { Line 243  template 'navigation' => page {
243    
244  };  };
245    
 =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 );  
         }  
   
 };  
   
246  =head1 REGIONS  =head1 REGIONS
247    
248  =head2 execute-sql  =head2 execute-sql
# Line 180  Execute SQL query on instance Line 253  Execute SQL query on instance
253    
254  template 'execute-sql' => sub {  template 'execute-sql' => sub {
255    
256            my $sql = get('sql') || Jifty->web->session->get('sql');
257            warn ">>>> sql = $sql";
258            my $instance = get('instance');
259            warn ">>>> instance = $instance";
260    
261          my $action = new_action(          my $action = new_action(
262                  class   => 'StrixSQL',                  class   => 'StrixSQL',
263                  moniker => 'strix-sql',                  moniker => 'strix-sql',
264                  sticky_on_success => 1,                  sticky_on_success => 1,
265                  sticky_on_failure => 1,                  sticky_on_failure => 1,
266                  arguments => {                  arguments => {
267                          instance => get('instance')                          instance => $instance,
268                  }                          sql => $sql,
269                    },
270          );          );
271    
272          form {          form {
273                  render_action( $action => [ 'instance', 'sql' ] );                  render_action( $action, [ 'instance', 'sql' ] );
274                  form_submit( label => _('Execute SQL') );                  form_submit( label => _('Execute SQL') );
275          };          };
276    
277          if ( my $sql = $action->result->content('sql') ) {          if ( my $sql = $action->result->content('sql') ) {
278                  div { _('Found %1 results', $sql->count ) }                  Jifty->web->session->set( sql => $sql->query );
279                    div { _('Found %1 results for %2', $sql->count, $instance ) }
280                  table {                  table {
281                          row { map { th { $_ } } $sql->_column_names };                          row { map { th { $_ } } $sql->_column_names };
282                          while (my $row = $sql->next) {                          while (my $row = $sql->next) {
# Line 208  template 'execute-sql' => sub { Line 288  template 'execute-sql' => sub {
288                          }                          }
289                  }                  }
290          }          }
291            warn ">>>> sql (at end) = ",Jifty->web->session->get('sql');
292  };  };
293    
294  =head2 search-instances  =head2 search-instances
# Line 405  template 'site' => sub { Line 486  template 'site' => sub {
486          );          );
487    
488          if ( my $site_id = $action->result->content('site_id') ) {          if ( my $site_id = $action->result->content('site_id') ) {
489                  show('strix-site-navigation-tree', $action->result->content('instance'), $site_id);                  show('navigation-tree', $action->result->content('instance'), $site_id);
490          }          }
491  };  };
492    
493    =head2 layout
494    
495    Shows layout for C<url>
496    
497    =cut
498    
499    template 'layout' => sub {
500    
501            my $url = get('url') || '/';
502            my $category = strix->category( $url );
503            my $layout = strix->layout( $url );
504    
505            h1 { $category->{naziv} }
506            pre {
507                    dump( $layout );
508            }
509    
510    };
511    
512    =head2 category
513    
514    Show category data for C<url>
515    
516    =cut
517    
518    template 'category' => sub {
519    
520            my $url = get('url') || '/';
521            my $category = strix->category( $url );
522    
523            h1 { $category->{naziv} }
524            pre {
525                    dump( $category );
526            }
527    
528    };
529    
530  =head1 PRIVATE TEMPLATES  =head1 PRIVATE TEMPLATES
531    
532  =head2 strix-site-navigation-tree  =head2 navigation-tree-category
533    
534    show('strix-site-navigation-tree',$instance,$site_id);    show('navigation-tree-category',$kat_row);
535    
536  =cut  =cut
537    
538  private template 'select-category' => sub {  private template 'navigation-tree-category' => sub {
539          my $self = shift;          my $self = shift;
540            #warn "## navigation-tree-category",dump( @_ );
541          my $p = shift;          my $p = shift;
542          strix_link( $p->{url}, $p->{naziv} );          hyperlink(
543                    onclick => {
544                            region => 'strix-site-layout',  # FIXME do we have to hard-code region name here?
545                            replace_with => '/strix/category',
546                            args => {
547                                    url => $p->{url},
548                                    instance => get('instance'),
549                            }
550                    },
551                    label => $p->{naziv},
552            );
553            outs_raw('&nbsp;');
554          if ( $p->{type} eq 'category' ) {          if ( $p->{type} eq 'category' ) {
                 outs_raw('&nbsp;');  
555                  hyperlink(                  hyperlink(
556  #                       url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'),  #                               url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'),
557                          onclick => {                          onclick => {
558                                  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?
559                                  replace_with => '/strix/layout',                                  replace_with => '/strix/layout',
# Line 437  private template 'select-category' => su Line 566  private template 'select-category' => su
566                          class => 'layout',                          class => 'layout',
567                  );                  );
568          }          }
569            outs_raw('&nbsp;');
570            strix_link( $p->{url}, '>>' );
571  };  };
572    
573  private template 'strix-site-navigation-tree' => sub {  =head2 navigation-tree
574    
575      show('navigation-tree',$instance,$site_id);
576    
577    =cut
578    
579    private template 'navigation-tree' => sub {
580          my $self = shift;          my $self = shift;
581          my ( $instance, $site_id ) = @_;          my ( $instance, $site_id ) = @_;
582    
583          warn ">>>> instance: $instance site_id: $site_id";          warn "## navigation-tree instance: $instance site_id: $site_id";
584    
585          set 'instance' => $instance;          set 'instance' => $instance;
586    
   
587          sub children {          sub children {
588                  my $c = shift;                  my $c = shift;
589                  return unless defined $c->{children};                  return unless defined $c->{children};
# Line 457  private template 'strix-site-navigation- Line 593  private template 'strix-site-navigation-
593                                          if ( defined( $p->{class} ) ) {                                          if ( defined( $p->{class} ) ) {
594                                                  { class is $p->{class} };                                                  { class is $p->{class} };
595                                          }                                          }
596                                          show( 'select-category', $p );                                          show( 'navigation-tree-category', $p );
597                                          children( $p );                                          children( $p );
598                                  }                                  }
599                          }                          }
# Line 466  private template 'strix-site-navigation- Line 602  private template 'strix-site-navigation-
602    
603          my $strix = Strix->new({ instance => $instance });          my $strix = Strix->new({ instance => $instance });
604    
605          my @navigation = @{ $strix->site_navigation( $site_id ) };          my $navigation = $strix->site_navigation( $site_id );
606          if ( @navigation ) {          #warn "## navigation = ",dump( $navigation );
607            if ( $navigation ) {
608                  ul {                  ul {
609                          foreach my $p ( @navigation ) {                          { class is 'navigation' };
610                            foreach my $p ( @$navigation ) {
611                                  li {                                  li {
612                                          show( 'select-category', $p );                                          show( 'navigation-tree-category', $p );
613                                          children( $p );                                          children( $p );
614                                  }                                  }
615                          }                          }

Legend:
Removed from v.212  
changed lines
  Added in v.244

  ViewVC Help
Powered by ViewVC 1.1.26