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

Contents of /trunk/lib/Frey/HTML.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 19 - (show annotations)
Sun Jun 29 12:55:39 2008 UTC (15 years, 9 months ago) by dpavlin
Original Path: trunk/lib/HTML.pm
File size: 1100 byte(s)
- create slim server caller in bin for Frey::Server
- restructure view packages
- beginning of rest dispatcher based on Template::Declare
1 package HTML;
2
3 use strict;
4 use warnings;
5
6 use Time::HiRes qw/time/;
7 use Data::Dump qw/dump/;
8 use Carp qw/confess/;
9
10 # FIXME
11 use View;
12 use Strix::View;
13 use Frey::REST;
14
15 warn "available templates = ",dump( Template::Declare->templates );
16
17 our @javascript;
18
19 use Template::Declare;
20 use Template::Declare::Tags; # defaults to 'HTML'
21 Template::Declare->init( roots => ['HTML','View'], around_template => sub {
22 my ($orig, $path, $args, $code) = @_;
23 my $t = time;
24 html {
25 head {
26 title { $path }
27 link {
28 { rel is 'stylesheet' }
29 { href is 'static/app.css' }
30 { type is 'text/css' }
31 { media is 'screen' }
32 };
33 foreach my $js ( @javascript ) {
34 script {
35 { type is 'text/javascript' }
36 { src is $js }
37 }
38 }
39 }
40 body {
41 $orig->();
42 }
43 }
44 warn "TEMPLATE $path ",dump($args),sprintf(" in %.4fs\n",time - $t);
45 });
46
47 sub view {
48 my $self = shift;
49 return Template::Declare->show( @_ );
50 }
51
52 sub add_javascript {
53 my $self = shift;
54 my $js = shift or confess "no JavaScript path";
55 # return unless -e $js; # FIXME
56 warn "Added javascript $js\n";
57 push @javascript, $js;
58 }

  ViewVC Help
Powered by ViewVC 1.1.26