s3browser 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +164 -0
- data/Rakefile +3 -0
- data/Vagrantfile +53 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/exe/s3browser-worker +25 -0
- data/lib/s3browser.rb +5 -0
- data/lib/s3browser/fetch.rb +43 -0
- data/lib/s3browser/gem_tasks.rb +158 -0
- data/lib/s3browser/plugins/es.rb +206 -0
- data/lib/s3browser/plugins/images.rb +33 -0
- data/lib/s3browser/plugins/upload.rb +22 -0
- data/lib/s3browser/policy.json +19 -0
- data/lib/s3browser/server.rb +81 -0
- data/lib/s3browser/store.rb +106 -0
- data/lib/s3browser/version.rb +3 -0
- data/lib/s3browser/views/bucket.haml +55 -0
- data/lib/s3browser/views/column_header.haml +4 -0
- data/lib/s3browser/views/flash_messages.haml +12 -0
- data/lib/s3browser/views/index.haml +12 -0
- data/lib/s3browser/views/layout.haml +39 -0
- data/lib/s3browser/worker.rb +41 -0
- data/s3browser.gemspec +40 -0
- metadata +213 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
.row
|
2
|
+
.col-md-12
|
3
|
+
.panel.panel-primary
|
4
|
+
.panel-heading
|
5
|
+
= bucket
|
6
|
+
.panel-body
|
7
|
+
.col-md-10
|
8
|
+
%form.form-horizontal{method: 'get', action: "/#{bucket}"}
|
9
|
+
.form-group
|
10
|
+
.input-group
|
11
|
+
%input.form-control{ type: 'text', name: 'q', placeholder: 'Search', value: q }
|
12
|
+
%span.input-group-btn
|
13
|
+
%button.btn.btn-default{ type: 'submit' } Go!
|
14
|
+
.col-md-2
|
15
|
+
- if settings.store.respond_to? :upload
|
16
|
+
%button.btn.btn-primary.btn-block{ 'type' => 'button', 'data-toggle' => 'modal', 'data-target' => '#upload-modal'}
|
17
|
+
Upload
|
18
|
+
|
19
|
+
%table.table.table-bordered.table-striped.table-condensed.table-hover
|
20
|
+
%thead
|
21
|
+
%tr
|
22
|
+
= haml :column_header, locals: { field: :key }
|
23
|
+
= haml :column_header, locals: { field: :size }
|
24
|
+
= haml :column_header, locals: { field: :content_type, field_name: 'Type' }
|
25
|
+
= haml :column_header, locals: { field: :last_modified }
|
26
|
+
%th
|
27
|
+
Thumbnail
|
28
|
+
%tbody
|
29
|
+
-objects.each do |obj|
|
30
|
+
%tr
|
31
|
+
%td
|
32
|
+
%a{ target: '_blank', href: obj[:url] }
|
33
|
+
= obj[:key]
|
34
|
+
%td= obj[:size]
|
35
|
+
%td= obj[:content_type]
|
36
|
+
%td= Time.at(obj[:last_modified]).strftime('%Y-%m-%d %H:%M:%S')
|
37
|
+
%td
|
38
|
+
-if obj[:thumbnail]
|
39
|
+
%img{ src: obj[:thumbnail][:url], width: obj[:thumbnail][:width]}
|
40
|
+
|
41
|
+
- if settings.store.respond_to? :upload
|
42
|
+
%form{ enctype: 'multipart/form-data', method: 'post', action: '/upload' }
|
43
|
+
#upload-modal.modal.fade{ tabindex: -1, role: 'dialog' }
|
44
|
+
.modal-dialog
|
45
|
+
.modal-content
|
46
|
+
.modal-header
|
47
|
+
%button.close{ type: 'button', 'data-dismiss' => 'modal', 'aria-label' => 'Close' }
|
48
|
+
%span{ 'aria-hidden' => 'true' } ×
|
49
|
+
%h4.modal-title Upload
|
50
|
+
.modal-body
|
51
|
+
.form-group
|
52
|
+
%input{ type: 'file', name: 'upload' }
|
53
|
+
.modal-footer
|
54
|
+
%button.btn.btn-default{ type: 'button', 'data-dismiss' => 'modal' } Close
|
55
|
+
%button.btn.btn-primary{ type: 'submit' } Upload
|
@@ -0,0 +1,12 @@
|
|
1
|
+
- if f_error = flash[:error]
|
2
|
+
.alert.alert-danger{ role: 'alert' }
|
3
|
+
= f_error
|
4
|
+
- if f_warning = flash[:warning]
|
5
|
+
.alert.alert-warning{ role: 'alert' }
|
6
|
+
= f_warning
|
7
|
+
- if f_success = flash[:success]
|
8
|
+
.alert.alert-success{ role: 'alert' }
|
9
|
+
= f_success
|
10
|
+
- if f_info = flash[:info]
|
11
|
+
.alert.alert-info{ role: 'alert' }
|
12
|
+
= f_info
|
@@ -0,0 +1,39 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%meta{:charset => 'utf-8'}
|
5
|
+
%title
|
6
|
+
S3Browser
|
7
|
+
- if defined? title
|
8
|
+
= "- #{title}"
|
9
|
+
%meta{:name => "description", :content => ""}
|
10
|
+
%meta{:name => "author", :content => ""}
|
11
|
+
|
12
|
+
:plain
|
13
|
+
<!--[if IE9]>
|
14
|
+
<script src="//oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
15
|
+
<script src="//oss.maxcdn.com/libs/respond/1.4.2/respond.min.js"></script>
|
16
|
+
<![endif]-->
|
17
|
+
|
18
|
+
/ Le styles
|
19
|
+
%link{ href: '//maxcdn.bootstrapcdn.com/bootswatch/3.3.4/flatly/bootstrap.min.css', type: 'text/css', rel: 'stylesheet' }
|
20
|
+
%link{ href: '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', type: 'text/css', rel: 'stylesheet' }
|
21
|
+
|
22
|
+
%body
|
23
|
+
- if defined? title
|
24
|
+
.container
|
25
|
+
.page-header
|
26
|
+
%h1= title
|
27
|
+
|
28
|
+
.container
|
29
|
+
= haml :flash_messages
|
30
|
+
|
31
|
+
= yield
|
32
|
+
|
33
|
+
%hr
|
34
|
+
|
35
|
+
/ Placed at the end of the document so the pages load faster
|
36
|
+
%script{ type: 'text/javascript', src: '//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js' }
|
37
|
+
%script{ type: 'text/javascript', src: '//maps.googleapis.com/maps/api/js?libraries=places' }
|
38
|
+
%script{ type: 'text/javascript', src: '//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js' }
|
39
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'shoryuken'
|
2
|
+
require 's3browser/store'
|
3
|
+
|
4
|
+
module S3Browser
|
5
|
+
class Worker
|
6
|
+
include Shoryuken::Worker
|
7
|
+
|
8
|
+
shoryuken_options queue: ENV['AWS_SQS_QUEUE'], body_parser: :json, auto_delete: true
|
9
|
+
|
10
|
+
class Store < S3Browser::Store
|
11
|
+
plugin :es
|
12
|
+
plugin :images
|
13
|
+
end
|
14
|
+
|
15
|
+
def perform(sqs_msg, body)
|
16
|
+
if body['Records']
|
17
|
+
body['Records'].each do |record|
|
18
|
+
bucket = record['s3']['bucket']['name']
|
19
|
+
key = record['s3']['object']['key']
|
20
|
+
|
21
|
+
info = s3.head_object({ bucket: bucket, key: key })
|
22
|
+
info = info.to_h.merge(record['s3']['object'])
|
23
|
+
|
24
|
+
store.add bucket, info
|
25
|
+
end
|
26
|
+
else
|
27
|
+
raise unless body['Event'] == 's3:TestEvent'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def store
|
33
|
+
@store ||= Store.new('s3browser')
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def s3
|
38
|
+
@s3 ||= Aws::S3::Client.new
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/s3browser.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 's3browser/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "s3browser"
|
8
|
+
spec.version = S3Browser::VERSION
|
9
|
+
spec.authors = ["Jurgens du Toit"]
|
10
|
+
spec.email = ["jrgns@jrgns.net"]
|
11
|
+
|
12
|
+
spec.summary = %q{A simple yet extendable utility to browse files on S3.}
|
13
|
+
spec.description = %q{A simple yet extendable utility to browse files on S3.}
|
14
|
+
spec.homepage = "https://github.com/jrgns/s3browser"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
31
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
32
|
+
spec.add_dependency 'aws-sdk'
|
33
|
+
spec.add_dependency 'elasticsearch'
|
34
|
+
spec.add_dependency 'sinatra'
|
35
|
+
spec.add_dependency 'rack-flash3'
|
36
|
+
spec.add_dependency 'haml'
|
37
|
+
spec.add_dependency 'highline'
|
38
|
+
spec.add_dependency 'dotenv'
|
39
|
+
spec.add_dependency 'shoryuken'
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: s3browser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jurgens du Toit
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aws-sdk
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: elasticsearch
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sinatra
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rack-flash3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: haml
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: highline
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: dotenv
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: shoryuken
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: A simple yet extendable utility to browse files on S3.
|
154
|
+
email:
|
155
|
+
- jrgns@jrgns.net
|
156
|
+
executables:
|
157
|
+
- s3browser-worker
|
158
|
+
extensions: []
|
159
|
+
extra_rdoc_files: []
|
160
|
+
files:
|
161
|
+
- ".gitignore"
|
162
|
+
- ".ruby-version"
|
163
|
+
- Gemfile
|
164
|
+
- LICENSE.txt
|
165
|
+
- README.md
|
166
|
+
- Rakefile
|
167
|
+
- Vagrantfile
|
168
|
+
- bin/console
|
169
|
+
- bin/setup
|
170
|
+
- exe/s3browser-worker
|
171
|
+
- lib/s3browser.rb
|
172
|
+
- lib/s3browser/fetch.rb
|
173
|
+
- lib/s3browser/gem_tasks.rb
|
174
|
+
- lib/s3browser/plugins/es.rb
|
175
|
+
- lib/s3browser/plugins/images.rb
|
176
|
+
- lib/s3browser/plugins/upload.rb
|
177
|
+
- lib/s3browser/policy.json
|
178
|
+
- lib/s3browser/server.rb
|
179
|
+
- lib/s3browser/store.rb
|
180
|
+
- lib/s3browser/version.rb
|
181
|
+
- lib/s3browser/views/bucket.haml
|
182
|
+
- lib/s3browser/views/column_header.haml
|
183
|
+
- lib/s3browser/views/flash_messages.haml
|
184
|
+
- lib/s3browser/views/index.haml
|
185
|
+
- lib/s3browser/views/layout.haml
|
186
|
+
- lib/s3browser/worker.rb
|
187
|
+
- s3browser.gemspec
|
188
|
+
homepage: https://github.com/jrgns/s3browser
|
189
|
+
licenses:
|
190
|
+
- MIT
|
191
|
+
metadata:
|
192
|
+
allowed_push_host: https://rubygems.org
|
193
|
+
post_install_message:
|
194
|
+
rdoc_options: []
|
195
|
+
require_paths:
|
196
|
+
- lib
|
197
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
|
+
requirements:
|
204
|
+
- - ">="
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
207
|
+
requirements: []
|
208
|
+
rubyforge_project:
|
209
|
+
rubygems_version: 2.5.1
|
210
|
+
signing_key:
|
211
|
+
specification_version: 4
|
212
|
+
summary: A simple yet extendable utility to browse files on S3.
|
213
|
+
test_files: []
|