Commit efbcdb4d

mo khan <mo@mokhan.ca>
2014-06-09 03:28:45
add controller to display s3 objects.
1 parent 00743ed
Changed files (5)
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
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>
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>
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>
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