carraway 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +58 -0
- data/README.md +2 -0
- data/docker/docker-compose.yml +8 -0
- data/lib/carraway/cli.rb +2 -0
- data/lib/carraway/file.rb +2 -1
- data/lib/carraway/file_repository.rb +76 -5
- data/lib/carraway/server.rb +24 -0
- data/lib/carraway/version.rb +1 -1
- data/lib/carraway/views/file_edit.erb +21 -0
- data/lib/carraway/views/files.erb +5 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36a15e8b79a0687aed5a10830b95266d42c335fe44d89c5c9d437fe25d142ebc
|
4
|
+
data.tar.gz: ff04bf837c8be068eb9402ff2c9c50270d047947befa4053ead816cfb9baa14d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31243a8f655fccb76aacc36bb6e029118bcf2d725b29bfadffd322fe3540c183033fdeb5431c4d10934592e2090c092e34082adf1202fc9eb676045667903d81
|
7
|
+
data.tar.gz: 125910fed0d17842f64b8adff09388d0568c5cf46667f6a46b02192bb7e4cc58ad29a8e188424a8a34a284bf31056b7c9d0b45c8fcd242e8aec800bed0ca5a52
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [v0.10.0](https://github.com/adorechic/carraway/tree/v0.10.0) (2019-02-11)
|
4
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.9.0...v0.10.0)
|
5
|
+
|
6
|
+
**Merged pull requests:**
|
7
|
+
|
8
|
+
- Post labeling [\#4](https://github.com/adorechic/carraway/pull/4) ([adorechic](https://github.com/adorechic))
|
9
|
+
- Extract file repository [\#3](https://github.com/adorechic/carraway/pull/3) ([adorechic](https://github.com/adorechic))
|
10
|
+
- Improve README documents [\#2](https://github.com/adorechic/carraway/pull/2) ([adorechic](https://github.com/adorechic))
|
11
|
+
|
12
|
+
## [v0.9.0](https://github.com/adorechic/carraway/tree/v0.9.0) (2018-11-07)
|
13
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.8.0...v0.9.0)
|
14
|
+
|
15
|
+
## [v0.8.0](https://github.com/adorechic/carraway/tree/v0.8.0) (2018-09-05)
|
16
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.7.0...v0.8.0)
|
17
|
+
|
18
|
+
**Merged pull requests:**
|
19
|
+
|
20
|
+
- Add render HTML using Markdown option [\#1](https://github.com/adorechic/carraway/pull/1) ([autumo](https://github.com/autumo))
|
21
|
+
|
22
|
+
## [v0.7.0](https://github.com/adorechic/carraway/tree/v0.7.0) (2018-09-04)
|
23
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.6.0...v0.7.0)
|
24
|
+
|
25
|
+
## [v0.6.0](https://github.com/adorechic/carraway/tree/v0.6.0) (2018-09-03)
|
26
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.5.0...v0.6.0)
|
27
|
+
|
28
|
+
## [v0.5.0](https://github.com/adorechic/carraway/tree/v0.5.0) (2018-09-03)
|
29
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.4.0...v0.5.0)
|
30
|
+
|
31
|
+
## [v0.4.0](https://github.com/adorechic/carraway/tree/v0.4.0) (2018-09-03)
|
32
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.3.1...v0.4.0)
|
33
|
+
|
34
|
+
## [v0.3.1](https://github.com/adorechic/carraway/tree/v0.3.1) (2018-08-31)
|
35
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.3.0...v0.3.1)
|
36
|
+
|
37
|
+
## [v0.3.0](https://github.com/adorechic/carraway/tree/v0.3.0) (2018-08-31)
|
38
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.2.1...v0.3.0)
|
39
|
+
|
40
|
+
## [v0.2.1](https://github.com/adorechic/carraway/tree/v0.2.1) (2018-08-31)
|
41
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.2.0...v0.2.1)
|
42
|
+
|
43
|
+
## [v0.2.0](https://github.com/adorechic/carraway/tree/v0.2.0) (2018-08-30)
|
44
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.1.3...v0.2.0)
|
45
|
+
|
46
|
+
## [v0.1.3](https://github.com/adorechic/carraway/tree/v0.1.3) (2018-08-30)
|
47
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.1.2...v0.1.3)
|
48
|
+
|
49
|
+
## [v0.1.2](https://github.com/adorechic/carraway/tree/v0.1.2) (2018-08-27)
|
50
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.1.1...v0.1.2)
|
51
|
+
|
52
|
+
## [v0.1.1](https://github.com/adorechic/carraway/tree/v0.1.1) (2018-08-27)
|
53
|
+
[Full Changelog](https://github.com/adorechic/carraway/compare/v0.1.0...v0.1.1)
|
54
|
+
|
55
|
+
## [v0.1.0](https://github.com/adorechic/carraway/tree/v0.1.0) (2018-08-27)
|
56
|
+
|
57
|
+
|
58
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/README.md
CHANGED
@@ -69,6 +69,8 @@ backend: # Required
|
|
69
69
|
file_backend:
|
70
70
|
bucket: 'carraway_bucket' # Required
|
71
71
|
prefix: 'files' # Required.
|
72
|
+
endpoint: http://localhost:6001 # Optional. Set if you use local S3 like mineo
|
73
|
+
region: ap-northeast-1 # Optional.
|
72
74
|
categories: # Least one category is required
|
73
75
|
category_key:
|
74
76
|
title: 'Category Name'
|
data/docker/docker-compose.yml
CHANGED
@@ -7,3 +7,11 @@ services:
|
|
7
7
|
command: -jar DynamoDBLocal.jar -dbPath /var/lib/dynamodb -port 6000
|
8
8
|
volumes:
|
9
9
|
- /tmp:/var/lib/dynamodb
|
10
|
+
minio:
|
11
|
+
image: minio/minio
|
12
|
+
ports:
|
13
|
+
- '6001:9000'
|
14
|
+
environment:
|
15
|
+
MINIO_ACCESS_KEY: dummy
|
16
|
+
MINIO_SECRET_KEY: dummy_secret
|
17
|
+
command: server /data
|
data/lib/carraway/cli.rb
CHANGED
@@ -15,6 +15,7 @@ module Carraway
|
|
15
15
|
def setup
|
16
16
|
Carraway::Config.load(options[:config])
|
17
17
|
Carraway::Post.setup
|
18
|
+
Carraway::FileRepository.new.setup
|
18
19
|
end
|
19
20
|
|
20
21
|
desc 'drop', 'Drop backend'
|
@@ -22,6 +23,7 @@ module Carraway
|
|
22
23
|
def drop
|
23
24
|
Carraway::Config.load(options[:config])
|
24
25
|
Carraway::Post.drop
|
26
|
+
Carraway::FileRepository.new.drop
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
data/lib/carraway/file.rb
CHANGED
@@ -18,6 +18,32 @@ module Carraway
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def find(uid)
|
22
|
+
item = client.get_item(
|
23
|
+
key: {
|
24
|
+
uid: uid
|
25
|
+
},
|
26
|
+
table_name: Config.backend['table_name'],
|
27
|
+
).item
|
28
|
+
if item && item['record_type'] == 'file'
|
29
|
+
Carraway::File.new(
|
30
|
+
uid: item['uid'],
|
31
|
+
title: item['title'],
|
32
|
+
created: item['created']
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def persisted?(file)
|
38
|
+
s3_client.head_object(
|
39
|
+
bucket: Config.file_backend['bucket'],
|
40
|
+
key: file.path
|
41
|
+
)
|
42
|
+
true
|
43
|
+
rescue Aws::S3::Errors::NotFound
|
44
|
+
false
|
45
|
+
end
|
46
|
+
|
21
47
|
def save(file, at: Time.now)
|
22
48
|
client.put_item(
|
23
49
|
table_name: Config.backend['table_name'],
|
@@ -25,15 +51,50 @@ module Carraway
|
|
25
51
|
uid: file.uid,
|
26
52
|
record_type: 'file',
|
27
53
|
title: file.title,
|
28
|
-
created: at.to_i
|
54
|
+
created: file.created || at.to_i
|
29
55
|
}
|
30
56
|
)
|
31
|
-
|
32
|
-
|
57
|
+
if file.file
|
58
|
+
s3_client.put_object(
|
59
|
+
body: file.file[:tempfile],
|
60
|
+
bucket: Config.file_backend['bucket'],
|
61
|
+
acl: 'public-read',
|
62
|
+
key: file.path
|
63
|
+
)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def destroy(file)
|
68
|
+
s3_client.delete_object(
|
33
69
|
bucket: Config.file_backend['bucket'],
|
34
|
-
acl: 'public-read',
|
35
70
|
key: file.path
|
36
71
|
)
|
72
|
+
client.delete_item(
|
73
|
+
table_name: Config.backend['table_name'],
|
74
|
+
key: {
|
75
|
+
uid: file.uid
|
76
|
+
}
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
def setup
|
81
|
+
s3_client.create_bucket(
|
82
|
+
bucket: Config.file_backend['bucket']
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
def drop
|
87
|
+
s3_client.list_objects(
|
88
|
+
bucket: Config.file_backend['bucket']
|
89
|
+
).contents.each do |content|
|
90
|
+
s3_client.delete_object(
|
91
|
+
bucket: Config.file_backend['bucket'],
|
92
|
+
key: content.key
|
93
|
+
)
|
94
|
+
end
|
95
|
+
s3_client.delete_bucket(
|
96
|
+
bucket: Config.file_backend['bucket']
|
97
|
+
)
|
37
98
|
end
|
38
99
|
|
39
100
|
private
|
@@ -52,7 +113,17 @@ module Carraway
|
|
52
113
|
end
|
53
114
|
|
54
115
|
def s3_client
|
55
|
-
|
116
|
+
if Config.file_backend['endpoint']
|
117
|
+
Aws::S3::Client.new(
|
118
|
+
endpoint: Config.file_backend['endpoint'],
|
119
|
+
region: Config.file_backend['region'],
|
120
|
+
access_key_id: 'dummy',
|
121
|
+
secret_access_key: 'dummy_secret',
|
122
|
+
force_path_style: true,
|
123
|
+
)
|
124
|
+
else
|
125
|
+
Aws::S3::Client.new
|
126
|
+
end
|
56
127
|
end
|
57
128
|
end
|
58
129
|
end
|
data/lib/carraway/server.rb
CHANGED
@@ -122,11 +122,35 @@ module Carraway
|
|
122
122
|
redirect "/carraway/"
|
123
123
|
end
|
124
124
|
|
125
|
+
get %r{/carraway/files/(\d+)} do |uid|
|
126
|
+
# FIXME handle not found
|
127
|
+
@file = FileRepository.new.find(uid)
|
128
|
+
erb :file_edit
|
129
|
+
end
|
130
|
+
|
125
131
|
get '/carraway/files' do
|
126
132
|
@files = FileRepository.new.all
|
127
133
|
erb :files
|
128
134
|
end
|
129
135
|
|
136
|
+
patch %r{/carraway/files/(\d+)} do |uid|
|
137
|
+
repository = FileRepository.new
|
138
|
+
file = repository.find(uid)
|
139
|
+
# FIXME handle not found
|
140
|
+
# FIXME validation
|
141
|
+
file.title = params[:title]
|
142
|
+
repository.save(file)
|
143
|
+
redirect "/carraway/files/#{file.uid}"
|
144
|
+
end
|
145
|
+
|
146
|
+
delete %r{/carraway/files/(\d+)} do |uid|
|
147
|
+
repository = FileRepository.new
|
148
|
+
file = repository.find(uid)
|
149
|
+
# FIXME handle not found
|
150
|
+
repository.destroy(file)
|
151
|
+
redirect "/carraway/files"
|
152
|
+
end
|
153
|
+
|
130
154
|
post '/carraway/files' do
|
131
155
|
file = File.new(title: params[:title], file: params[:file])
|
132
156
|
# FIXME validation and error
|
data/lib/carraway/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
<h3><%= @file.title %></h3>
|
2
|
+
<p><%= @file.path %></p>
|
3
|
+
<div class="row">
|
4
|
+
<form action="/carraway/files/<%= @file.uid %>" method="POST" class="col s12" enctype="multipart/form-data">
|
5
|
+
<input type="hidden" name="_method" value="PATCH">
|
6
|
+
<div class="row">
|
7
|
+
<div class="input-field col s12">
|
8
|
+
<input type="text" id="title" name="title" placeholder="ファイルタイトル" value="<%= @file.title %>" >
|
9
|
+
<label for="title">ファイルタイトル</label>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<button type="submit" class="waves-effect waves-light btn">保存</button>
|
14
|
+
</form>
|
15
|
+
<form action="/carraway/files/<%= @file.uid %>" method="POST" class="col s12">
|
16
|
+
<input type="hidden" name="_method" value="DELETE">
|
17
|
+
<div class="col s6">
|
18
|
+
<button type="submit" class="waves-effect waves-light btn red">削除</button>
|
19
|
+
</div>
|
20
|
+
</form>
|
21
|
+
</div>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carraway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- adorechic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- ".gitignore"
|
204
204
|
- ".rspec"
|
205
205
|
- ".travis.yml"
|
206
|
+
- CHANGELOG.md
|
206
207
|
- CODE_OF_CONDUCT.md
|
207
208
|
- Gemfile
|
208
209
|
- LICENSE.txt
|
@@ -224,6 +225,7 @@ files:
|
|
224
225
|
- lib/carraway/server.rb
|
225
226
|
- lib/carraway/version.rb
|
226
227
|
- lib/carraway/views/edit.erb
|
228
|
+
- lib/carraway/views/file_edit.erb
|
227
229
|
- lib/carraway/views/file_modal.erb
|
228
230
|
- lib/carraway/views/files.erb
|
229
231
|
- lib/carraway/views/layout.erb
|
@@ -248,8 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
250
|
- !ruby/object:Gem::Version
|
249
251
|
version: '0'
|
250
252
|
requirements: []
|
251
|
-
|
252
|
-
rubygems_version: 2.7.7
|
253
|
+
rubygems_version: 3.0.2
|
253
254
|
signing_key:
|
254
255
|
specification_version: 4
|
255
256
|
summary: GatsbyJS backend
|