diff options
| author | mo khan <mo@mokhan.ca> | 2014-06-08 21:28:45 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-06-08 21:28:45 -0600 |
| commit | efbcdb4d25a7fe12c0b317b146a87c433f951e7b (patch) | |
| tree | 262207f392922eba217f0fd847ce56fae052ab2f | |
| parent | 00743ed74a1e988258d755e708e8a4e168792ce8 (diff) | |
add controller to display s3 objects.
| -rw-r--r-- | app/controllers/admin/blobs_controller.rb | 22 | ||||
| -rw-r--r-- | app/views/admin/blobs/index.html.erb | 22 | ||||
| -rw-r--r-- | app/views/admin/blobs/show.html.erb | 27 | ||||
| -rw-r--r-- | app/views/admin/shared/_admin_nav.html.erb | 1 | ||||
| -rw-r--r-- | config/routes.rb | 1 |
5 files changed, 73 insertions, 0 deletions
diff --git a/app/controllers/admin/blobs_controller.rb b/app/controllers/admin/blobs_controller.rb new file mode 100644 index 00000000..e239ba23 --- /dev/null +++ b/app/controllers/admin/blobs_controller.rb @@ -0,0 +1,22 @@ +module Admin + class BlobsController < AdminController + def index + @objects = bucket.objects + end + + def show + @object = bucket.objects[params[:id]] + end + + private + + def connection + @connection ||= AWS::S3.new + end + + def bucket + bucket_name = ENV['FOG_DIRECTORY'] + connection.buckets[bucket_name] + end + end +end diff --git a/app/views/admin/blobs/index.html.erb b/app/views/admin/blobs/index.html.erb new file mode 100644 index 00000000..a0177477 --- /dev/null +++ b/app/views/admin/blobs/index.html.erb @@ -0,0 +1,22 @@ +<div class="row-fluid"> + <div class="span12"> + <%= render partial: 'admin/shared/admin_nav' %> + <h1>Blobs <small><%= @objects.count %></small></h1> + <table class="table table-condensed"> + <thead> + <tr> + <th>bucket</th> + <th>key</th> + </tr> + </thead> + <tbody> + <% @objects.each do |object| %> + <tr> + <td><%= object.bucket.name %></td> + <td><%= link_to object.key, admin_blob_path(object.key) %></td> + </tr> + <% end %> + </tbody> + </table> + </div> +</div> diff --git a/app/views/admin/blobs/show.html.erb b/app/views/admin/blobs/show.html.erb new file mode 100644 index 00000000..c455b23c --- /dev/null +++ b/app/views/admin/blobs/show.html.erb @@ -0,0 +1,27 @@ +<div class="row-fluid"> + <div class="span12"> + <h1>Blob <small><%= @object.key %></small></h1> + <p><%= link_to "<< Back", admin_blobs_path %></p> + <table class="table table-condensed"> + <thead> + <tr> + <th>id</th> + </tr> + </thead> + <tbody> + <tr> + <td><%= link_to @object.key, admin_blob_path(@object.key) %></td> + </tr> + </tbody> + </table> + <ul> + <li><%= @object.acl %></li> + <li><%= @object.versions %></li> + <li><%= @object.public_url %></li> + <li><%= @object.last_modified %></li> + <li><%= @object.etag %></li> + <li><%= @object.content_type %></li> + <li><%= @object.content_length %></li> + </ul> + </div> +</div> diff --git a/app/views/admin/shared/_admin_nav.html.erb b/app/views/admin/shared/_admin_nav.html.erb index bdfa3de0..9b6d5190 100644 --- a/app/views/admin/shared/_admin_nav.html.erb +++ b/app/views/admin/shared/_admin_nav.html.erb @@ -4,4 +4,5 @@ <li><%= link_to "Activity", admin_activities_path %></li> <li><%= link_to "Subscriptions", admin_subscriptions_path %></li> <li><%= link_to "Photos", admin_photos_path %></li> + <li><%= link_to "Blobs", admin_blobs_path %></li> </ul> diff --git a/config/routes.rb b/config/routes.rb index 7ab70eaa..c2182851 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -57,6 +57,7 @@ Cake::Application.routes.draw do resources :activities, only: [:index] resources :subscriptions, only: [:index] resources :photos, only: [:index, :show] + resources :blobs, only: [:index, :show] resources :errors, only: [:index, :create] end |
