Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Admin section, root page to list buckets

  • Loading branch information...
commit c4d419225a2d986250d02482ba84ceae897608cc 1 parent 5ca8333
@castaway authored
View
19 lib/PresentingPerl/Web/Controller/Admin.pm
@@ -0,0 +1,19 @@
+package PresentingPerl::Web::Controller::Admin;
+
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller' }
+
+sub root :Path :Args(0) {
+ my ($self, $c) = @_;
+
+ my $buckets = $c->model('DB::Bucket');
+
+ $c->stash->{current_view} = 'Zoom';
+ $c->stash->{buckets} = $buckets;
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
View
48 lib/PresentingPerl/Web/View/Zoom/Admin.pm
@@ -0,0 +1,48 @@
+package PresentingPerl::Web::View::Zoom::Admin;
+use Moose;
+
+use Data::Dumper;
+use HTML::Zoom::FilterBuilder::Template;
+
+sub wrap {
+ my ($self, $zoom, $stash) = @_;
+
+ my @body;
+
+ $zoom->select('#main-content')->collect_content({into => \@body})->run;
+
+ my $layout_zoom = HTML::Zoom->from_file($stash->{wrapper_template});
+ # This does *not* modify $layout_zoom, but rather returns the modified version!
+ return $layout_zoom->select('#main-content')->replace_content(\@body);
+}
+
+sub root {
+ my ($self, $stash) = @_;
+
+ my $error = $stash->{error} || '';
+ my $zoom = $_;
+ my $buckets = [ map {
+ my $obj = $_;
+ sub {
+ $_->select('.bucket-slug')->replace_content($obj->slug)
+ ->select('.bucket-name')->replace_content($obj->name)
+ ->select('.edit-link')->set_attribute(
+ 'href' => $obj->slug.'/'
+ )
+ ->select('.delete-link')->set_attribute(
+ 'href' => $obj->slug.'/delete/'
+ )
+ }
+
+ } ($stash->{buckets}->all) ];
+
+ $zoom = $zoom->select('#bucket-list')
+ ->repeat_content($buckets)
+ ->select('.error-text')->replace_content($error);
+
+ $self->wrap($zoom, $stash);
+
+
+}
+
+1;
View
44 root/admin/root
@@ -0,0 +1,44 @@
+ <div id="main-content">
+
+ <h2 class="author-name">
+ List of available buckets
+ </h2>
+ <p>
+ Add a new bucket
+ </p>
+ <form class="add-bucket-form" action="" method="POST">
+ <label for="new_name">Enter a name for this bucket</label> <input type="text" name="new_name"/>
+ <br /><br />
+ <label for="new_slug">Enter a relative URI for this bucket</label> <input type="text" name="new_slug"/>
+ <br /><br />
+ <input type="submit" value="Create Bucket"/>
+ </form>
+ <span class="error-text">Some error</span>
+ <p>
+ Below is a list of existing buckets. Click on the buckets to change details about them, and 'Delete' to remove them.
+ </p>
+ <ul id="bucket-list">
+ <li class="bucket">
+ <a class="edit-link">
+ <span class="bucket-slug">Some Random Event</span> -
+ <span class="bucket-name">Some Random Event</span>
+ </a>
+ <a class="delete-link">Delete</a>
+ </a>
+ </li>
+ </ul>
+ </div>
+
+ <div id="custom-html">
+ <h1>
+ <span class="bucket-name">THIS IZ MAI BUKKIT</span>
+ </h1>
+ <ul id="video-list">
+ <li class="video">
+ <a class="video-link"><span class="video-name">Really Imaginative Video Name</span> (<span class="video-author">Some Guy</span>)</a>
+ </li>
+ </ul>
+ </div>
+
+<!-- END MAIN CONTENT -->
+ </div>
Please sign in to comment.
Something went wrong with that request. Please try again.