paperclip-remote_assets 0.1.1 → 0.1.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/README.md +14 -2
- data/lib/paperclip/remote_assets/middleware.rb +7 -1
- data/lib/paperclip/remote_assets/version.rb +1 -1
- data/lib/paperclip/remote_assets.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f2492873d2b543667d59b27e1355c80c14a692b
|
4
|
+
data.tar.gz: dab9d11741e5065c8eb89cfabd313d53c8649961
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66db547ecbd44968c2a8ca688a92f6a1a6fc232c74456cc491bc5fafe4fec2dfc1611ff7bf555dd7207ad2b5f291b020635bfc9f18ba8ecf8441ff04089c65ad
|
7
|
+
data.tar.gz: 42d922ab0644cf2abdafd7837de7b81e7781d0740aa125da4f5846a9b09b1f217cfce043ea8c15e5eb063f5e5de106b785726876b7b7adda10337abad49a5c6a
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ the middleware checks if the file exists in your `public/system` folder and
|
|
8
8
|
redirects to the remote target if it doesn't.
|
9
9
|
|
10
10
|
> **Note** : This only works if your local assets storing path matches the
|
11
|
-
remote one.
|
11
|
+
remote one.
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
@@ -43,7 +43,19 @@ alternatively, in some initializer or environment file :
|
|
43
43
|
Paperclip::RemoteAssets.remote_root = 'http://www.my-production-domain.com'
|
44
44
|
```
|
45
45
|
|
46
|
-
|
46
|
+
If your remote assets root path does not start with `/system`, you can set
|
47
|
+
the following flag, so the middleware strips the leading `/system` from the
|
48
|
+
requested path.
|
49
|
+
|
50
|
+
```bash
|
51
|
+
ENV['REMOTE_ASSETS_ROOT_INCLUDES_SYSTEM'] = 'false'
|
52
|
+
```
|
53
|
+
|
54
|
+
alternatively, in some initializer or environment file :
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
Paperclip::RemoteAssets.remote_root_includes_system = false
|
58
|
+
```
|
47
59
|
|
48
60
|
## Contributing
|
49
61
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Paperclip
|
2
2
|
module RemoteAssets
|
3
3
|
class Middleware
|
4
|
+
SYSTEM_PREFIX_REGEX = /\A\/system\//
|
5
|
+
|
4
6
|
attr_reader :app
|
5
7
|
|
6
8
|
def initialize(app)
|
@@ -18,10 +20,14 @@ module Paperclip
|
|
18
20
|
private
|
19
21
|
|
20
22
|
def remote_asset?(path)
|
21
|
-
path.match(
|
23
|
+
path.match(SYSTEM_PREFIX_REGEX) && !File.exist?(Rails.root.join('public', path))
|
22
24
|
end
|
23
25
|
|
24
26
|
def remote_asset_path_for(path)
|
27
|
+
unless Paperclip::RemoteAssets.remote_root_includes_system?
|
28
|
+
path = path.gsub(SYSTEM_PREFIX_REGEX, '/')
|
29
|
+
end
|
30
|
+
|
25
31
|
File.join(Paperclip::RemoteAssets.remote_root, path)
|
26
32
|
end
|
27
33
|
end
|
@@ -7,10 +7,19 @@ module Paperclip
|
|
7
7
|
autoload :Middleware
|
8
8
|
|
9
9
|
mattr_writer :remote_root
|
10
|
+
mattr_writer :remote_root_includes_system
|
10
11
|
|
11
12
|
def self.remote_root
|
12
13
|
@@remote_root ||= ENV['REMOTE_ASSETS_ROOT']
|
13
14
|
end
|
15
|
+
|
16
|
+
def self.remote_root_includes_system?
|
17
|
+
@@remote_root_includes_system ||= if ENV.key?('REMOTE_ASSETS_ROOT_INCLUDES_SYSTEM')
|
18
|
+
ENV['REMOTE_ASSETS_ROOT_INCLUDES_SYSTEM'] == 'true'
|
19
|
+
else
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
14
23
|
end
|
15
24
|
end
|
16
25
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-remote_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vala
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|