1 package Moose::Website;
3 use MooseX::Types::Path::Class;
7 use YAML::XS 'LoadFile';
9 use Moose::Website::I18N;
10 use Moose::Website::Resource::Templates;
11 use Moose::Website::Resource::WebFiles;
13 our $VERSION = '0.01';
14 our $AUTHORITY = 'cpan:STEVAN';
16 with 'MooseX::Getopt';
20 isa => 'Path::Class::Dir',
28 default => sub { 'en' },
33 isa => 'Path::Class::File',
36 file(__FILE__)->parent->parent->parent->file('data', 'pages.yml')
42 has 'template_resource' => (
43 traits => [ 'NoGetopt' ],
45 isa => 'Moose::Website::Resource::Templates',
48 Moose::Website::Resource::Templates->new
51 'template_root' => 'dir'
55 has 'web_file_resource' => (
56 traits => [ 'NoGetopt' ],
58 isa => 'Moose::Website::Resource::WebFiles',
61 Moose::Website::Resource::WebFiles->new
66 traits => [ 'NoGetopt' ],
72 Moose::Website::I18N->get_handle( $self->locale )
77 traits => [ 'NoGetopt' ],
79 isa => 'ArrayRef[HashRef]',
83 LoadFile( $self->page_file->stringify );
88 traits => [ 'NoGetopt' ],
95 INCLUDE_PATH => $self->template_root,
96 %{ $self->template_config }
101 has 'template_config' => (
102 traits => [ 'NoGetopt' ],
106 default => sub { +{} },
109 sub log { shift; warn @_, "\n" }
114 foreach my $page ( @{ $self->pages } ) {
116 my $outfile = $self->outdir->file( $page->{outfile} )->stringify;
118 $self->log( "Writing page " . $page->{name} . " to $outfile using template " . $page->{template} );
122 $self->build_template_params( current_page => $page ),
124 ) || confess $self->tt->error;
127 $self->log( "Copying web resources to " . $self->outdir );
128 $self->web_file_resource->copy( to => $self->outdir );
131 sub build_template_params {
132 my ($self, %params) = @_;
134 $params{ pages } = $self->pages;
135 $params{ loc } = sub { $self->i18n->loc( @_ ) };
141 __PACKAGE__->meta->make_immutable;
151 Moose::Website - A Moosey solution to this problem
169 All complex software has bugs lurking in it, and this module is no
170 exception. If you find a bug please either email me, or add the bug
175 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
177 =head1 COPYRIGHT AND LICENSE
179 Copyright 2010 Infinity Interactive, Inc.
181 L<http://www.iinteractive.com>
183 This library is free software; you can redistribute it and/or modify
184 it under the same terms as Perl itself.