shrine-host-url 0.0.1 → 0.0.2
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/.gitignore +1 -0
- data/Readme.md +85 -9
- data/lib/shrine/plugins/host_url.rb +3 -2
- data/shrine-host-url.gemspec +1 -1
- metadata +2 -3
- data/README.md +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 598ec4dba45f858c85c82adbc8b2aaebf6d6ab41
|
4
|
+
data.tar.gz: 71ef0cef8aad32b4830c2a0fee42f6e0b442f477
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dde4237332cf6c41be553371bf66be71f5067862e8efc94dad624d055f315f7d25b9d2594b4ac928d82b07b4ef57a148bec625d89151785003897692bec4f54
|
7
|
+
data.tar.gz: f75b3b8cb45516158852d3d9701846b0fef67e94e6343d0d3dab02a6a76517db81916eead30116f21945f4320a0f456684d5e6222582ee3c55615dc7d5d9c327
|
data/.gitignore
CHANGED
data/Readme.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Shrine::Host::Url
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
[Shrine](https://github.com/janko-m/shrine) got many different plugins for almost everywhat you want. To change host url you can use [default_url_options](http://shrinerb.com/rdoc/classes/Shrine/Plugins/DefaultUrlOptions.html), but you can't change a host port with it. This plugin can help you change host and port for your image url. Read, please, description for details.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -20,19 +18,97 @@ Or install it yourself as:
|
|
20
18
|
|
21
19
|
$ gem install shrine-host-url
|
22
20
|
|
23
|
-
##
|
21
|
+
## Description
|
22
|
+
|
23
|
+
This plugin was developed to change minio host url and port for nginx static files caching.
|
24
|
+
I had some problems with caching when I've done like this [article](https://blog.minio.io/enterprise-grade-cloud-storage-with-nginx-plus-and-minio-e708fb4cb3e8). Someone had the same [problems](https://github.com/minio/minio/issues/4120). It was resolved like that:
|
25
|
+
1. You store file by direct link without nginx (or without nginx caching)
|
26
|
+
2. For reading from storage you need to use an another link with nginx caching
|
27
|
+
3. So, you need to change link in your RoR application
|
28
|
+
|
29
|
+
Example nginx config for storage
|
24
30
|
|
25
|
-
|
31
|
+
```
|
32
|
+
proxy_cache_path /var/cache/nginx/minio_cache levels=1:2 keys_zone=minio_cache:10m max_size=10m inactive=60m use_temp_path=off;
|
33
|
+
|
34
|
+
upstream minio_servers {
|
35
|
+
server localhost:9000;
|
36
|
+
}
|
37
|
+
|
38
|
+
server {
|
39
|
+
listen 80;
|
40
|
+
server_name minio.dev;
|
41
|
+
|
42
|
+
location / {
|
43
|
+
proxy_cache minio_cache;
|
44
|
+
add_header X-Cache-Status $upstream_cache_status;
|
45
|
+
proxy_cache_revalidate on;
|
46
|
+
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
47
|
+
proxy_cache_lock on;
|
48
|
+
proxy_ignore_headers Set-Cookie;
|
49
|
+
proxy_cache_valid 1m;
|
50
|
+
|
51
|
+
proxy_set_header Host $http_host;
|
52
|
+
proxy_pass http://minio_servers;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
```
|
26
56
|
|
27
|
-
|
57
|
+
### Usage
|
58
|
+
|
59
|
+
We are using minio for storing images with [shrine](http://shrinerb.com).
|
60
|
+
Add to Gemfile
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
gem 'shrine-fog'
|
64
|
+
gem 'fog-aws'
|
65
|
+
```
|
28
66
|
|
29
|
-
|
67
|
+
config/initializers/shrine.rb
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
require 'shrine/storage/fog'
|
71
|
+
require 'fog/aws'
|
72
|
+
require 'image_processing/mini_magick'
|
73
|
+
|
74
|
+
minio = Fog::Storage.new(
|
75
|
+
provider: 'AWS',
|
76
|
+
aws_access_key_id: '<key>',
|
77
|
+
aws_secret_access_key: '<secret>',
|
78
|
+
region: 'us-east-1',
|
79
|
+
endpoint: 'http://localhost:9000/',
|
80
|
+
path_style: true,
|
81
|
+
)
|
82
|
+
|
83
|
+
Shrine.storages[:cache] = Shrine::Storage::Fog.new(
|
84
|
+
connection: minio,
|
85
|
+
directory: '<cache-directory>',
|
86
|
+
public: true,
|
87
|
+
)
|
88
|
+
|
89
|
+
Shrine.storages[:store] = Shrine::Storage::Fog.new(
|
90
|
+
connection: minio,
|
91
|
+
directory: '<store-directory>',
|
92
|
+
public: true,
|
93
|
+
)
|
94
|
+
```
|
95
|
+
|
96
|
+
Also, you need to add with the minio client corresponding directories and grant privileges.
|
97
|
+
|
98
|
+
app/models/image_uploader.rb
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
class ImageUploader < Shrine
|
102
|
+
<...>
|
103
|
+
plugin :host_url, host: 'minio.dev', port: '8000'
|
104
|
+
end
|
105
|
+
```
|
30
106
|
|
31
|
-
|
107
|
+
For more options read, please, official shrine documentation
|
32
108
|
|
33
109
|
## Contributing
|
34
110
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
111
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/domido-com/shrine-host-url
|
36
112
|
|
37
113
|
## License
|
38
114
|
|
@@ -9,6 +9,7 @@ class Shrine
|
|
9
9
|
def url(**options)
|
10
10
|
new_uri(
|
11
11
|
URI.parse(super),
|
12
|
+
uploader.opts[:host_url][:scheme],
|
12
13
|
uploader.opts[:host_url][:host],
|
13
14
|
uploader.opts[:host_url][:port]
|
14
15
|
)
|
@@ -16,9 +17,9 @@ class Shrine
|
|
16
17
|
|
17
18
|
private
|
18
19
|
|
19
|
-
def new_uri(uri, new_host, new_port)
|
20
|
+
def new_uri(uri, new_scheme, new_host, new_port)
|
20
21
|
URI::HTTP.new(
|
21
|
-
|
22
|
+
new_scheme,
|
22
23
|
uri.userinfo,
|
23
24
|
new_host,
|
24
25
|
new_port,
|
data/shrine-host-url.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shrine-host-url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Tesevich
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,7 +70,6 @@ files:
|
|
70
70
|
- ".travis.yml"
|
71
71
|
- Gemfile
|
72
72
|
- LICENSE.txt
|
73
|
-
- README.md
|
74
73
|
- Rakefile
|
75
74
|
- Readme.md
|
76
75
|
- bin/console
|
data/README.md
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# Shrine::Host::Url
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/shrine/host/url`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'shrine-host-url'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install shrine-host-url
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/shrine-host-url.
|
36
|
-
|
37
|
-
## License
|
38
|
-
|
39
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|