cloud_assets 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -123,13 +123,13 @@ headers partial into the HTML head element, and replaces the interior
123
123
  of the element whose id is "content" -- say it's a div -- with the
124
124
  yield of the Rails view that uses this layout.
125
125
 
126
- ## Fixups
126
+ ## HTML Fixups
127
127
 
128
128
  The remote site likely was not designed to have its HTML repurposed and
129
129
  rewritten on other sites. Sites following best practices *should* not
130
130
  need any manual fixups. However, any number of hacks might produce HTML
131
131
  that cloud_assets does not know how to rewrite. You have an opportunity
132
- to fix these by adding a monkey-patch to your initializer:
132
+ to fix these by adding some monkey-patches to your initializer:
133
133
 
134
134
  ```ruby
135
135
  module CloudAssets
@@ -146,3 +146,20 @@ and best practice, it would be good to submit a pull request so
146
146
  cloud_assets can handle it. If not, it would be ideal to fix the
147
147
  remote asset source -- e.g. remove hard-coded references or eliminate
148
148
  unwarranted assumptions.
149
+
150
+ ## Remote URL Fixups
151
+
152
+ You can also use a monkey-patch to rewrite the URLs used to fetch the
153
+ remote assets, in case they do not align with the URLs of your
154
+ Rails site. Normally, cloud_assets just passes through the path
155
+ component of the URL exactly as requested from Rails; this allows
156
+ you to change that behavior to do anything you want, for example,
157
+ blacklisting or whitelisting URLs for the remote asset source.
158
+
159
+ ```ruby
160
+ module CloudAssets
161
+ def self.fixup_url(fullpath)
162
+ html.gsub 'wrongness', 'rightness'
163
+ end
164
+ end
165
+ ```
data/lib/cloud_assets.rb CHANGED
@@ -12,6 +12,12 @@ module CloudAssets
12
12
  html
13
13
  end
14
14
 
15
+ # Monkey-patch this method if you need to hack some fixups into
16
+ # asset requests urls
17
+ def self.fixup_url(fullpath)
18
+ fullpath
19
+ end
20
+
15
21
  # Monkey-patch this method if you need to hack some fixups into
16
22
  # javascript from your asset source.
17
23
  def self.fixup_javascript(javascript)
@@ -63,7 +69,7 @@ module CloudAssets
63
69
  require 'nokogiri'
64
70
 
65
71
  def cloud_asset(path)
66
- p = "#{CloudAssets::origin}#{path}"
72
+ p = CloudAssets::fixup_url("#{CloudAssets::origin}#{path}")
67
73
  hydra = Typhoeus::Hydra.new
68
74
  unless $dalli_cache.nil?
69
75
  hydra.cache_getter do |request|
@@ -1,3 +1,3 @@
1
1
  module CloudAssets
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-22 00:00:00.000000000 Z
12
+ date: 2012-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: typhoeus
16
- requirement: &70352043299300 !ruby/object:Gem::Requirement
16
+ requirement: &70291259168200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70352043299300
24
+ version_requirements: *70291259168200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &70352043298820 !ruby/object:Gem::Requirement
27
+ requirement: &70291259167780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70352043298820
35
+ version_requirements: *70291259167780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: dalli
38
- requirement: &70352043298340 !ruby/object:Gem::Requirement
38
+ requirement: &70291259167360 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70352043298340
46
+ version_requirements: *70291259167360
47
47
  description: ! "\n This gem is in use in some production sites to provide\n backing
48
48
  for a Rails app using content from WordPress and\n PostLaunch (a Java based CMS),
49
49
  and has specific\n dependencies on Typhoeus, Nokogiri, and dalli, favorites\n