/[Frey]/trunk/lib/HTML.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 /trunk/lib/HTML.pm

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

revision 10 by dpavlin, Sat Jun 28 22:13:05 2008 UTC revision 21 by dpavlin, Sun Jun 29 13:12:59 2008 UTC
# Line 5  use warnings; Line 5  use warnings;
5    
6  use Time::HiRes qw/time/;  use Time::HiRes qw/time/;
7  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
8  use View;  use Carp qw/confess/;
9    
10  use Data::Dump qw/dump/;  # FIXME
11    
12    our @view_classes = qw(
13            Frey::View
14            Frey::REST
15            Strix::View
16    );
17    
18    warn "Using view classes ", dump( @view_classes );
19    
20    foreach ( @view_classes ) {
21            my $path = $_;
22            $path =~ s!::!/!g;
23            $path .= '.pm';
24            require $path or warn "Can't require $_ from $path: $!";
25    }
26    
27  warn "available templates = ",dump( Template::Declare->templates );  warn "available templates = ",dump( Template::Declare->templates );
28    
29    our @javascript;
30    
31  use Template::Declare;  use Template::Declare;
32  use Template::Declare::Tags; # defaults to 'HTML'  use Template::Declare::Tags; # defaults to 'HTML'
33  Template::Declare->init( roots => ['HTML','View'], around_template => sub {  Template::Declare->init( roots => \@view_classes, around_template => sub {
34          my ($orig, $path, $args, $code) = @_;          my ($orig, $path, $args, $code) = @_;
35          my $t = time;          my $t = time;
36          html {          html {
37                  head {}                  head {
38                            title { $path }
39                            link {
40                                    { rel is 'stylesheet' }
41                                    { href is 'static/app.css' }
42                                    { type is 'text/css' }
43                                    { media is 'screen' }
44                            };
45                            foreach my $js ( @javascript ) {
46                                    script {
47                                            { type is 'text/javascript' }
48                                            { src is $js }
49                                    }
50                            }
51                    }
52                  body {                  body {
53                          $orig->();                          $orig->();
54                  }                  }
# Line 26  Template::Declare->init( roots => ['HTML Line 57  Template::Declare->init( roots => ['HTML
57  });  });
58    
59  sub view {  sub view {
 #       warn "## view",dump( @_ );  
60          my $self = shift;          my $self = shift;
61          return Template::Declare->show( @_ );          return Template::Declare->show( @_ );
62  }  }
63    
64    sub add_javascript {
65            my $self = shift;
66            my $js = shift or confess "no JavaScript path";
67    #       return unless -e $js; # FIXME
68            warn "Added javascript $js\n";
69            push @javascript, $js;
70    }

Legend:
Removed from v.10  
changed lines
  Added in v.21

  ViewVC Help
Powered by ViewVC 1.1.26