Skip to content

Commit

Permalink
fix quicklook for s3 buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy Wang authored and Tommy Wang committed Dec 3, 2016
1 parent fab146c commit dca865a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aws_workflow/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def get_s3_buckets():
continue
log.error(e)
else:
for tag in tags.get('TagSet', []):
bucket['TagSet'] = tags.get('TagSet', [])
for tag in bucket['TagSet']:
bucket['facets'][tag['Key'].lower()] = tag['Value']
finally:
buckets.append(bucket)
Expand Down
1 change: 1 addition & 0 deletions aws_workflow/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@ def find_s3_bucket(wf, profile, region_name, terms, facets, quicklook_baseurl):
uid=uid,
icon='icons/s3_bucket.png',
type='default',
quicklookurl=quicklookurl
)
12 changes: 12 additions & 0 deletions quicklook_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@ def get(self):
self.write(template.render(**context))


class S3QuicklookHandler(tornado.web.RequestHandler):
def enrich(self, context):
pass

def get(self):
template = templates.get_template('s3.html.j2')
context = json.loads(self.get_argument('context', '{}'))
self.enrich(context)
self.write(template.render(**context))


def make_app():
return tornado.web.Application([
(r'/static/(.*)', tornado.web.StaticFileHandler, {'path': os.path.join(os.getcwd(), 'static')}),
(r'/quicklook/ec2', Ec2QuicklookHandler),
(r'/quicklook/s3', S3QuicklookHandler),
])


Expand Down
27 changes: 27 additions & 0 deletions templates/s3.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<html>
<head>
<title>{{ title }}</title>
<link rel="stylesheet" type="text/css" href="/static/css/main.css">
</head>
<body>
<h1>{{ title }}</h1>
<table>
<tr>
<td>Creation Date:</td>
<td>{{ bucket.CreationDate }}</td>
</tr>
<tr>
<td>Tags:</td>
<td>
<dl>
{% for tag in bucket.TagSet %}
<dt>{{ tag.Key }}</dt>
<dd>{{ tag.Value }}</dd>
{% endfor %}
</dl>
</td>
</tr>
</table>
{{ foo }}
</body>
</html>

0 comments on commit dca865a

Please sign in to comment.