Permalink
Browse files

Added duckduckhack, reorganized ini files

  • Loading branch information...
1 parent 4580171 commit faf49616c27d4347f2ed83b6c486aee9e2508bed @Getty Getty committed Sep 9, 2012
@@ -55,6 +55,7 @@ sub publish_to {
$packer = HTML::Packer->init();
}
for my $site (@{$self->sites}) {
+ $site->meta_config;
for my $dir (values %{$site->dirs}) {
for (sort { $a->fullpath cmp $b->fullpath } values %{$dir->fullpath_files}) {
my $real_file = file($target,$site->key,$_->fullpath)->absolute;
@@ -41,6 +41,18 @@ sub _build_files {
$files{$page}->{$locale} = $file;
}
}
+ my $default_locale = $self->dir->site->default_locale;
+ my %statics = %{$self->statics_coderefs};
+ for my $static (keys %statics) {
+ my $code = $pages{$page};
+ my $file = DDG::Publisher::File->new(
+ code => $code,
+ filebase => $static,
+ locale => $default_locale,
+ dir => $self,
+ );
+ $files{$page} = $file;
+ }
return \%files;
}
@@ -64,6 +76,7 @@ sub _build_fullpath_files {
sub locale_url {
my ( $self, $page, $locale ) = @_;
+ return $self->files->{$page}->fullpath if (ref $self->files->{$page} eq 'DDG::Publisher::File');
return $self->files->{$page}->{$locale}->fullpath;
}
@@ -73,6 +86,12 @@ has pages_coderefs => (
builder => 'pages',
);
+has statics_coderefs => (
+ is => 'ro',
+ lazy => 1,
+ builder => 'statics',
+);
+
has web_path => (
is => 'ro',
lazy => 1,
@@ -26,7 +26,7 @@ has file => (
sub _build_file {
my ( $self ) = @_;
my $file = $self->filebase;
- $file .= '.'.$self->locale unless $self->locale eq 'en_US';
+ $file .= '.'.$self->locale unless $self->locale eq $self->dir->site->default_locale;
$file .= '.html';
return $file;
}
@@ -0,0 +1,22 @@
+package DDG::Publisher::Meta;
+
+use MooX;
+
+has _values => (
+ is => 'ro',
+ default => sub {{}},
+);
+sub values { shift->_values }
+
+sub new_from_ini {
+ my ( $class, $data ) = @_;
+ use DDP; p($data);
+ return DDG::Publisher::Meta->new;
+}
+
+sub clone_with_ini {
+ my ( $self, $data ) = @_;
+
+}
+
+1;
@@ -16,7 +16,10 @@ sub pages {{
about => sub {},
feedback => sub {},
privacy => sub {},
- spread => sub {},
+ spread => sub {},
+}}
+
+sub statics {{
walpha => sub {
no_wrapper => 1,
},
@@ -0,0 +1,15 @@
+package DDG::Publisher::Site::Duckduckhack::Root;
+
+use MooX;
+
+with qw(
+ DDG::Publisher::DirRole
+);
+
+sub path { '/' }
+
+sub pages {{
+ index => sub {},
+}}
+
+1;
@@ -5,6 +5,9 @@ use Class::Load ':all';
use Text::Xslate qw( mark_raw );
use File::ShareDir::ProjectDistDir;
use Locale::Simple;
+use Config::INI::Reader;
+use Path::Class;
+use DDG::Publisher::Meta;
requires qw(
default_hostname
@@ -30,27 +33,13 @@ has dirs => (
lazy => 1,
);
-sub load_locale_package {
- my ( $self ) = @_;
- load_class($self->locale_package) unless (is_class_loaded($self->locale_package));
-}
-
-sub locales {
- my ( $self ) = @_;
- $self->load_locale_package;
- return (keys $self->locale_package->locales);
-}
-
-# has locale_domain => (
-# is => 'ro',
-# builder => 1,
-# lazy => 1,
-# );
+has default_locale => (
+ is => 'ro',
+ builder => 1,
+ lazy => 1,
+);
-# sub _build_locale_domain {
-# my ( $self ) = @_;
-
-# }
+sub _build_default_locale { 'en_US' }
sub _build_dirs {
my ( $self ) = @_;
@@ -63,6 +52,29 @@ sub _build_dirs {
} $self->dirs_classes};
}
+has meta_default => (
+ is => 'ro',
+ builder => 1,
+ lazy => 1,
+);
+
+sub _build_meta_default {
+ my ( $self ) = @_;
+ my $meta_default = Config::INI::Reader->read_file(file(dist_dir('DDG-Publisher'),'core','config.ini'));
+ return DDG::Publisher::Meta->new_from_ini($meta_default);
+}
+
+sub load_locale_package {
+ my ( $self ) = @_;
+ load_class($self->locale_package) unless (is_class_loaded($self->locale_package));
+}
+
+sub locales {
+ my ( $self ) = @_;
+ $self->load_locale_package;
+ return (keys $self->locale_package->locales);
+}
+
has template_engine => (
is => 'ro',
lazy => 1,
@@ -71,8 +83,8 @@ has template_engine => (
sub _build_template_engine {
my ( $self ) = @_;
- my $site_template_root = join('/',dist_dir('DDG-Publisher'),'site',$self->key);
- my $core_template_root = join('/',dist_dir('DDG-Publisher'),'core');
+ my $site_template_root = dir(dist_dir('DDG-Publisher'),'site',$self->key)->stringify;
+ my $core_template_root = dir(dist_dir('DDG-Publisher'),'core')->stringify;
return Text::Xslate->new(
path => [$site_template_root,$core_template_root],
function => {
@@ -0,0 +1 @@
+[meta]
File renamed without changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.

0 comments on commit faf4961

Please sign in to comment.