Permalink
Browse files

Removed complete site generation infrastructure

  • Loading branch information...
1 parent 7ead031 commit 61973124cd1d557714fc76ec64e7a5ca7d92e777 @Getty Getty committed Mar 26, 2012
View
@@ -5,27 +5,15 @@ copyright_holder = DuckDuckGo, Inc. L<http://duckduckgo.com/>
copyright_year = 2011
[Prereqs]
-MooseX::Getopt = 0.37
Digest::MD5 = 2.51
IO::All = 0.41
JSON = 2.53
-Moose = 2.0205
namespace::autoclean = 0.13
-Template = 2.22
-Template::Plugin::Capture = 0.01
-Template::Provider::Encoding = 0.10
YAML = 0.73
YAML::XS = 0.35
File::Path = 2.08
-MooseX::NonMoose = 0.22
Data::Printer = 0
File::Spec = 3.33
-Text::Zilla = 0
-MooseX::Aliases = 0.10
-Locale::PO = 0.21
-HTML::Packer = 0
-CSS::Packer = 0
-JavaScript::Packer = 0
WWW::DuckDuckGo = 0.008
List::MoreUtils = 0.33
utf8::all = 0.004
@@ -35,7 +23,6 @@ Class::Load = 0.18
Module::Data = 0.001
Path::Class = 0.25
File::ShareDir = 1.03
-Locale::gettext_pp = 0
Package::Stash = 0
[Prereqs / TestRequires]
View
@@ -1,11 +0,0 @@
-package DDG::App;
-
-use Moose;
-
-with qw(
- MooseX::Getopt
-);
-
-sub error { die "[".(ref shift)."] ".shift }
-
-1;
@@ -1,78 +0,0 @@
-package DDG::App::GenerateStatic;
-
-use Moose;
-extends 'DDG::App';
-
-use Text::Zilla::Dir::FromHash;
-
-has targetdir => (
- isa => 'Str',
- is => 'ro',
- required => 1,
-);
-
-has _target => (
- traits => [qw( NoGetopt )],
- isa => 'Str',
- is => 'ro',
- lazy_build => 1,
-);
-sub target { shift->_target }
-
-sub _build__target {
- my ( $self ) = @_;
- return $self->targetdir if File::Spec->file_name_is_absolute($self->targetdir);
- return File::Spec->rel2abs($self->targetdir);
-}
-
-has packed => (
- is => 'ro',
- isa => 'Bool',
- lazy_build => 1,
-);
-sub _build_packed { 1 }
-
-has podir => (
- isa => 'Str',
- is => 'ro',
- required => 1,
-);
-
-has _pos => (
- traits => [qw( NoGetopt )],
- isa => 'Str',
- is => 'ro',
- lazy_build => 1,
-);
-sub pos { shift->_pos }
-
-sub _build__pos {
- my ( $self ) = @_;
- return $self->targetdir if File::Spec->file_name_is_absolute($self->podir);
- return File::Spec->rel2abs($self->podir);
-}
-
-has site => (
- isa => 'Str',
- is => 'ro',
- required => 1,
-);
-
-sub BUILD {
- my ( $self ) = @_;
- $self->error($self->target." is not writeable") unless -w $self->target;
- my $class = "DDG::Site::".$self->site;
- my $error;
- {
- local $@;
- my $file = $class . '.pm';
- $file =~ s{::}{/}g;
- eval { CORE::require($file) };
- $error = $@;
- }
- die $error if $error;
- my $site = $class->new( packed => $self->packed );
- Text::Zilla::Dir::FromHash->new($site->files)->tzil_to($self->target);
-}
-
-1;
View
@@ -1,7 +0,0 @@
-package DDG::Dir::Static;
-
-use Text::Zilla;
-
-tzil_dir 'Stash';
-
-1;
View
@@ -1,29 +0,0 @@
-package DDG::File::Static;
-
-use Text::Zilla;
-
-tzil_file 'TT';
-
-use MooseX::Aliases;
-
-has 'tt' => (
- isa => 'Template',
- is => 'ro',
- required => 1,
-);
-sub build_tzil_tt { shift->tt }
-
-has 'template' => (
- isa => 'Str',
- is => 'ro',
- required => 1,
-);
-sub build_tzil_template { shift->template }
-
-has '+tzil_stash' => (
- alias => 'stash',
-);
-
-sub to { shift->tzil_write_to(@_) }
-
-1;
View
@@ -1,155 +0,0 @@
-package DDG::Site;
-
-use Moose;
-use Template;
-use File::Spec;
-use File::ShareDir::ProjectDistDir;
-use DDG::Util::Translate;
-use HTML::Packer;
-
-sub key { die "please overwrite key" }
-sub locales { die "please overwrite locales" }
-
-sub default_locale {
- my ( $self ) = @_;
- my @locales = $self->locales;
- return $locales[0];
-}
-
-sub template_dir { File::Spec->rel2abs( File::Spec->catfile( dist_dir('DDG'), 'templates', shift->key ) ) };
-
-has tt => (
- isa => 'Template',
- is => 'ro',
- lazy_build => 1,
-);
-sub _build_tt {
- my ( $self ) = @_;
- Template->new({
- INCLUDE_PATH => $self->template_dir,
- TEMPLATE_EXTENSION => '.tt',
- render_die => 1,
- START_TAG => '<@',
- END_TAG => '@>',
- WRAPPER => 'base.tt',
- });
-}
-
-has packed => (
- is => 'ro',
- isa => 'Bool',
- lazy_build => 1,
-);
-sub _build_packed { 1 }
-
-has packer => (
- isa => 'HTML::Packer',
- is => 'ro',
- lazy_build => 1,
-);
-sub _build_packer {
- HTML::Packer->init()
-}
-
-has statics => (
- is => 'ro',
- isa => 'HashRef',
- lazy_build => 1,
-);
-sub _build_statics {{}}
-
-has locale_urls => (
- is => 'ro',
- isa => 'HashRef',
- lazy_build => 1,
-);
-sub _build_locale_urls {{}}
-
-sub minify {
- my ( $self, $contentref ) = @_;
- $self->packer->minify($contentref,{
- remove_comments => 1,
- remove_newlines => 1,
- do_javascript => 'shrink',
- do_stylesheet => 'minify',
- });
-}
-
-sub locale_url {
- my ( $self, $basename, $locale ) = @_;
- defined $locale && defined $self->locale_urls->{$basename} &&
- defined $self->locale_urls->{$basename}->{$locale} ?
- $self->locale_urls->{$basename}->{$locale} :
- $self->root.$basename.$self->suffix;
-}
-
-has suffix => (
- is => 'ro',
- isa => 'Str',
- lazy_build => 1,
-);
-sub _build_suffix { '.html' }
-
-has root => (
- is => 'ro',
- isa => 'Str',
- lazy_build => 1,
-);
-sub _build_root { '/' }
-
-sub get_locale_statics {
- my ( $self, $basename, $template, $stash ) = @_;
- $self->locale_urls->{$basename} = {};
- my %statics;
- for ($self->locales) {
- my $filename = $basename.($_ eq $self->default_locale ? '' : '.'.$_ ).$self->suffix;
- if ($basename eq 'index' and $_ eq $self->default_locale) {
- $self->locale_urls->{$basename}->{$_} = $self->root;
- } else {
- $self->locale_urls->{$basename}->{$_} = $self->root.$filename;
- }
- $statics{$filename} = {
- template => $template,
- stash => {
- %$stash,
- site => $self,
- basename => $basename,
- filename => $filename,
- locale => $_,
- },
- };
- }
- return %statics;
-}
-
-sub files {
- my ( $self ) = @_;
- my %f;
- for ( keys %{$self->statics} ) {
- my $filename = $_;
- my $config = $self->statics->{$_};
- my $template = delete $config->{template};
- my $stash = delete $config->{stash};
- my $content = $self->generate($template,$stash);
- $self->minify(\$content) if ($self->packed);
- $f{$filename} = $content;
- }
- return \%f;
-}
-
-sub generate {
- my ( $self, $template, $stash ) = @_;
- my $content;
- if ($self->can('default_stash')) {
- for (keys %{$self->default_stash}) {
- $stash->{$_} = $self->default_stash->{$_} unless defined $stash->{$_};
- }
- }
- $stash->{$_} = DDG::Util::Translate->coderef_hash->{$_} for (keys %{DDG::Util::Translate->coderef_hash});
- $stash->{u} = sub { $self->locale_url(@_) };
- $stash->{root} = $self->root;
- $self->tt->process($template.".tt", $stash, \$content) || die $self->tt->error(), "\n";
- return $content;
-}
-
-1;
Oops, something went wrong.

0 comments on commit 6197312

Please sign in to comment.