Created
March 25, 2015 04:56
-
-
Save jamesdavidson/65b16dc4c5f964cb3ead to your computer and use it in GitHub Desktop.
Make a HTML list of names from S3 bucket meta-data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Retrieve a list of buckets. | |
| ; Retrieve the access-control-list. | |
| ; For each, print the owner's display-name. | |
| (ns com.example | |
| (:use amazonica.core | |
| amazonica.aws.s3 | |
| clojure.pprint)) | |
| (defn retrieve-name [bucket] | |
| (:display-name | |
| (:owner | |
| (get-bucket-acl | |
| (:name bucket))))) | |
| (defn bullet-list [title items] | |
| (str "<p>" title "</p>" | |
| "<ul>" items "</ul>")) | |
| (defn bullet-point [item] | |
| (str "<li>" item "</li>")) | |
| (defn write-index-html [output] | |
| (spit "index.html" | |
| (str | |
| "<html>" | |
| "<head>" | |
| "<title>hello</title>" | |
| "</head>" | |
| "<body>" | |
| "<div>" | |
| output | |
| "</div>" | |
| "</body>" | |
| "</html>"))) | |
| (write-index-html | |
| (bullet-list | |
| "bucket owners" | |
| (reduce str "" | |
| (map (comp bullet-point retrieve-name) | |
| (list-buckets))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice