actions plugin
Matt S Trout [Wed, 13 Feb 2013 16:10:30 +0000 (16:10 +0000)]
lib/App/SCS/Plugin/Actions.pm [new file with mode: 0644]

diff --git a/lib/App/SCS/Plugin/Actions.pm b/lib/App/SCS/Plugin/Actions.pm
new file mode 100644 (file)
index 0000000..ff85cdf
--- /dev/null
@@ -0,0 +1,29 @@
+package App::SCS::Plugin::Actions;
+
+use Module::Runtime qw(use_module);
+use IO::All;
+use Moo;
+
+with 'App::SCS::Role::Plugin';
+
+has mount_at => (is => 'ro', default => sub { 'actions' });
+
+has dispatcher => (is => 'lazy', builder => sub {
+  my ($self) = @_;
+  use_module('Plack::App::PSGIBin')->new(
+    root => io->dir($self->app->share_dir)->catdir('actions')
+  );
+});
+
+sub page_dispatchers {
+  my ($self) = @_;
+  my $base = $self->mount_at;
+  "/${base}/..." => sub { $self->dispatcher },
+}
+
+sub provides_pages {
+  my ($self) = @_;
+  return;
+}
+
+1;