/[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 214 by dpavlin, Fri Jun 20 20:54:41 2008 UTC revision 242 by dpavlin, Wed Oct 1 20:22:22 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            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,
# Line 92  template 'name_diff' => page { Line 94  template 'name_diff' => page {
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
# Line 122  sub strix { Line 171  sub strix {
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          );          );
# Line 148  template 'navigation' => page { Line 197  template 'navigation' => page {
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
# Line 180  Execute SQL query on instance Line 207  Execute SQL query on instance
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) {
# Line 208  template 'execute-sql' => sub { Line 242  template 'execute-sql' => sub {
242                          }                          }
243                  }                  }
244          }          }
245            warn ">>>> sql (at end) = ",Jifty->web->session->get('sql');
246  };  };
247    
248  =head2 search-instances  =head2 search-instances
# Line 409  template 'site' => sub { Line 444  template 'site' => sub {
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 navigation-tree-category  =head2 navigation-tree-category
# Line 421  private template 'navigation-tree-catego Line 493  private template 'navigation-tree-catego
493          my $self = shift;          my $self = shift;
494          #warn "## navigation-tree-category",dump( @_ );          #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('&nbsp;');
508          if ( $p->{type} eq 'category' ) {          if ( $p->{type} eq 'category' ) {
                 outs_raw('&nbsp;');  
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',
# Line 438  private template 'navigation-tree-catego Line 520  private template 'navigation-tree-catego
520                          class => 'layout',                          class => 'layout',
521                  );                  );
522          }          }
523            outs_raw('&nbsp;');
524            strix_link( $p->{url}, '>>' );
525  };  };
526    
527  =head2 navigation-tree  =head2 navigation-tree
# Line 450  private template 'navigation-tree' => su Line 534  private template 'navigation-tree' => su
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};
# Line 477  private template 'navigation-tree' => su Line 560  private template 'navigation-tree' => su
560          #warn "## navigation = ",dump( $navigation );          #warn "## navigation = ",dump( $navigation );
561          if ( $navigation ) {          if ( $navigation ) {
562                  ul {                  ul {
563                            { class is 'navigation' };
564                          foreach my $p ( @$navigation ) {                          foreach my $p ( @$navigation ) {
565                                  li {                                  li {
566                                          show( 'navigation-tree-category', $p );                                          show( 'navigation-tree-category', $p );

Legend:
Removed from v.214  
changed lines
  Added in v.242

  ViewVC Help
Powered by ViewVC 1.1.26