summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-09-17 23:50:22 -0500
committerJesse Luehrs <doy@tozt.net>2010-09-18 11:34:55 -0500
commit7f0ab9818534c6720aff98d10eb6e55aa63dbeee (patch)
treeca483c234279eb3570b7f0172c248a5238d09808 /bin
parenta3ac0614071f5935f3c6754fbc2e498bddc9d692 (diff)
downloadtozt.net-7f0ab9818534c6720aff98d10eb6e55aa63dbeee.tar.gz
tozt.net-7f0ab9818534c6720aff98d10eb6e55aa63dbeee.zip
basic sketch of the site rendering code
Diffstat (limited to 'bin')
-rw-r--r--bin/preview30
-rw-r--r--bin/render10
2 files changed, 40 insertions, 0 deletions
diff --git a/bin/preview b/bin/preview
new file mode 100644
index 0000000..aebeaa3
--- /dev/null
+++ b/bin/preview
@@ -0,0 +1,30 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use Plack::App::Directory;
+use Plack::Builder;
+use Plack::Request;
+use Plack::Response;
+use Plack::Runner;
+
+my $site_root = 'site';
+my $dir_app = Plack::App::Directory->new(root => $site_root)->to_app;
+my $app = sub {
+ my ($env) = @_;
+ my $req = Plack::Request->new($env);
+ if (-d ("$site_root" . $req->path)) {
+ my $resp = Plack::Response->new(302);
+ my $path = $req->path;
+ $path .= '/' unless $path =~ m:/$:;
+ $resp->location("${path}index.html");
+ return $resp->finalize;
+ }
+ else {
+ return $dir_app->($env);
+ }
+};
+
+my $runner = Plack::Runner->new;
+$runner->parse_options(@ARGV);
+$runner->run($app);
diff --git a/bin/render b/bin/render
new file mode 100644
index 0000000..859c5a1
--- /dev/null
+++ b/bin/render
@@ -0,0 +1,10 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use lib 'lib';
+
+use Tozt;
+
+my $site = Tozt->new;
+$site->render_all;
+$site->update_static;