Permalink
Browse files

Basic admin layout in Actions (Admin controller)

  • Loading branch information...
1 parent 68d63e8 commit 190e6522459d63fc0c7839638e60fc7bec7912fd @castaway committed Mar 24, 2012
Showing with 106 additions and 6 deletions.
  1. +60 −4 lib/PresentingPerl/Web/Controller/Admin.pm
  2. +2 −2 lib/PresentingPerl/Web/View/Zoom/Admin.pm
  3. +44 −0 root/admin/all_buckets
@@ -5,13 +5,69 @@ use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller' }
-sub root :Path :Args(0) {
+## This thing runs on HTML::Zoom, look in View::Zoom::Admin to see how the stash is applied to the templates.
+sub begin : Private {
my ($self, $c) = @_;
- my $buckets = $c->model('DB::Bucket');
-
$c->stash->{current_view} = 'Zoom';
- $c->stash->{buckets} = $buckets;
+}
+
+## Admin starts here, we fetch the buckets
+sub base :Chained('/') :PathPart('admin') :CaptureArgs(0) {
+ my ($self, $c) = @_;
+
+ $c->stash({ buckets_rs => $c->model('DB::Bucket') });
+}
+
+## Main admin page, links to edit users, buckets etc etc.
+sub admin :Chained('base') :PathPart('') :Args(0) {
+ my ($self, $c) = @_;
+}
+
+sub buckets :Chained('base') :PathPart('buckets') :CaptureArgs(0) {
+}
+
+## View all/Create new bucket
+sub all_buckets :Chained('buckets') :PathPart('') :Args(0) {
+ my ($self, $c) = @_;
+
+ if($c->req->param) {
+ my ($slug, $name) = ($c->req->param('new_slug'),
+ $c->req->param('new_name') );
+ $c->stash($c->req->params);
+
+ if(!$name || !$slug) {
+ $c->stash('error', 'Please fill in both a name and a slug for the new bucket');
+ return;
+ }
+
+ my $exists = $c->stash->{buckets_rs}->find({ slug => $slug });
+ if($exists) {
+ $c->stash('error', "The bucket $slug already exists, edit below or choose a new slug");
+ return;
+ }
+
+ $c->stash->{buckets_rs}->create({
+ slug => $slug,
+ name => $name,
+ });
+ }
+}
+
+## admin/buckets/<slug>
+sub bucket :Chained('buckets') :PathPart('') :CaptureArgs(1) {
+ my ($self, $c, $bucket) = @_;
+
+ ## Find bucket by slug and add bucket object to stash
+}
+
+## View/Edit single bucket/Add video
+sub edit_bucket :Chained('bucket') :PathPart('') :Args(0) {
+}
+
+## admin/buckets/<slug>/<video-slug>
+sub edit_video :Chained('bucket') :PathPart('') :Args(1) {
+ my ($self, $c, $video_slug) = @_;
}
__PACKAGE__->meta->make_immutable;
@@ -16,7 +16,7 @@ sub wrap {
return $layout_zoom->select('#main-content')->replace_content(\@body);
}
-sub root {
+sub all_buckets {
my ($self, $stash) = @_;
my $error = $stash->{error} || '';
@@ -34,7 +34,7 @@ sub root {
)
}
- } ($stash->{buckets}->all) ];
+ } ($stash->{buckets_rs}->all) ];
$zoom = $zoom->select('#bucket-list')
->repeat_content($buckets)
View
@@ -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" id="new_name"/>
+ <br /><br />
+ <label for="new_slug">Enter a relative URI for this bucket</label> <input type="text" name="new_slug" id="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>

0 comments on commit 190e652

Please sign in to comment.